import {
  Datagrid,
  List,
  NumberField,
  SelectArrayInput,
  SelectField,
  TextField,
  TextInput,
} from "react-admin";
import { ResourceListActions } from "../shared/ListActions";
import { categoryPartChoices } from "../shared/enums";
const partFilters = [
  <TextInput key="q" source="q" label="Search" alwaysOn />,
  <SelectArrayInput
    key="categories"
    source="categories"
    label="Category"
    choices={categoryPartChoices}
  />,
  <TextInput key="serialNumber" source="serialNumber" label="Serial number" />,
];
export const PartList = () => (
  <List
    filters={partFilters}
    actions={<ResourceListActions filters={partFilters} />}
  >
    <Datagrid rowClick="show">
      <TextField source="name" />
      <SelectField source="categories" choices={categoryPartChoices} />
      <NumberField source="price" />
      <TextField source="serialNumber" />
    </Datagrid>
  </List>
);
