From fe7fb860fc332247e53d8d193fd4c10c09503704 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Thu, 31 Oct 2024 10:00:21 +0700
Subject: button logout

---
 app/lib/camera/component/hedear.tsx | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

(limited to 'app/lib/camera/component/hedear.tsx')

diff --git a/app/lib/camera/component/hedear.tsx b/app/lib/camera/component/hedear.tsx
index 5cf3f1d..2a8bfc6 100644
--- a/app/lib/camera/component/hedear.tsx
+++ b/app/lib/camera/component/hedear.tsx
@@ -1,7 +1,17 @@
 // components/Header.tsx
 import Image from "next/image";
+import { deleteAuth, getAuth } from "../../api/auth";
+import { Button } from "@mui/material";
+import { useRouter } from "next/navigation";
 
 export default function Header() {
+  const auth = getAuth();
+  const route = useRouter();
+
+  const handleSigOut = () => {
+    deleteAuth();
+    route.push('/login');
+  };
   return (
     <nav className="fixed top-0 left-0 w-full bg-white border-b-2 border-red-500 py-4 px-4 sm:px-96 z-50 shadow-md">
       <div className="flex justify-between items-center">
@@ -14,7 +24,13 @@ export default function Header() {
             className="rounded-full"
           />
         </div>
-
+        {auth && (
+          <div>
+            <Button size="small" onClick={() => handleSigOut()}>
+              Logout
+            </Button>
+          </div>
+        )}
       </div>
     </nav>
   );
-- 
cgit v1.2.3

