Files
Checkmate/client/src/hooks/forms/UseInitNotificationsChannelForm.tsx
T

21 lines
617 B
TypeScript
Raw Normal View History

2025-11-13 13:47:26 -08:00
import { notificationChannelSchema } from "@/validation/zod";
import { useMemo } from "react";
import { z } from "zod";
export const useInitForm = ({
initialData,
}: {
initialData: Partial<z.infer<typeof notificationChannelSchema>> | undefined;
}) => {
return useMemo(() => {
const defaults: z.infer<typeof notificationChannelSchema> = {
name: initialData?.name || "",
type: initialData?.type || "email",
config: {
url: initialData?.config?.url || "",
emailAddress: initialData?.config?.emailAddress || "",
},
};
return { defaults };
}, [initialData]);
};