Merge pull request #3288 from bluewave-labs/settings-zod-schema

Settings zod schema
This commit is contained in:
Alexander Holliday authored and GitHub committed 2026-02-18 09:32:28 -08:00
commit dab465b8c5
14 files changed
+640 -562

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import { useMemo } from "react";
import { settingsSchema } from "@/Validation/settings";
import type { Settings } from "@/Types/Settings";
import type { SettingsFormData } from "@/Validation/settings";
interface UseSettingsFormOptions {
data?: Settings | null;
}
export const useSettingsForm = ({ data = null }: UseSettingsFormOptions = {}) => {
return useMemo(() => {
const defaults: SettingsFormData = {
systemEmailIgnoreTLS: data?.systemEmailIgnoreTLS || false,
systemEmailRequireTLS: data?.systemEmailRequireTLS || false,
systemEmailRejectUnauthorized: data?.systemEmailRejectUnauthorized || true,
systemEmailSecure: data?.systemEmailSecure || false,
systemEmailPool: data?.systemEmailPool || false,
showURL: data?.showURL || false,
systemEmailHost: data?.systemEmailHost || "",
systemEmailUser: data?.systemEmailUser || "",
systemEmailAddress: data?.systemEmailAddress || "",
systemEmailConnectionHost: data?.systemEmailConnectionHost || "localhost",
systemEmailTLSServername: data?.systemEmailTLSServername || "",
systemEmailPort: data?.systemEmailPort || "",
globalThresholds: {
cpu: data?.globalThresholds?.cpu || "",
memory: data?.globalThresholds?.memory || "",
disk: data?.globalThresholds?.disk || "",
temperature: data?.globalThresholds?.temperature || "",
},
checkTTL: data?.checkTTL || 30,
pagespeedApiKey: "",
systemEmailPassword: "",
};
return { schema: settingsSchema, defaults };
}, [data]);
};