diff --git a/src/client/components/monitor/StatusPage/EditForm.tsx b/src/client/components/monitor/StatusPage/EditForm.tsx index 11b0708..98ea0e5 100644 --- a/src/client/components/monitor/StatusPage/EditForm.tsx +++ b/src/client/components/monitor/StatusPage/EditForm.tsx @@ -10,6 +10,7 @@ const { Text } = Typography; export interface MonitorStatusPageEditFormValues { title: string; slug: string; + monitorList: PrismaJson.MonitorStatusPageList; } interface MonitorStatusPageEditFormProps { diff --git a/src/client/pages/Monitor/PageAdd.tsx b/src/client/pages/Monitor/PageAdd.tsx index ad95bb9..a25ff42 100644 --- a/src/client/pages/Monitor/PageAdd.tsx +++ b/src/client/pages/Monitor/PageAdd.tsx @@ -3,12 +3,10 @@ import { useNavigate } from 'react-router'; import { useCurrentWorkspaceId } from '../../store/user'; import { trpc } from '../../api/trpc'; import { useEvent } from '../../hooks/useEvent'; -import { MonitorStatusPageEditForm } from '../../components/monitor/StatusPage/EditForm'; - -interface Values { - title: string; - slug: string; -} +import { + MonitorStatusPageEditForm, + MonitorStatusPageEditFormValues, +} from '../../components/monitor/StatusPage/EditForm'; export const MonitorPageAdd: React.FC = React.memo(() => { const workspaceId = useCurrentWorkspaceId()!; @@ -17,17 +15,18 @@ export const MonitorPageAdd: React.FC = React.memo(() => { const createPageMutation = trpc.monitor.createPage.useMutation(); const trpcUtils = trpc.useContext(); - const handleFinish = useEvent(async (values: Values) => { - await createPageMutation.mutateAsync({ - workspaceId, - title: values.title, - slug: values.slug, - }); + const handleFinish = useEvent( + async (values: MonitorStatusPageEditFormValues) => { + await createPageMutation.mutateAsync({ + ...values, + workspaceId, + }); - trpcUtils.monitor.getAllPages.refetch(); + trpcUtils.monitor.getAllPages.refetch(); - navigate('/monitor/pages'); - }); + navigate('/monitor/pages'); + } + ); return (
diff --git a/src/server/trpc/routers/monitor.ts b/src/server/trpc/routers/monitor.ts index 3bac342..ebf69b7 100644 --- a/src/server/trpc/routers/monitor.ts +++ b/src/server/trpc/routers/monitor.ts @@ -500,10 +500,17 @@ export const monitorRouter = router({ }) ) .input( - z.object({ - slug: z.string(), - title: z.string(), - }) + z + .object({ + slug: z.string(), + title: z.string(), + }) + .merge( + MonitorStatusPageModelSchema.pick({ + description: true, + monitorList: true, + }).partial() + ) ) .output(MonitorStatusPageModelSchema) .mutation(async ({ input }) => {