import { MyBetaModalFormProps, renderTextHelper } from '@/common';
import {
  HouseCollectionTasksChannelEnum,
  HouseCollectionTasksStatusEnum,
} from '@/gen/Enums';
import { ProCard, ProDescriptions } from '@ant-design/pro-components';
import { Space, Tag } from 'antd';

export default function info(props: MyBetaModalFormProps) {
  const { item } = props;

  return (
    <Space direction="vertical" style={{ width: '100%' }}>
      <ProCard title="基本信息">
        <ProDescriptions bordered>
          <ProDescriptions.Item label="ID">{item?.id}</ProDescriptions.Item>
          <ProDescriptions.Item label="任务名称">
            {item?.task_name}
          </ProDescriptions.Item>

          <ProDescriptions.Item label="渠道">
            {!item?.channel || !Array.isArray(item?.channel) ? (
              '-'
            ) : (
              <Space>
                {item.channel.map((channelValue: string) => {
                  const channelInfo =
                    HouseCollectionTasksChannelEnum[
                      channelValue as keyof typeof HouseCollectionTasksChannelEnum
                    ];
                  return (
                    <Tag key={channelValue} color={channelInfo?.color}>
                      {channelInfo?.text || channelValue}
                    </Tag>
                  );
                })}
              </Space>
            )}
          </ProDescriptions.Item>
          <ProDescriptions.Item label="状态">
            <renderTextHelper.Tag
              Enums={HouseCollectionTasksStatusEnum}
              value={item?.status}
              key="status"
            />
          </ProDescriptions.Item>
          <ProDescriptions.Item label="房屋数">
            {item?.total_houses || '-'}
          </ProDescriptions.Item>
          <ProDescriptions.Item label="住户数">
            {item?.total_notified || '-'}
          </ProDescriptions.Item>
          <ProDescriptions.Item label="创建人">
            {item?.company_employee?.name || '-'}-
            {item?.company_employee?.phone || '-'}
          </ProDescriptions.Item>
          <ProDescriptions.Item label="创建时间">
            {item?.created_at || '-'}
          </ProDescriptions.Item>
          <ProDescriptions.Item label="完成时间">
            {item?.completed_time || '-'}
          </ProDescriptions.Item>
        </ProDescriptions>
      </ProCard>
    </Space>
  );
}
