diff --git a/src/client/components/monitor/MonitorInfo.tsx b/src/client/components/monitor/MonitorInfo.tsx index b73027e..1b31bdb 100644 --- a/src/client/components/monitor/MonitorInfo.tsx +++ b/src/client/components/monitor/MonitorInfo.tsx @@ -206,7 +206,7 @@ export const MonitorInfo: React.FC = React.memo((props) => { )} diff --git a/src/client/pages/Monitor/PageList.tsx b/src/client/pages/Monitor/PageList.tsx index 2f820bd..256e5d0 100644 --- a/src/client/pages/Monitor/PageList.tsx +++ b/src/client/pages/Monitor/PageList.tsx @@ -2,15 +2,26 @@ import React from 'react'; import { useNavigate } from 'react-router'; import { useCurrentWorkspaceId } from '../../store/user'; import { trpc } from '../../api/trpc'; -import { Button, Card } from 'antd'; -import { EditOutlined, EyeOutlined } from '@ant-design/icons'; +import { Button, Card, Popconfirm } from 'antd'; +import { DeleteOutlined, EditOutlined, EyeOutlined } from '@ant-design/icons'; +import { useEvent } from '../../hooks/useEvent'; export const MonitorPageList: React.FC = React.memo(() => { - const workspaceId = useCurrentWorkspaceId()!; - const { data: pages = [] } = trpc.monitor.getAllPages.useQuery({ + const workspaceId = useCurrentWorkspaceId(); + const navigate = useNavigate(); + const { data: pages = [], refetch } = trpc.monitor.getAllPages.useQuery({ workspaceId, }); - const navigate = useNavigate(); + const deletePageMutation = trpc.monitor.deletePage.useMutation(); + + const handleDeletePage = useEvent(async (monitorId: string) => { + await deletePageMutation.mutateAsync({ + workspaceId, + id: monitorId, + }); + + refetch(); + }); return (
@@ -24,14 +35,26 @@ export const MonitorPageList: React.FC = React.memo(() => {
{p.title}
-
diff --git a/src/server/trpc/routers/monitor.ts b/src/server/trpc/routers/monitor.ts index d5babac..f9ffa1e 100644 --- a/src/server/trpc/routers/monitor.ts +++ b/src/server/trpc/routers/monitor.ts @@ -651,6 +651,31 @@ export const monitorRouter = router({ }, }); }), + deletePage: workspaceOwnerProcedure + .meta( + buildMonitorOpenapi({ + method: 'DELETE', + path: '/deleteStatusPage', + }) + ) + .input( + MonitorStatusPageModelSchema.pick({ + id: true, + }) + ) + .output(MonitorStatusPageModelSchema) + .mutation(async ({ input }) => { + const { id, workspaceId } = input; + + const res = await prisma.monitorStatusPage.delete({ + where: { + id, + workspaceId, + }, + }); + + return res; + }), }); function buildMonitorOpenapi(meta: OpenApiMetaInfo): OpenApiMeta {