From 74754cf65b4d1b49101e2d60b18740dd0e40cff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Mon, 3 Nov 2025 22:07:12 +0100 Subject: [PATCH] fix: invalidate dashboard after new report is created --- apps/start/src/modals/save-report.tsx | 38 +++++---------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/apps/start/src/modals/save-report.tsx b/apps/start/src/modals/save-report.tsx index b8c1fa04..d99aec2d 100644 --- a/apps/start/src/modals/save-report.tsx +++ b/apps/start/src/modals/save-report.tsx @@ -1,15 +1,7 @@ import { ButtonContainer } from '@/components/button-container'; import { InputWithLabel } from '@/components/forms/input-with-label'; import { Button } from '@/components/ui/button'; -import { Combobox } from '@/components/ui/combobox'; import { Label } from '@/components/ui/label'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/components/ui/select'; import { useAppParams } from '@/hooks/use-app-params'; import { handleError } from '@/integrations/trpc/react'; import { zodResolver } from '@hookform/resolvers/zod'; @@ -58,6 +50,13 @@ export default function SaveReport({ trpc.report.create.mutationOptions({ onError: handleError, onSuccess(res) { + queryClient.invalidateQueries( + trpc.report.list.queryFilter({ + dashboardId: res.dashboardId, + projectId, + }), + ); + const goToReport = () => { router.navigate({ to: '/$organizationId/$projectId/reports/$reportId', @@ -86,24 +85,6 @@ export default function SaveReport({ }, }), ); - const dashboardMutation = useMutation( - trpc.dashboard.create.mutationOptions({ - onError: handleError, - onSuccess(res) { - setValue('dashboardId', res.id); - dashboardQuery.refetch(); - queryClient.invalidateQueries(trpc.report.list.pathFilter()); - toast('Success', { - description: 'Dashboard created.', - }); - }, - }), - ); - const dashboardQuery = useQuery( - trpc.dashboard.list.queryOptions({ - projectId: projectId!, - }), - ); const { register, handleSubmit, formState, control, setValue } = useForm({ @@ -114,11 +95,6 @@ export default function SaveReport({ }, }); - const dashboards = (dashboardQuery.data ?? []).map((item) => ({ - value: item.id, - label: item.name, - })); - return (