import { useTranslation } from "react-i18next"; import { Form, type FormInstance, Input } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; import { type AccessConfigForWangsu } from "@/domain/access"; type AccessFormWangsuConfigFieldValues = Nullish; export type AccessFormWangsuConfigProps = { form: FormInstance; formName: string; disabled?: boolean; initialValues?: AccessFormWangsuConfigFieldValues; onValuesChange?: (values: AccessFormWangsuConfigFieldValues) => void; }; const initFormModel = (): AccessFormWangsuConfigFieldValues => { return { accessKeyId: "", accessKeySecret: "", apiKey: "", }; }; const AccessFormWangsuConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange: onValuesChange }: AccessFormWangsuConfigProps) => { const { t } = useTranslation(); const formSchema = z.object({ accessKeyId: z .string() .min(1, t("access.form.wangsu_access_key_id.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })) .trim(), accessKeySecret: z .string() .min(1, t("access.form.wangsu_access_key_secret.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })) .trim(), apiKey: z .string() .min(1, t("access.form.wangsu_api_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 AccessFormWangsuConfig;