From 56f2f98a5e6c427119107d1998e7f6e01d1a901a Mon Sep 17 00:00:00 2001 From: ghaddaditw <40211818-ghaddaditw@users.noreply.replit.com> Date: Sun, 8 Jun 2025 00:06:16 +0000 Subject: [PATCH] Improve financial record creation by ensuring data is handled correctly Refactor createRecordMutation in FinancesPage.tsx to handle fetch responses properly. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ff0be73b-afdd-4747-978b-bb8301fb0a82 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9777c70b-fc38-4831-8d6b-78dfffe041b0/1999d076-38ec-4633-8667-1740c231dafc.jpg --- client/src/pages/FinancesPage.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client/src/pages/FinancesPage.tsx b/client/src/pages/FinancesPage.tsx index 994016e..ecffffa 100644 --- a/client/src/pages/FinancesPage.tsx +++ b/client/src/pages/FinancesPage.tsx @@ -35,14 +35,21 @@ export default function FinancesPage() { const summary = (summaryResponse as any)?.summary || { income: 0, expenses: 0, net: 0 }; const createRecordMutation = useMutation({ - mutationFn: (record: typeof newRecord) => - apiRequest("/api/financial/records", { + mutationFn: async (record: typeof newRecord) => { + const response = await fetch("/api/financial/records", { method: "POST", + headers: { + "Content-Type": "application/json", + }, body: JSON.stringify({ ...record, amount: parseFloat(record.amount), }), - }), + credentials: "include", + }); + if (!response.ok) throw new Error("Failed to create record"); + return response.json(); + }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["/api/financial/records"] }); queryClient.invalidateQueries({ queryKey: ["/api/financial/summary"] });