diff --git a/src/client/api/model/website.ts b/src/client/api/model/website.ts index cc154cd..ef17b95 100644 --- a/src/client/api/model/website.ts +++ b/src/client/api/model/website.ts @@ -4,15 +4,6 @@ import { AppRouterOutput } from '../trpc'; export type WebsiteInfo = NonNullable; -export async function deleteWorkspaceWebsite( - workspaceId: string, - websiteId: string -) { - await request.delete(`/api/workspace/${workspaceId}/website/${websiteId}`); - - queryClient.resetQueries(['websites', workspaceId]); -} - export function refreshWorkspaceWebsites(workspaceId: string) { queryClient.refetchQueries(['websites', workspaceId]); } diff --git a/src/client/components/CommonList.tsx b/src/client/components/CommonList.tsx index 4bdcd17..a9f4457 100644 --- a/src/client/components/CommonList.tsx +++ b/src/client/components/CommonList.tsx @@ -100,7 +100,9 @@ export const CommonList: React.FC = React.memo((props) => { }} >
-
{item.title}
+
+ {item.title} +
{item.number && item.number > 0 && ( diff --git a/src/client/components/website/WebsiteConfig.tsx b/src/client/components/website/WebsiteConfig.tsx index e611b14..c3eefcb 100644 --- a/src/client/components/website/WebsiteConfig.tsx +++ b/src/client/components/website/WebsiteConfig.tsx @@ -1,6 +1,5 @@ import { Form, Input, message } from 'antd'; import React from 'react'; -import { deleteWorkspaceWebsite } from '../../api/model/website'; import { useRequest } from '../../hooks/useRequest'; import { useCurrentWorkspaceId } from '../../store/user'; import { ErrorTip } from '../ErrorTip'; @@ -38,6 +37,9 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo( onSuccess: defaultSuccessHandler, onError: defaultErrorHandler, }); + const deleteMutation = trpc.website.delete.useMutation({ + onError: defaultErrorHandler, + }); const handleSave = useEvent( async (values: { name: string; domain: string; monitorId: string }) => { @@ -65,7 +67,7 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo( ); const [, handleDeleteWebsite] = useRequest(async () => { - await deleteWorkspaceWebsite(workspaceId, websiteId!); + await deleteMutation.mutateAsync({ workspaceId, websiteId }); message.success(t('Delete Success')); @@ -157,7 +159,7 @@ export const WebsiteConfig: React.FC<{ websiteId: string }> = React.memo(
handleDeleteWebsite()} >