{"size": 1338, "ext": "js", "max_stars_repo_path": "src/components/pages/table/ContractTable.js", "max_stars_repo_name": "GrupoLIA/AdminPanel", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/pages/table/ContractTable.js", "max_issues_repo_name": "GrupoLIA/AdminPanel", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/pages/table/ContractTable.js", "max_forks_repo_name": "GrupoLIA/AdminPanel", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.1142857143, "max_line_length": 69, "alphanum_fraction": 0.5246636771}
import { Table, Typography, DatePicker } from 'antd';
import moment from 'moment';

const { Text } = Typography;
const dateFormat = 'YYYY-MM-DD';

const columns = [
  {
    title: 'ID',
    dataIndex: '_id',
    responsive: ['md'],
    width: '1%',
  },
  {
    title: 'Employer',
    dataIndex: 'employer',
  },
  {
    title: 'Employee',
    dataIndex: 'employee',
  },
  {
    title: 'Trade',
    dataIndex: 'trade',
  },
  {
    title: 'Description',
    dataIndex: 'description',
  },
  {
    title: 'Creation date',
    dataIndex: 'createdAt',
    render: (date) => (
      <DatePicker defaultValue={moment(date, dateFormat)} disabled />
    ),
  },
  {
    title: 'Status',
    dataIndex: 'status',
    render: (text) => {
      switch (text) {
        case 'accepted':
          return <Text type="success">{text}</Text>;
        case 'pending':
          return <Text type="warning">{text}</Text>;
        case 'expired':
          return <Text type="danger">{text}</Text>;
        case 'finished':
          return <Text italic>{text}</Text>;
        default:
          return;
      }
    },
  },
];

const ContractTable = ({ data }) => (
  <>
    <Table
      className="clearfix"
      columns={columns}
      dataSource={data}
      style={{ clear: 'both' }}
      rowkey="id"
    />
  </>
);

export default ContractTable;
