blob: 0b6ea7017bb4c21969f3557f88e1a06681269147 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import React from 'react';
import { useHistory } from 'react-router-dom';
import Page from './Page';
import ListTable from '../components/ListTable';
import { useProducts } from '../hooks/useAPIClient';
const fields = [
{ key: 'name', label: 'Название' },
{ key: 'price', label: 'Цена' },
];
const actions = [
{ name: 'Добавить', route: 'products/add' },
];
const Products: React.FC = () => {
const history = useHistory();
const { data: products } = useProducts();
const handleRowClick = (index: number) => {
const product = products && products[index];
history.push(`/products/edit/${product?._id}`);
};
return (
<Page title="Товары" actions={actions}>
<ListTable items={products} fields={fields} handleRowClick={handleRowClick} />
</Page>
);
};
export default Products;
|