import { useTranslation } from "react-i18next"; import { Form, type FormInstance, Input } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; import { type AccessConfigForUCloud } from "@/domain/access"; type AccessFormUCloudConfigFieldValues = Nullish; export type AccessFormUCloudConfigProps = { form: FormInstance; formName: string; disabled?: boolean; initialValues?: AccessFormUCloudConfigFieldValues; onValuesChange?: (values: AccessFormUCloudConfigFieldValues) => void; }; const initFormModel = (): AccessFormUCloudConfigFieldValues => { return { privateKey: "", publicKey: "", }; }; const AccessFormUCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormUCloudConfigProps) => { const { t } = useTranslation(); const formSchema = z.object({ privateKey: z .string() .trim() .min(1, t("access.form.ucloud_private_key.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })), publicKey: z .string() .min(1, t("access.form.ucloud_public_key.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })) .trim(), projectId: z .string() .max(64, t("common.errmsg.string_max", { max: 64 })) .trim() .nullish(), }); const formRule = createSchemaFieldRule(formSchema); const handleFormChange = (_: unknown, values: z.infer) => { onValuesChange?.(values); }; return (
} > } > } >
); }; export default AccessFormUCloudConfig;