diff options
author | eug-vs <eug-vs@keemail.me> | 2021-03-14 06:30:22 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-03-14 06:30:22 +0300 |
commit | 610584c3ce986cdea431180f545e023cee14d5d2 (patch) | |
tree | a4c1b2a3de7b4ccf7cef8a4bdf5d366cc62492b5 /src/containers/Products.tsx | |
parent | 790cb41dfe3283fea96789fbacc28a077c474e44 (diff) | |
download | commercel-ui-610584c3ce986cdea431180f545e023cee14d5d2.tar.gz |
feat: implement Product Add/Edit
Diffstat (limited to 'src/containers/Products.tsx')
-rw-r--r-- | src/containers/Products.tsx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/containers/Products.tsx b/src/containers/Products.tsx index 3542df1..0b6ea70 100644 --- a/src/containers/Products.tsx +++ b/src/containers/Products.tsx @@ -1,26 +1,32 @@ import React from 'react'; -import Page from '../containers/Page'; +import { useHistory } from 'react-router-dom'; +import Page from './Page'; import ListTable from '../components/ListTable'; import { useProducts } from '../hooks/useAPIClient'; const fields = [ - { key: '_id', label: 'ID' }, { key: 'name', label: 'Название' }, - { key: 'type', label: 'Тип' }, + { key: 'price', label: 'Цена' }, ]; const actions = [ - { name: 'Добавить', route: 'products/add' } + { name: 'Добавить', route: 'products/add' }, ]; -const Home: React.FC = () => { +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} /> + <ListTable items={products} fields={fields} handleRowClick={handleRowClick} /> </Page> ); }; -export default Home; +export default Products; |