Skip to content

Commit 24bed6b

Browse files
authored
Video-32-Admin-Dashboard-UI (#32)
1 parent 7688fbb commit 24bed6b

6 files changed

Lines changed: 118 additions & 18 deletions

File tree

README.md

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,36 +268,58 @@ JS AMAZONA
268268
2. create api for getMyOrders
269269
3. show orders in profile screen
270270
4. style orders
271-
32. Admin Products
272-
1. create Admin Order menu in header
273-
2. create ProductListScreen.js
274-
3. show products with edit and delete button
275-
4. show create product button
276-
5. implement create product backend
277-
6. redirect user to edit product screen
278-
33. Edit Product
271+
32. Admin Dashboard UI
272+
1. Header.js
273+
2. if user is admin show Dashboard
274+
3. create DashboardScreen
275+
4. create DashboardMenu
276+
5. Style dashboard
277+
33. Admin Products UI
279278
1. create ProductListScreen.js
280-
2. load product data from backend
281-
3. handle form submit
282-
4. save product in backend
283-
34. Delete Product
279+
2. show products with edit and delete button
280+
3. show create product button
281+
34. Create Product
282+
1. create product model
283+
2. implement create product route
284+
3. create product function in api.js
285+
4. call create product function in ProductListScreen
286+
5. redirect to edit product
287+
35. Edit Product
288+
1. update parseUrlRequest to get action
289+
2. create ProductEditScreen.js
290+
3. load product data from backend
291+
4. handle form submit
292+
5. save product in backend
293+
36. Delete Product
284294
1. update ProductListScreen.js
285295
2. handle delete button
286296
3. rerender after deletion
287-
35. Admin Orders
297+
37. Admin Orders
288298
1. create Admin Order menu in header
289299
2. create AdminOrder.js
290300
3. load orders from backend
291301
4. list them in the screen
292302
5. show delete and edit button
293303
6. redirect to order details on edit action
294-
36. Edit Order
304+
38. Edit Order
295305
1. if order is payed show deliver button for admin
296306
2. handle click on deliver button
297307
3. set state to delivered
298-
37. Delete Order
308+
39. Delete Order
299309
1. update OrderListScreen.js
300310
2. handle delete button
301311
3. rerender after deletion
302-
38. Publish heroku
312+
40. Show Summary Report in Dashboard
313+
1. create summary section
314+
2. style summary
315+
3. create summary backend
316+
4. create getSummary in api.js
317+
5. load data in dashboard screen
318+
6. show 3 boxes for Users, Orders and Sales
319+
41. Show Chart in Dashboard
320+
1. import chartist
321+
2. add chartist css to index.html
322+
3. create linear chart for daily sales
323+
4. create pie chart for product categories
324+
42. Publish heroku
303325
1. publish steps
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const DashboardMenu = {
2+
render: (props) => {
3+
return `
4+
<div class="dashboard-menu">
5+
<ul>
6+
<li class="${props.selected === 'dashboard' ? 'selected' : ''}">
7+
<a href="/#/dashboard">Dashboard</a>
8+
</li>
9+
<li class="${props.selected === 'orders' ? 'selected' : ''}">
10+
<a href="/#/orderlist">Orders</a>
11+
</li>
12+
<li class="${props.selected === 'products' ? 'selected' : ''}">
13+
<a href="/#/productlist">Products</a>
14+
</li>
15+
</ul>
16+
</div>
17+
`;
18+
},
19+
};
20+
export default DashboardMenu;

frontend/src/components/Header.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getUserInfo } from '../localStorage';
22

33
const Header = {
44
render: () => {
5-
const { name } = getUserInfo();
5+
const { name, isAdmin } = getUserInfo();
66
return `
77
<div class="brand">
88
<a href="/#/">jsamazona</a>
@@ -15,6 +15,7 @@ const Header = {
1515
}
1616
1717
<a href="/#/cart">Cart</a>
18+
${isAdmin ? `<a href="/#/dashboard">Dashboard</a>` : ''}
1819
</div>`;
1920
},
2021
after_render: () => {},

frontend/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ShippingScreen from './srceens/ShippingScreen';
1111
import PaymentScreen from './srceens/PaymentScreen';
1212
import PlaceOrderScreen from './srceens/PlaceOrderScreen';
1313
import OrderScreen from './srceens/OrderScreen';
14+
import DashboardScreen from './srceens/DashboardScreen';
1415

1516
const routes = {
1617
'/': HomeScreen,
@@ -24,6 +25,7 @@ const routes = {
2425
'/shipping': ShippingScreen,
2526
'/payment': PaymentScreen,
2627
'/placeorder': PlaceOrderScreen,
28+
'/dashboard': DashboardScreen,
2729
};
2830
const router = async () => {
2931
showLoading();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import DashboardMenu from '../components/DashboardMenu';
2+
3+
const DashboardScreen = {
4+
after_render: () => {},
5+
render: () => {
6+
return `
7+
<div class="dashboard">
8+
${DashboardMenu.render({ selected: 'dashboard' })}
9+
<div class="dashboard-content">
10+
<h1>Dashboard</h1>
11+
<div>
12+
Info and Charts will be added here
13+
</div>
14+
</div>
15+
</div>
16+
`;
17+
},
18+
};
19+
export default DashboardScreen;

frontend/style.css

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ header {
9191
}
9292
header a {
9393
color: #ffffff;
94-
font-weight: bold;
9594
text-decoration: none;
95+
padding-right: 1rem;
9696
}
9797
header a:hover {
9898
color: #f08040;
9999
}
100100
.brand a {
101+
font-weight: bold;
101102
font-size: 3rem;
103+
padding-left: 1rem;
102104
}
103105
footer {
104106
background-color: #203040;
@@ -372,3 +374,37 @@ tbody > tr:nth-child(odd) {
372374
td {
373375
padding: 0.5rem;
374376
}
377+
/* Dashboard */
378+
.dashboard {
379+
display: flex;
380+
flex-wrap: wrap;
381+
height: 100%;
382+
}
383+
.dashboard h1 {
384+
font-size: 3rem;
385+
margin: 1rem 0;
386+
}
387+
.dashboard-menu {
388+
flex: 1 1 20rem;
389+
background-color: #f0f0f0;
390+
}
391+
.dashboard-menu ul {
392+
padding: 0;
393+
}
394+
.dashboard-menu a {
395+
display: flex;
396+
padding: 1rem;
397+
padding-left: 2rem;
398+
justify-content: space-between;
399+
}
400+
.dashboard-menu a:hover {
401+
background-color: #c0c0c0;
402+
}
403+
.dashboard-menu li.selected a {
404+
background-color: #c0c0c0;
405+
color: #f08040;
406+
}
407+
.dashboard-content {
408+
flex: 4 1 80rem;
409+
padding: 1rem;
410+
}

0 commit comments

Comments
 (0)