fix: remove /api/ double-prefix from all frontend API calls
Frontend api.ts baseUrl is already "/api", so paths like "/api/cases" produced "/api/api/cases". Stripped the redundant prefix from all component calls. Rewrite destination correctly adds /api/ back for the Go backend.
This commit is contained in:
@@ -24,7 +24,7 @@ export default function AIExtractPage() {
|
||||
|
||||
const { data: casesData } = useQuery({
|
||||
queryKey: ["cases"],
|
||||
queryFn: () => api.get<PaginatedResponse<Case>>("/api/cases"),
|
||||
queryFn: () => api.get<PaginatedResponse<Case>>("/cases"),
|
||||
});
|
||||
|
||||
const cases = casesData?.data ?? [];
|
||||
@@ -40,12 +40,12 @@ export default function AIExtractPage() {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
response = await api.postFormData<ExtractionResponse>(
|
||||
"/api/ai/extract-deadlines",
|
||||
"/ai/extract-deadlines",
|
||||
formData,
|
||||
);
|
||||
} else {
|
||||
response = await api.post<ExtractionResponse>(
|
||||
"/api/ai/extract-deadlines",
|
||||
"/ai/extract-deadlines",
|
||||
{ text },
|
||||
);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ export default function AIExtractPage() {
|
||||
|
||||
try {
|
||||
const promises = deadlines.map((d) =>
|
||||
api.post(`/api/cases/${selectedCaseId}/deadlines`, {
|
||||
api.post(`/cases/${selectedCaseId}/deadlines`, {
|
||||
title: d.title,
|
||||
due_date: d.due_date ?? "",
|
||||
source: "ai_extraction",
|
||||
|
||||
@@ -16,7 +16,7 @@ export default function FristenPage() {
|
||||
|
||||
const { data: deadlines } = useQuery({
|
||||
queryKey: ["deadlines"],
|
||||
queryFn: () => api.get<Deadline[]>("/api/deadlines"),
|
||||
queryFn: () => api.get<Deadline[]>("/deadlines"),
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function TerminePage() {
|
||||
|
||||
const { data: appointments } = useQuery({
|
||||
queryKey: ["appointments"],
|
||||
queryFn: () => api.get<Appointment[]>("/api/appointments"),
|
||||
queryFn: () => api.get<Appointment[]>("/appointments"),
|
||||
});
|
||||
|
||||
function handleEdit(appointment: Appointment) {
|
||||
|
||||
@@ -54,16 +54,16 @@ export function AppointmentList({ onEdit }: AppointmentListProps) {
|
||||
|
||||
const { data: appointments, isLoading } = useQuery({
|
||||
queryKey: ["appointments"],
|
||||
queryFn: () => api.get<Appointment[]>("/api/appointments"),
|
||||
queryFn: () => api.get<Appointment[]>("/appointments"),
|
||||
});
|
||||
|
||||
const { data: cases } = useQuery({
|
||||
queryKey: ["cases"],
|
||||
queryFn: () => api.get<{ cases: Case[]; total: number }>("/api/cases"),
|
||||
queryFn: () => api.get<{ cases: Case[]; total: number }>("/cases"),
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: string) => api.delete(`/api/appointments/${id}`),
|
||||
mutationFn: (id: string) => api.delete(`/appointments/${id}`),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["appointments"] });
|
||||
toast.success("Termin geloscht");
|
||||
|
||||
@@ -41,7 +41,7 @@ export function AppointmentModal({ open, onClose, appointment }: AppointmentModa
|
||||
|
||||
const { data: cases } = useQuery({
|
||||
queryKey: ["cases"],
|
||||
queryFn: () => api.get<{ cases: Case[]; total: number }>("/api/cases"),
|
||||
queryFn: () => api.get<{ cases: Case[]; total: number }>("/cases"),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -66,7 +66,7 @@ export function AppointmentModal({ open, onClose, appointment }: AppointmentModa
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (body: Record<string, unknown>) =>
|
||||
api.post<Appointment>("/api/appointments", body),
|
||||
api.post<Appointment>("/appointments", body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["appointments"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["dashboard"] });
|
||||
@@ -89,7 +89,7 @@ export function AppointmentModal({ open, onClose, appointment }: AppointmentModa
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: () => api.delete(`/api/appointments/${appointment!.id}`),
|
||||
mutationFn: () => api.delete(`/appointments/${appointment!.id}`),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["appointments"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["dashboard"] });
|
||||
|
||||
@@ -39,14 +39,14 @@ export function DeadlineCalculator() {
|
||||
|
||||
const { data: proceedingTypes, isLoading: typesLoading } = useQuery({
|
||||
queryKey: ["proceeding-types"],
|
||||
queryFn: () => api.get<ProceedingType[]>("/api/proceeding-types"),
|
||||
queryFn: () => api.get<ProceedingType[]>("/proceeding-types"),
|
||||
});
|
||||
|
||||
const calculateMutation = useMutation({
|
||||
mutationFn: (params: {
|
||||
proceeding_type: string;
|
||||
trigger_event_date: string;
|
||||
}) => api.post<CalculateResponse>("/api/deadlines/calculate", params),
|
||||
}) => api.post<CalculateResponse>("/deadlines/calculate", params),
|
||||
});
|
||||
|
||||
function handleCalculate(e: React.FormEvent) {
|
||||
|
||||
@@ -54,12 +54,12 @@ export function DeadlineList() {
|
||||
|
||||
const { data: deadlines, isLoading } = useQuery({
|
||||
queryKey: ["deadlines"],
|
||||
queryFn: () => api.get<Deadline[]>("/api/deadlines"),
|
||||
queryFn: () => api.get<Deadline[]>("/deadlines"),
|
||||
});
|
||||
|
||||
const { data: cases } = useQuery({
|
||||
queryKey: ["cases"],
|
||||
queryFn: () => api.get<Case[]>("/api/cases"),
|
||||
queryFn: () => api.get<Case[]>("/cases"),
|
||||
});
|
||||
|
||||
const completeMutation = useMutation({
|
||||
|
||||
@@ -57,7 +57,7 @@ export function CalDAVSettings({ tenant }: { tenant: Tenant }) {
|
||||
// Fetch sync status
|
||||
const { data: syncStatus } = useQuery({
|
||||
queryKey: ["caldav-status"],
|
||||
queryFn: () => api.get<CalDAVSyncResponse>("/api/caldav/status"),
|
||||
queryFn: () => api.get<CalDAVSyncResponse>("/caldav/status"),
|
||||
refetchInterval: 30_000,
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ export function CalDAVSettings({ tenant }: { tenant: Tenant }) {
|
||||
|
||||
// Trigger sync
|
||||
const syncMutation = useMutation({
|
||||
mutationFn: () => api.post<CalDAVSyncResponse>("/api/caldav/sync"),
|
||||
mutationFn: () => api.post<CalDAVSyncResponse>("/caldav/sync"),
|
||||
onSuccess: (result) => {
|
||||
queryClient.invalidateQueries({ queryKey: ["caldav-status"] });
|
||||
if (result.status === "ok") {
|
||||
|
||||
Reference in New Issue
Block a user