Skip to content

Commit 8a2de9f

Browse files
updated
1 parent 0ed627d commit 8a2de9f

File tree

11 files changed

+174
-26
lines changed

11 files changed

+174
-26
lines changed

chapter-6/src/services/saleService.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import api, { EndPoints } from '../api/axios';
2-
import { SaleType } from '../models/sale-type';
1+
import api, { EndPoints } from 'api/axios';
2+
import { SaleType } from 'models/sale-type';
33

44
export async function getSalesAxios() {
55
return await api.get<SaleType[]>(EndPoints.sales);

chapter-7/src/app/layouts/dashboard-layout/dashboard-sidebar-navigation.tsx

+50-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { Link } from 'react-router-dom';
33
import { createStyles, makeStyles } from '@material-ui/core/styles';
44
import Drawer from '@material-ui/core/Drawer';
@@ -7,19 +7,31 @@ import ListItem from '@material-ui/core/ListItem';
77
import ListItemIcon from '@material-ui/core/ListItemIcon';
88
import ListItemText from '@material-ui/core/ListItemText';
99
import SettingsIcon from '@material-ui/icons/Settings';
10-
import ExitToAppIcon from '@material-ui/icons/ExitToApp';
1110
import Toolbar from '@material-ui/core/Toolbar';
1211
import { useRouteMatch } from 'react-router';
13-
import { Divider, ListSubheader } from '@material-ui/core';
12+
import { Collapse, Divider, ListSubheader } from '@material-ui/core';
1413

15-
import { PieChart as PieChartIcon } from 'react-feather';
14+
import {
15+
PieChart as PieChartIcon,
16+
ShoppingCart as ShoppingCartIcon,
17+
ChevronUp as ChevronUpIcon,
18+
ChevronDown as ChevronDownIcon,
19+
List as ListIcon,
20+
FilePlus as FilePlusIcon,
21+
LogOut as LogOutIcon,
22+
} from 'react-feather';
1623

1724
const DashboardSidebarNavigation = () => {
1825
const classes = useStyles();
1926
const { url } = useRouteMatch();
27+
const [open, setOpen] = useState(false);
2028

2129
useEffect(() => {}, []);
2230

31+
const handleClick = () => {
32+
setOpen(!open);
33+
};
34+
2335
return (
2436
<>
2537
<div className={classes.root}>
@@ -51,18 +63,40 @@ const DashboardSidebarNavigation = () => {
5163
<ListItemText primary={'Dashboard'} />
5264
</ListItem>
5365
</Link>
54-
<Link className={classes.link} to={`${url}/settings-and-privacy`}>
55-
<ListItem button>
56-
<ListItemIcon>
57-
<SettingsIcon />
58-
</ListItemIcon>
59-
<ListItemText primary={'settings and privacy'} />
60-
</ListItem>
61-
</Link>
66+
67+
<ListSubheader>Management</ListSubheader>
68+
<ListItem button onClick={handleClick}>
69+
<ListItemIcon>
70+
<ShoppingCartIcon />
71+
</ListItemIcon>
72+
<ListItemText primary="Products" />
73+
{open ? <ChevronUpIcon /> : <ChevronDownIcon />}
74+
</ListItem>
75+
<Collapse in={open} timeout="auto" unmountOnExit>
76+
<List component="div" disablePadding>
77+
<Link className={classes.link} to={`${url}/list-products`}>
78+
<ListItem button className={classes.nested}>
79+
<ListItemIcon>
80+
<ListIcon />
81+
</ListItemIcon>
82+
<ListItemText primary="List Products" />
83+
</ListItem>
84+
</Link>
85+
<Link className={classes.link} to={`${url}/create-product`}>
86+
<ListItem button className={classes.nested}>
87+
<ListItemIcon>
88+
<FilePlusIcon />
89+
</ListItemIcon>
90+
<ListItemText primary="Create Product" />
91+
</ListItem>
92+
</Link>
93+
</List>
94+
</Collapse>
95+
6296
<a className={classes.link} href={'/'}>
6397
<ListItem button>
6498
<ListItemIcon>
65-
<ExitToAppIcon />
99+
<LogOutIcon />
66100
</ListItemIcon>
67101
<ListItemText primary={'logout'} />
68102
</ListItem>
@@ -106,5 +140,8 @@ const useStyles = makeStyles(theme =>
106140
textDecoration: 'none',
107141
color: 'inherit',
108142
},
143+
nested: {
144+
paddingLeft: theme.spacing(4),
145+
},
109146
}),
110147
);

chapter-7/src/app/routes.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@ export const Routes = () => {
3232
exact
3333
/>
3434
<Route
35-
path={path + '/settings-and-privacy'}
35+
path={path + '/list-products'}
3636
component={lazy(
37-
() => import('./views/dashboard/settings-and-privacy'),
37+
() => import('./views/dashboard/product/ProductListView'),
38+
)}
39+
exact
40+
/>
41+
<Route
42+
path={path + '/create-product'}
43+
component={lazy(
44+
() => import('./views/dashboard/product/ProductCreateView'),
3845
)}
3946
exact
4047
/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { makeStyles } from '@material-ui/core';
3+
4+
const Header = () => {
5+
const classes = useStyles();
6+
7+
return <h1>Header works!</h1>;
8+
};
9+
10+
const useStyles = makeStyles(() => ({}));
11+
12+
export default Header;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { makeStyles } from '@material-ui/core';
3+
4+
const ProductCreateForm = () => {
5+
const classes = useStyles();
6+
7+
return <h1>ProductCreateForm works!</h1>;
8+
};
9+
10+
const useStyles = makeStyles(() => ({}));
11+
12+
export default ProductCreateForm;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import { Container, makeStyles } from '@material-ui/core';
3+
4+
import Header from './Header';
5+
import ProductCreateForm from './ProductCreateForm';
6+
7+
const ProductCreateView = () => {
8+
const classes = useStyles();
9+
10+
return (
11+
<Container>
12+
<Header />
13+
<ProductCreateForm />
14+
</Container>
15+
);
16+
};
17+
18+
const useStyles = makeStyles(theme => ({}));
19+
20+
export default ProductCreateView;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { makeStyles } from '@material-ui/core';
3+
4+
const Header = () => {
5+
const classes = useStyles();
6+
7+
return <h1>Header works!</h1>;
8+
};
9+
10+
const useStyles = makeStyles(() => ({}));
11+
12+
export default Header;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { makeStyles } from '@material-ui/core';
3+
4+
const Results = () => {
5+
const classes = useStyles();
6+
7+
return <h1>Results works!</h1>;
8+
};
9+
10+
const useStyles = makeStyles(() => ({}));
11+
12+
export default Results;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import { Container, makeStyles } from '@material-ui/core';
3+
4+
import Header from './Header';
5+
import Results from './Results';
6+
7+
const ProductListView = () => {
8+
const classes = useStyles();
9+
10+
return (
11+
<Container>
12+
<Header />
13+
<Results />
14+
</Container>
15+
);
16+
};
17+
18+
const useStyles = makeStyles(theme => ({}));
19+
20+
export default ProductListView;

chapter-7/src/app/views/dashboard/settings-and-privacy.tsx

-9
This file was deleted.

chapter-7/src/models/product-type.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export type InventoryType = 'in_stock' | 'limited' | 'out_of_stock';
2+
3+
export type ProductType = {
4+
id: string;
5+
attributes: string[];
6+
category: string;
7+
createdAt: string | number;
8+
currency: string;
9+
image: string | null;
10+
inventoryType: InventoryType;
11+
isAvailable: boolean;
12+
isShippable: boolean;
13+
name: string;
14+
price: number;
15+
quantity: number;
16+
updatedAt: string | number;
17+
variants: number;
18+
description: string;
19+
images: string[];
20+
includesTaxes: boolean;
21+
isTaxable: boolean;
22+
productCode: '';
23+
productSku: '';
24+
salePrice: '';
25+
};

0 commit comments

Comments
 (0)