fix: invalidate queries better
This commit is contained in:
@@ -47,7 +47,7 @@ export default function AddDashboard() {
|
|||||||
toast('Success', {
|
toast('Success', {
|
||||||
description: 'Dashboard created.',
|
description: 'Dashboard created.',
|
||||||
});
|
});
|
||||||
queryClient.invalidateQueries(trpc.dashboard.pathFilter());
|
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||||
popModal();
|
popModal();
|
||||||
},
|
},
|
||||||
onError: handleError,
|
onError: handleError,
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ export default function SaveReport({
|
|||||||
projectId,
|
projectId,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||||
|
|
||||||
const goToReport = () => {
|
const goToReport = () => {
|
||||||
router.navigate({
|
router.navigate({
|
||||||
@@ -157,6 +158,7 @@ function SelectDashboard({
|
|||||||
projectId: string;
|
projectId: string;
|
||||||
}) {
|
}) {
|
||||||
const trpc = useTRPC();
|
const trpc = useTRPC();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
const [isCreatingNew, setIsCreatingNew] = useState(false);
|
const [isCreatingNew, setIsCreatingNew] = useState(false);
|
||||||
const [newDashboardName, setNewDashboardName] = useState('');
|
const [newDashboardName, setNewDashboardName] = useState('');
|
||||||
|
|
||||||
@@ -177,6 +179,7 @@ function SelectDashboard({
|
|||||||
trpc.dashboard.create.mutationOptions({
|
trpc.dashboard.create.mutationOptions({
|
||||||
onError: handleError,
|
onError: handleError,
|
||||||
async onSuccess(res) {
|
async onSuccess(res) {
|
||||||
|
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||||
await dashboardQuery.refetch();
|
await dashboardQuery.refetch();
|
||||||
onChange(res.id);
|
onChange(res.id);
|
||||||
setIsCreatingNew(false);
|
setIsCreatingNew(false);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import FullPageLoadingState from '@/components/full-page-loading-state';
|
|||||||
import { PageContainer } from '@/components/page-container';
|
import { PageContainer } from '@/components/page-container';
|
||||||
import { PageHeader } from '@/components/page-header';
|
import { PageHeader } from '@/components/page-header';
|
||||||
import { handleErrorToastOptions, useTRPC } from '@/integrations/trpc/react';
|
import { handleErrorToastOptions, useTRPC } from '@/integrations/trpc/react';
|
||||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
import { Link, createFileRoute } from '@tanstack/react-router';
|
import { Link, createFileRoute } from '@tanstack/react-router';
|
||||||
|
|
||||||
export const Route = createFileRoute(
|
export const Route = createFileRoute(
|
||||||
@@ -58,6 +58,7 @@ export const Route = createFileRoute(
|
|||||||
function Component() {
|
function Component() {
|
||||||
const { projectId } = Route.useParams();
|
const { projectId } = Route.useParams();
|
||||||
const trpc = useTRPC();
|
const trpc = useTRPC();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
const query = useQuery(
|
const query = useQuery(
|
||||||
trpc.dashboard.list.queryOptions({
|
trpc.dashboard.list.queryOptions({
|
||||||
projectId,
|
projectId,
|
||||||
@@ -80,6 +81,7 @@ function Component() {
|
|||||||
})(error);
|
})(error);
|
||||||
},
|
},
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
|
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||||
query.refetch();
|
query.refetch();
|
||||||
toast('Success', {
|
toast('Success', {
|
||||||
description: 'Dashboard deleted.',
|
description: 'Dashboard deleted.',
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
} from '@/components/report/report-item';
|
} from '@/components/report/report-item';
|
||||||
import { handleErrorToastOptions, useTRPC } from '@/integrations/trpc/react';
|
import { handleErrorToastOptions, useTRPC } from '@/integrations/trpc/react';
|
||||||
import { pushModal, showConfirm } from '@/modals';
|
import { pushModal, showConfirm } from '@/modals';
|
||||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
import { createFileRoute, useRouter } from '@tanstack/react-router';
|
import { createFileRoute, useRouter } from '@tanstack/react-router';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
@@ -85,6 +85,7 @@ function Component() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { organizationId, dashboardId, projectId } = Route.useParams();
|
const { organizationId, dashboardId, projectId } = Route.useParams();
|
||||||
const trpc = useTRPC();
|
const trpc = useTRPC();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||||
|
|
||||||
const dashboardQuery = useQuery(
|
const dashboardQuery = useQuery(
|
||||||
@@ -105,6 +106,7 @@ function Component() {
|
|||||||
trpc.dashboard.delete.mutationOptions({
|
trpc.dashboard.delete.mutationOptions({
|
||||||
onError: handleErrorToastOptions({}),
|
onError: handleErrorToastOptions({}),
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
|
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||||
toast('Dashboard deleted');
|
toast('Dashboard deleted');
|
||||||
router.navigate({
|
router.navigate({
|
||||||
to: '/$organizationId/$projectId/dashboards',
|
to: '/$organizationId/$projectId/dashboards',
|
||||||
@@ -139,6 +141,7 @@ function Component() {
|
|||||||
trpc.report.delete.mutationOptions({
|
trpc.report.delete.mutationOptions({
|
||||||
onError: handleErrorToastOptions({}),
|
onError: handleErrorToastOptions({}),
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
|
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||||
reportsQuery.refetch();
|
reportsQuery.refetch();
|
||||||
toast('Report deleted');
|
toast('Report deleted');
|
||||||
},
|
},
|
||||||
@@ -149,6 +152,7 @@ function Component() {
|
|||||||
trpc.report.duplicate.mutationOptions({
|
trpc.report.duplicate.mutationOptions({
|
||||||
onError: handleErrorToastOptions({}),
|
onError: handleErrorToastOptions({}),
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
|
queryClient.invalidateQueries(trpc.dashboard.list.pathFilter());
|
||||||
reportsQuery.refetch();
|
reportsQuery.refetch();
|
||||||
toast('Report duplicated');
|
toast('Report duplicated');
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user