import { List, DataTable, TextField, DateField, EditButton, ShowButton } from 'react-admin';
import { SelectField } from 'react-admin';

const equipmentStatusChoices = [
  { id: 'Active', name: 'В эксплуатации' },
  { id: 'Repair', name: 'В ремонте' },
  { id: 'Reserve', name: 'В резерве' },
  { id: 'WriteOff', name: 'Списано' },
];

export const EquipmentList = () => (
  <List>
    <DataTable>
      <DataTable.Col source="id" />
      <DataTable.Col source="name" />
      <DataTable.Col source="serialNumber" />
      <DataTable.Col source="dateOfInspection" field={DateField} />
      <DataTable.Col source="commissionedAt" field={DateField} />
      <DataTable.Col source="status" field={(props) => <SelectField {...props} choices={equipmentStatusChoices} />} />
      <DataTable.Col source="createdAt" field={DateField} />
      <DataTable.Col source="updatedAt" field={DateField} />
      <DataTable.Col>
        <EditButton />
        <ShowButton />
      </DataTable.Col>
    </DataTable>
  </List>
);