()
| 4 | import Link from "next/link"; |
| 5 | |
| 6 | export default function AdminHeader() { |
| 7 | const router = useRouter(); |
| 8 | |
| 9 | const handleLogout = async () => { |
| 10 | try { |
| 11 | const response = await fetch("/api/admin/logout", { |
| 12 | method: "POST", |
| 13 | }); |
| 14 | |
| 15 | if (response.ok) { |
| 16 | router.push("/admin/login"); |
| 17 | router.refresh(); |
| 18 | } |
| 19 | } catch (error) { |
| 20 | console.error("Logout error:", error); |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | return ( |
| 25 | <header className="bg-white shadow-sm"> |
| 26 | <div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8"> |
| 27 | <div className="flex items-center justify-between py-4"> |
| 28 | <nav className="flex space-x-4"> |
| 29 | <Link |
| 30 | href="/admin" |
| 31 | className="rounded-md px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900" |
| 32 | > |
| 33 | Add Bookmark |
| 34 | </Link> |
| 35 | <Link |
| 36 | href="/admin/manage" |
| 37 | className="rounded-md px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900" |
| 38 | > |
| 39 | Manage Bookmarks |
| 40 | </Link> |
| 41 | </nav> |
| 42 | <button |
| 43 | onClick={handleLogout} |
| 44 | className="rounded-md px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900" |
| 45 | > |
| 46 | Logout |
| 47 | </button> |
| 48 | </div> |
| 49 | </div> |
| 50 | </header> |
| 51 | ); |
| 52 | } |
nothing calls this directly
no outgoing calls
no test coverage detected