import { useTranslation } from "react-i18next"; import { Form, type FormInstance, Input } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; import { type AccessConfigForZeroSSL } from "@/domain/access"; type AccessFormZeroSSLConfigFieldValues = Nullish; export type AccessFormZeroSSLConfigProps = { form: FormInstance; formName: string; disabled?: boolean; initialValues?: AccessFormZeroSSLConfigFieldValues; onValuesChange?: (values: AccessFormZeroSSLConfigFieldValues) => void; }; const initFormModel = (): AccessFormZeroSSLConfigFieldValues => { return { eabKid: "", eabHmacKey: "", }; }; const AccessFormZeroSSLConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormZeroSSLConfigProps) => { const { t } = useTranslation(); const formSchema = z.object({ eabKid: z .string() .min(1, t("access.form.zerossl_eab_kid.placeholder")) .max(256, t("common.errmsg.string_max", { max: 256 })) .trim(), eabHmacKey: z .string() .min(1, t("access.form.zerossl_eab_hmac_key.placeholder")) .max(256, t("common.errmsg.string_max", { max: 256 })) .trim(), }); const formRule = createSchemaFieldRule(formSchema); const handleFormChange = (_: unknown, values: z.infer) => { onValuesChange?.(values); }; return (
} > } >
); }; export default AccessFormZeroSSLConfig;