diff --git a/src/Dashboards/AdminD.js b/src/Dashboards/AdminD.js index 0e02d79..15e0bfb 100644 --- a/src/Dashboards/AdminD.js +++ b/src/Dashboards/AdminD.js @@ -1,5 +1,7 @@ import React, { useEffect, useState } from "react"; import axios from "axios"; +import { toast, ToastContainer } from "react-toastify"; +import { useNavigate } from "react-router-dom"; import { Chart as ChartJS, CategoryScale, @@ -11,7 +13,6 @@ import { PointElement, LineElement, } from "chart.js"; -import { Bar, Line } from "react-chartjs-2"; import Navbar from "../components/Navbar"; import "tailwindcss/tailwind.css"; @@ -27,6 +28,21 @@ ChartJS.register( ); const AdminD = () => { + const navigate = useNavigate(); + const handleLogout = () => { + try { + let confirmation = window.confirm("Are you sure you want to logout?"); + if (confirmation) { + setTimeout(() => { + localStorage.setItem("isLoggedIn", false); + navigate("/"); + }, 1000); + toast.success("Logout Successfully."); + } + } catch (error) { + toast.error("Error doing logout. Try again."); + } + }; const [barData, setBarData] = useState({ labels: [], datasets: [ @@ -94,7 +110,7 @@ const AdminD = () => { label: "Revenue", data: data.values, fill: false, - backgroundColor: "rgba(153, 102, 255, 0.2)", + backgroundColor: "rgba(153, 182, 455, 0.2)", borderColor: "rgba(153, 102, 255, 1)", }, ], @@ -147,10 +163,13 @@ const AdminD = () => { return ( <> +

Admin Dashboard

-

Announcements

+

+ Announcements +

    {announcements.map((announcement) => (
  • @@ -161,7 +180,7 @@ const AdminD = () => {
-

Users

+

Users

@@ -183,7 +202,7 @@ const AdminD = () => {
-

Products

+

Products

@@ -213,6 +232,12 @@ const AdminD = () => {
+
);