import type { VbenFormProps } from "@vben/common-ui";

export const ModelCertificateFrom: VbenFormProps = {
  schema: [
    {
      fieldName: 'certificateType',
      label: '凭证类型',
      component: "Select",
      rules: "required",
      defaultValue: 'apiKey',
      componentProps: {
        options: [
          { label: 'API密钥', value: 'apiKey' },
          { label: '其他', value: 'other' },
        ],
      },
    },
    {
      fieldName: "modelProvider",
      label: "模型提供商",
      component: "Select",
      rules: "required",
      componentProps: {
        options: [
          { label: '提供商A', value: 'providerA' },
          { label: '提供商B', value: 'providerB' },
        ],
      },
      dependencies: {
        triggerFields: ["certificateType"],
        show: (values) => values.certificateType === 'apiKey',
      }
    },
    {
      fieldName: "apiKey",
      label: "API密钥",
      component: "Input",
      rules: "required",
      dependencies: {
        triggerFields: ["certificateType"],
        show: (values) => values.certificateType === 'apiKey',
      },
    },
    {
      fieldName: "baseUrl",
      label: "API基础URL",
      component: "Input",
      dependencies: {
        triggerFields: ["certificateType"],
        rules: (values) => {
          if (values.certificateType === 'other') {
            return "required"
          }
          return null;
        },
      },
    }
  ]
};
