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