import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';

import { maskIdCard, maskMobile, getRealNameStatusName } from '#/utils/agent';

export function useRealNameColumns(): VxeTableGridOptions['columns'] {
  return [
    {
      field: 'id',
      title: 'ID',
      width: 80,
    },
    {
      field: 'agent_id',
      title: '代理ID',
      width: 100,
    },
    {
      field: 'name',
      title: '姓名',
      width: 120,
    },
    {
      field: 'id_card',
      title: '身份证号',
      width: 180,
      formatter: ({ cellValue }: { cellValue: string }) => {
        return maskIdCard(cellValue);
      },
    },
    {
      field: 'mobile',
      title: '手机号',
      width: 140,
      formatter: ({ cellValue }: { cellValue: string }) => {
        return maskMobile(cellValue);
      },
    },
    {
      field: 'status',
      title: '状态',
      width: 100,
      cellRender: {
        name: 'CellTag',
        options: [
          { value: 1, color: 'warning', label: '未验证' },
          { value: 2, color: 'success', label: '已通过' },
        ],
      },
    },
    {
      field: 'verify_time',
      title: '验证时间',
      width: 160,
    },
    {
      field: 'create_time',
      title: '创建时间',
      width: 160,
      sortable: true,
    },
  ] as const;
}

export function useRealNameFormSchema(): VbenFormSchema[] {
  return [
    {
      component: 'InputNumber',
      fieldName: 'agent_id',
      label: '代理ID',
    },
    {
      component: 'Select',
      fieldName: 'status',
      label: '状态',
      componentProps: {
        allowClear: true,
        options: [
          { label: '未验证', value: 1 },
          { label: '已通过', value: 2 },
        ],
      },
    },
  ];
}

