summaryrefslogtreecommitdiff
path: root/src/containers
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers')
-rw-r--r--src/containers/Home.tsx6
-rw-r--r--src/containers/Page.tsx25
-rw-r--r--src/containers/Products.tsx14
3 files changed, 37 insertions, 8 deletions
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 = () => (
- <Paper>
+ <Page title="Главная">
<p>
Привет, мир!
<Button>Нажми меня</Button>
<Button variant="outlined">Отменить</Button>
</p>
- </Paper>
+ </Page>
);
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<Props> = ({ title, actions, children }) => (
+ <Paper>
+ <div className="mb-2 flex justify-between items-center">
+ <span className="text-2xl font-bold">{title}</span>
+ {actions?.map(action => (<Button size="sm" route={action.route}>{action.name}</Button>))}
+ </div>
+ {children}
+ </Paper>
+);
+
+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 (
- <Paper>
- <DataTable title="Товары" items={products} fields={fields} />
- </Paper>
+ <Page title="Товары" actions={actions}>
+ <ListTable items={products} fields={fields} />
+ </Page>
);
};