fix: fix website list not refresh when delete website problem
This commit is contained in:
parent
cc581f9c22
commit
fcb30a375b
@ -38,6 +38,7 @@ It's good to specialize in one thing, if we are experts in related abilities we
|
|||||||
- [ ] survey
|
- [ ] survey
|
||||||
- [ ] lighthouse report
|
- [ ] lighthouse report
|
||||||
- [ ] hooks
|
- [ ] hooks
|
||||||
|
- [ ] links
|
||||||
|
|
||||||
## Preview
|
## Preview
|
||||||
|
|
||||||
|
@ -10,10 +10,8 @@ import { MonitorPicker } from '../monitor/MonitorPicker';
|
|||||||
import {
|
import {
|
||||||
defaultErrorHandler,
|
defaultErrorHandler,
|
||||||
defaultSuccessHandler,
|
defaultSuccessHandler,
|
||||||
getQueryKey,
|
|
||||||
trpc,
|
trpc,
|
||||||
} from '../../api/trpc';
|
} from '../../api/trpc';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
|
||||||
import { useEvent } from '../../hooks/useEvent';
|
import { useEvent } from '../../hooks/useEvent';
|
||||||
import { hostnameValidator } from '../../utils/validator';
|
import { hostnameValidator } from '../../utils/validator';
|
||||||
import { useTranslation } from '@i18next-toolkit/react';
|
import { useTranslation } from '@i18next-toolkit/react';
|
||||||
@ -25,7 +23,7 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo(
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const workspaceId = useCurrentWorkspaceId();
|
const workspaceId = useCurrentWorkspaceId();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const queryClient = useQueryClient();
|
const trpcUtils = trpc.useUtils();
|
||||||
|
|
||||||
const { data: website, isLoading } = trpc.website.info.useQuery({
|
const { data: website, isLoading } = trpc.website.info.useQuery({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
@ -33,10 +31,7 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo(
|
|||||||
});
|
});
|
||||||
|
|
||||||
const updateMutation = trpc.website.updateInfo.useMutation({
|
const updateMutation = trpc.website.updateInfo.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: defaultSuccessHandler,
|
||||||
queryClient.resetQueries(getQueryKey(trpc.website.info));
|
|
||||||
defaultSuccessHandler();
|
|
||||||
},
|
|
||||||
onError: defaultErrorHandler,
|
onError: defaultErrorHandler,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,6 +44,11 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo(
|
|||||||
domain: values.domain,
|
domain: values.domain,
|
||||||
monitorId: values.monitorId,
|
monitorId: values.monitorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
trpcUtils.website.info.refetch({
|
||||||
|
workspaceId,
|
||||||
|
websiteId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -57,6 +57,8 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo(
|
|||||||
|
|
||||||
message.success(t('Delete Success'));
|
message.success(t('Delete Success'));
|
||||||
|
|
||||||
|
await trpcUtils.website.all.refetch({ workspaceId });
|
||||||
|
|
||||||
navigate({
|
navigate({
|
||||||
to: '/website',
|
to: '/website',
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { createRootRouteWithContext, Outlet } from '@tanstack/react-router';
|
import { createRootRouteWithContext, Outlet } from '@tanstack/react-router';
|
||||||
import { TanStackRouterDevtools } from '@tanstack/router-devtools';
|
// import { TanStackRouterDevtools } from '@tanstack/router-devtools';
|
||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
interface RouterContext {
|
interface RouterContext {
|
||||||
@ -13,7 +13,8 @@ export const Route = createRootRouteWithContext<RouterContext>()({
|
|||||||
// https://github.com/TanStack/router/issues/857
|
// https://github.com/TanStack/router/issues/857
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
<TanStackRouterDevtools position="bottom-right" />
|
|
||||||
|
{/* <TanStackRouterDevtools position="bottom-right" /> */}
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user