fix: fix monitor list create page add monitor list not work problem

This commit is contained in:
moonrailgun 2023-12-23 23:25:53 +08:00
parent f749f720db
commit 42eb5779b2
3 changed files with 26 additions and 19 deletions

View File

@ -10,6 +10,7 @@ const { Text } = Typography;
export interface MonitorStatusPageEditFormValues {
title: string;
slug: string;
monitorList: PrismaJson.MonitorStatusPageList;
}
interface MonitorStatusPageEditFormProps {

View File

@ -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) => {
const handleFinish = useEvent(
async (values: MonitorStatusPageEditFormValues) => {
await createPageMutation.mutateAsync({
...values,
workspaceId,
title: values.title,
slug: values.slug,
});
trpcUtils.monitor.getAllPages.refetch();
navigate('/monitor/pages');
});
}
);
return (
<div className="px-8 py-4">

View File

@ -500,10 +500,17 @@ export const monitorRouter = router({
})
)
.input(
z.object({
z
.object({
slug: z.string(),
title: z.string(),
})
.merge(
MonitorStatusPageModelSchema.pick({
description: true,
monitorList: true,
}).partial()
)
)
.output(MonitorStatusPageModelSchema)
.mutation(async ({ input }) => {