@@ -132,7 +126,7 @@ const App = () => {
) : (
- } />
+ } />
} />
} />
diff --git a/admin/src/components/Header.js b/admin/src/components/Header.js
index 4bd120b..54b0662 100644
--- a/admin/src/components/Header.js
+++ b/admin/src/components/Header.js
@@ -1,32 +1,61 @@
-import React from 'react';
+import React, { useState, useContext } from "react";
+import { useNavigate } from "react-router-dom";
+import Swal from "sweetalert2";
+
+import { UserContext } from "../pages/auth/UserContext";
const Header = () => {
- return (
-
- CINEMAGIC
-
-
- );
+ const navigate = useNavigate();
+ const { updateUserData } = useContext(UserContext);
+
+ const handleLogout = () => {
+ Swal.fire({
+ title: "Are you sure?",
+ text: "You won't be able to revert this!",
+ icon: "warning",
+ showCancelButton: true,
+ confirmButtonColor: "#3085d6",
+ cancelButtonColor: "#d33",
+ confirmButtonText: "Yes, log out!",
+ }).then((result) => {
+ if (result.isConfirmed) {
+ updateUserData({});
+ localStorage.removeItem("admin-token");
+ navigate("/login");
+ }
+ });
+ };
+ return (
+
+ CINEMAGIC
+
+
+ );
};
export default Header;