import { useTranslation } from "react-i18next"; import { AutoComplete, 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 })), clientId: z .string() .min(1, t("access.form.azure_client_id.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })), clientSecret: z .string() .min(1, t("access.form.azure_client_secret.placeholder")) .max(64, t("common.errmsg.string_max", { max: 64 })), cloudName: z.string().nullish(), }); const formRule = createSchemaFieldRule(formSchema); const handleFormChange = (_: unknown, values: z.infer) => { onValuesChange?.(values); }; return (
} > } > } > } > ({ value }))} placeholder={t("access.form.azure_cloud_name.placeholder")} filterOption={(inputValue, option) => option!.value.toLowerCase().includes(inputValue.toLowerCase())} />
); }; export default AccessFormAzureConfig;