import { MyColumns, MyPageContainer, MyProTableProps } from '@/common';
import { Apis } from '@/gen/Apis';
import {
  HouseRegistersCustomerTypeEnum,
  HouseRegistersHouseStatusEnum,
  HouseRegistersStatusEnum,
  HouseRegistersTypeEnum,
  HouseRegistersUsagePlanEnum,
} from '@/gen/Enums';
import { ProTable } from '@ant-design/pro-components';
import { Space } from 'antd';
import Audit from './modals/Audit';

export default function Index({ title = '房屋登记审核' }) {
  return (
    <MyPageContainer title={title}>
      <ProTable
        {...MyProTableProps.props}
        request={async (params, sort) =>
          MyProTableProps.request(
            { status: 'Pending', ...params },
            sort,
            Apis.Archive.HouseRegisters.List,
          )
        }
        columns={[
          MyColumns.ID(),
          {
            title: '房屋',
            dataIndex: ['asset_house', 'full_name'],
          },
          MyColumns.EnumTag({
            title: '类型',
            dataIndex: 'type',
            valueEnum: HouseRegistersTypeEnum,
          }),
          MyColumns.EnumTag({
            title: '状态',
            dataIndex: 'status',
            valueEnum: HouseRegistersStatusEnum,
          }),
          MyColumns.EnumTag({
            title: '房屋状态',
            dataIndex: 'house_status',
            valueEnum: HouseRegistersHouseStatusEnum,
            search: false,
          }),
          MyColumns.EnumTag({
            title: '使用计划',
            dataIndex: 'usage_plan',
            valueEnum: HouseRegistersUsagePlanEnum,
            search: false,
          }),
          MyColumns.EnumTag({
            title: '客户类型',
            dataIndex: 'customer_type',
            valueEnum: HouseRegistersCustomerTypeEnum,
            search: false,
          }),
          MyColumns.CreatedAt(),
          MyColumns.Option({
            render: (_, item: any, index, action) => (
              <Space key={index}>
                <Audit item={item} reload={action?.reload} title={title} />
              </Space>
            ),
          }),
        ]}
      />
    </MyPageContainer>
  );
}
