import { useTranslation } from "react-i18next"; import { Form, type FormInstance, Input } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; import { type AccessConfigForAzure } from "@/domain/access"; type AccessFormAzureConfigFieldValues = Nullish; export type AccessFormAzureConfigProps = { form: FormInstance; formName: string; disabled?: boolean; initialValues?: AccessFormAzureConfigFieldValues; onValuesChange?: (values: AccessFormAzureConfigFieldValues) => void; }; const initFormModel = (): AccessFormAzureConfigFieldValues => { return { tenantId: "", clientId: "", clientSecret: "", }; }; const AccessFormAzureConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormAzureConfigProps) => { const { t } = useTranslation(); const formSchema = z.object({ tenantId: z .string() .min(1, t("access.form.azure_tenant_id.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })) .trim(), clientId: z .string() .min(1, t("access.form.azure_client_id.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })) .trim(), clientSecret: z .string() .min(1, t("access.form.azure_client_secret.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })) .trim(), cloudName: z.string().nullish(), }); const formRule = createSchemaFieldRule(formSchema); const handleFormChange = (_: unknown, values: z.infer) => { onValuesChange?.(values); }; return (
} > } > } > } >
); }; export default AccessFormAzureConfig;