import { MyBetaModalFormProps, MyColumns, MyProTableProps } from '@/common';
import { Apis } from '@/gen/Apis';
import {
  BillPaymentsTypeEnum,
  BillsStatusEnum,
  ContractBillsCostTypeEnum,
  HouseOrdersPaymentMethodEnum,
} from '@/gen/Enums';
import { ProTable } from '@ant-design/pro-components';

export default function Index(props: MyBetaModalFormProps) {
  return (
    <ProTable
      {...MyProTableProps.props}
      headerTitle="装修押金"
      request={async (params, sort) =>
        MyProTableProps.request(
          {
            ...params,
            id: props?.item?.id,
          },
          sort,
          Apis.Renovation.RenovationApplies.Bills,
        )
      }
      columns={[
        MyColumns.ID({
          search: false,
        }),
        {
          title: '付款人',
          dataIndex: 'payer',
        },
        {
          title: '付款人电话',
          dataIndex: 'phone',
        },
        MyColumns.EnumTag({
          title: '状态',
          dataIndex: 'status',
          valueEnum: BillsStatusEnum,
        }),
        MyColumns.EnumTag({
          title: '支付方式',
          dataIndex: 'payment_method',
          valueEnum: HouseOrdersPaymentMethodEnum,
        }),
        MyColumns.EnumTag({
          title: '费用项目',
          dataIndex: 'type',
          valueEnum: BillPaymentsTypeEnum,
          search: false,
        }),
        MyColumns.EnumTag({
          title: '费用类型',
          dataIndex: 'flow_type',
          valueEnum: ContractBillsCostTypeEnum,
          search: false,
        }),
        {
          title: '支付金额',
          dataIndex: 'amount',
          render: (_, item) => `${item?.amount}元`,
          search: false,
        },
        {
          title: '支付时间',
          dataIndex: 'paid_time',
          search: false,
        },
        {
          title: '退款金额',
          render: (_, item) => `${item?.refund_amount}元`,
          search: false,
        },
        {
          title: '退款时间',
          dataIndex: 'refund_time',
          search: false,
        },
        MyColumns.UpdatedAt(),
      ]}
    />
  );
}
