Files
Checkmate/client/src/Hooks/useStatusPageForm.ts
T

27 lines
951 B
TypeScript
Raw Normal View History

2026-02-02 23:46:15 +00:00
import { useMemo } from "react";
import { statusPageSchema, type StatusPageFormData } from "@/Validation/statusPage";
import type { StatusPage } from "@/Types/StatusPage";
interface UseStatusPageFormOptions {
data?: StatusPage | null;
}
export const useStatusPageForm = ({ data = null }: UseStatusPageFormOptions = {}) => {
return useMemo(() => {
const defaults: StatusPageFormData = {
companyName: data?.companyName || "",
url: data?.url || "",
timezone: data?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,
color: data?.color || "#4169E1",
monitors: data?.monitors || [],
isPublished: data?.isPublished ?? false,
showCharts: data?.showCharts ?? true,
showUptimePercentage: data?.showUptimePercentage ?? true,
showAdminLoginLink: data?.showAdminLoginLink ?? false,
customCSS: data?.customCSS || "",
logo: data?.logo || null,
};
return { schema: statusPageSchema, defaults };
}, [data]);
};