From e1fc8ea5904de90f94d3f63287555c75067846ac Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 14 Mar 2021 03:03:12 +0300 Subject: feat: add Page component --- src/containers/Home.tsx | 6 +++--- src/containers/Page.tsx | 25 +++++++++++++++++++++++++ src/containers/Products.tsx | 14 +++++++++----- 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 src/containers/Page.tsx (limited to 'src/containers') diff --git a/src/containers/Home.tsx b/src/containers/Home.tsx index 7f62186..f39861a 100644 --- a/src/containers/Home.tsx +++ b/src/containers/Home.tsx @@ -1,15 +1,15 @@ import React from 'react'; -import Paper from '../components/Paper'; +import Page from '../containers/Page'; import Button from '../components/Button'; const Home: React.FC = () => ( - +

Привет, мир!

-
+ ); export default Home; diff --git a/src/containers/Page.tsx b/src/containers/Page.tsx new file mode 100644 index 0000000..0c8269e --- /dev/null +++ b/src/containers/Page.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import Paper from '../components/Paper'; +import Button from '../components/Button'; + +interface Action { + name: string; + route: string; +} + +interface Props { + title: string; + actions?: Action[]; +} + +const Page: React.FC = ({ title, actions, children }) => ( + +
+ {title} + {actions?.map(action => ())} +
+ {children} +
+); + +export default Page; diff --git a/src/containers/Products.tsx b/src/containers/Products.tsx index 8cd301a..3542df1 100644 --- a/src/containers/Products.tsx +++ b/src/containers/Products.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import Paper from '../components/Paper'; -import DataTable from '../components/DataTable'; +import Page from '../containers/Page'; +import ListTable from '../components/ListTable'; import { useProducts } from '../hooks/useAPIClient'; const fields = [ @@ -9,13 +9,17 @@ const fields = [ { key: 'type', label: 'Тип' }, ]; +const actions = [ + { name: 'Добавить', route: 'products/add' } +]; + const Home: React.FC = () => { const { data: products } = useProducts(); return ( - - - + + + ); }; -- cgit v1.2.3