import React from 'react';
import Page from '../containers/Page';
import ListTable from '../components/ListTable';
import { useProducts } from '../hooks/useAPIClient';

const fields = [
  { key: '_id', label: 'ID' },
  { key: 'name', label: 'Название' },
  { key: 'type', label: 'Тип' },
];

const actions = [
  { name: 'Добавить', route: 'products/add' }
];

const Home: React.FC = () => {
  const { data: products } = useProducts();

  return (
    <Page title="Товары" actions={actions}>
      <ListTable items={products} fields={fields} />
    </Page>
  );
};

export default Home;
