[55ed171] | 1 | import React, { useContext, useEffect, useState } from "react";
|
---|
| 2 | import Button from "react-bootstrap/Button";
|
---|
| 3 | import "../styles/AdminDashboard.css";
|
---|
| 4 | import AddProductForm from "../components/AddProductForm";
|
---|
| 5 | import { Store } from "../Store";
|
---|
| 6 | import { useNavigate, Link } from "react-router-dom";
|
---|
| 7 | import ListProducts from "../components/ListProducts";
|
---|
[a2e5735] | 8 | import { Helmet } from "react-helmet-async";
|
---|
[55ed171] | 9 |
|
---|
| 10 | function AdminDashboardScreen() {
|
---|
| 11 | const navigate = useNavigate();
|
---|
| 12 | const { state } = useContext(Store);
|
---|
| 13 | const { userInfo } = state;
|
---|
| 14 | useEffect(() => {
|
---|
| 15 | if (!userInfo || !userInfo.isAdmin) {
|
---|
| 16 | return navigate("/");
|
---|
| 17 | }
|
---|
| 18 | }, [userInfo, navigate]);
|
---|
| 19 |
|
---|
| 20 | return (
|
---|
| 21 | <div id="pgContainer">
|
---|
[a2e5735] | 22 | <Helmet>
|
---|
| 23 | <title>Dashboard</title>
|
---|
| 24 | </Helmet>
|
---|
[55ed171] | 25 | <div id="sidebarMenu">
|
---|
| 26 | <Link
|
---|
| 27 | to={"/admin/addProduct"}
|
---|
| 28 | style={{ textDecoration: "none", width: "100%" }}
|
---|
| 29 | >
|
---|
| 30 | <div className="dashboard-btn" to="/admin/addProduct">
|
---|
| 31 | Додади нов производ
|
---|
| 32 | </div>
|
---|
| 33 | </Link>
|
---|
[a2e5735] | 34 | <Link
|
---|
| 35 | to={"/admin/addCategory"}
|
---|
| 36 | style={{ textDecoration: "none", width: "100%" }}
|
---|
| 37 | >
|
---|
| 38 | <div className="dashboard-btn">Додади категорија</div>
|
---|
| 39 | </Link>
|
---|
[55ed171] | 40 | <Link
|
---|
| 41 | to={"/admin/products"}
|
---|
| 42 | style={{ textDecoration: "none", width: "100%" }}
|
---|
| 43 | >
|
---|
| 44 | <div className="dashboard-btn">Производи</div>
|
---|
| 45 | </Link>
|
---|
| 46 | <Link
|
---|
| 47 | to={"/admin/orders"}
|
---|
| 48 | style={{ textDecoration: "none", width: "100%" }}
|
---|
| 49 | >
|
---|
| 50 | <div className="dashboard-btn">Нарачки</div>
|
---|
| 51 | </Link>
|
---|
| 52 | </div>
|
---|
| 53 | </div>
|
---|
| 54 | );
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | export default AdminDashboardScreen;
|
---|