fix: fix monitor list create page add monitor list not work problem
This commit is contained in:
parent
f749f720db
commit
42eb5779b2
@ -10,6 +10,7 @@ const { Text } = Typography;
|
|||||||
export interface MonitorStatusPageEditFormValues {
|
export interface MonitorStatusPageEditFormValues {
|
||||||
title: string;
|
title: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
|
monitorList: PrismaJson.MonitorStatusPageList;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MonitorStatusPageEditFormProps {
|
interface MonitorStatusPageEditFormProps {
|
||||||
|
@ -3,12 +3,10 @@ import { useNavigate } from 'react-router';
|
|||||||
import { useCurrentWorkspaceId } from '../../store/user';
|
import { useCurrentWorkspaceId } from '../../store/user';
|
||||||
import { trpc } from '../../api/trpc';
|
import { trpc } from '../../api/trpc';
|
||||||
import { useEvent } from '../../hooks/useEvent';
|
import { useEvent } from '../../hooks/useEvent';
|
||||||
import { MonitorStatusPageEditForm } from '../../components/monitor/StatusPage/EditForm';
|
import {
|
||||||
|
MonitorStatusPageEditForm,
|
||||||
interface Values {
|
MonitorStatusPageEditFormValues,
|
||||||
title: string;
|
} from '../../components/monitor/StatusPage/EditForm';
|
||||||
slug: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MonitorPageAdd: React.FC = React.memo(() => {
|
export const MonitorPageAdd: React.FC = React.memo(() => {
|
||||||
const workspaceId = useCurrentWorkspaceId()!;
|
const workspaceId = useCurrentWorkspaceId()!;
|
||||||
@ -17,17 +15,18 @@ export const MonitorPageAdd: React.FC = React.memo(() => {
|
|||||||
const createPageMutation = trpc.monitor.createPage.useMutation();
|
const createPageMutation = trpc.monitor.createPage.useMutation();
|
||||||
const trpcUtils = trpc.useContext();
|
const trpcUtils = trpc.useContext();
|
||||||
|
|
||||||
const handleFinish = useEvent(async (values: Values) => {
|
const handleFinish = useEvent(
|
||||||
|
async (values: MonitorStatusPageEditFormValues) => {
|
||||||
await createPageMutation.mutateAsync({
|
await createPageMutation.mutateAsync({
|
||||||
|
...values,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
title: values.title,
|
|
||||||
slug: values.slug,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
trpcUtils.monitor.getAllPages.refetch();
|
trpcUtils.monitor.getAllPages.refetch();
|
||||||
|
|
||||||
navigate('/monitor/pages');
|
navigate('/monitor/pages');
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-8 py-4">
|
<div className="px-8 py-4">
|
||||||
|
@ -500,10 +500,17 @@ export const monitorRouter = router({
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z
|
||||||
|
.object({
|
||||||
slug: z.string(),
|
slug: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
})
|
})
|
||||||
|
.merge(
|
||||||
|
MonitorStatusPageModelSchema.pick({
|
||||||
|
description: true,
|
||||||
|
monitorList: true,
|
||||||
|
}).partial()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.output(MonitorStatusPageModelSchema)
|
.output(MonitorStatusPageModelSchema)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user