From d145f8ecba591db7f0fc6ed5c0d3e7bcfb2d6f54 Mon Sep 17 00:00:00 2001 From: gunshiz Date: Sat, 10 Oct 2026 00:38:23 +0700 Subject: [PATCH] fix : dedupe code --- components/admin/admin-header.tsx | 165 ++++++++++++++---------------- components/header-shell.tsx | 32 ++++++ components/public/site-header.tsx | 34 ++---- 3 files changed, 115 insertions(+), 116 deletions(-) create mode 100644 components/header-shell.tsx diff --git a/components/admin/admin-header.tsx b/components/admin/admin-header.tsx index 53963f3..46ea5aa 100644 --- a/components/admin/admin-header.tsx +++ b/components/admin/admin-header.tsx @@ -1,6 +1,5 @@ "use client"; -import Image from "@/components/ui/resilient-image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { @@ -15,101 +14,85 @@ import { } from "lucide-react"; import { Button } from "@/components/ui/button"; -import { PublicAccountMenu } from "@/components/public/public-account-menu"; -import { NotificationBell } from "@/components/notifications/notification-bell"; -import { ThemeSwitcher } from "@/components/theme-switcher"; +import { HeaderShell } from "@/components/header-shell"; export function AdminHeader() { const pathname = usePathname(); - return (<> -
-
- + - - - -
-
- + + + ); } diff --git a/components/header-shell.tsx b/components/header-shell.tsx new file mode 100644 index 0000000..302317e --- /dev/null +++ b/components/header-shell.tsx @@ -0,0 +1,32 @@ +import type { ReactNode } from "react"; +import Link from "next/link"; + +import Image from "@/components/ui/resilient-image"; +import { PublicAccountMenu } from "@/components/public/public-account-menu"; +import { NotificationBell } from "@/components/notifications/notification-bell"; +import { ThemeSwitcher } from "@/components/theme-switcher"; + +export function HeaderShell({ homeHref, homeLabel, children }: { + homeHref: string; + homeLabel: string; + children: ReactNode; +}) { + return ( +
+
+ + + ไกด์เกนชินไม่ใช่เกมมือถือ + + {children} + + + +
+
+ ); +} diff --git a/components/public/site-header.tsx b/components/public/site-header.tsx index e3fa423..15c2d3b 100644 --- a/components/public/site-header.tsx +++ b/components/public/site-header.tsx @@ -1,4 +1,3 @@ -import Image from "@/components/ui/resilient-image"; import Link from "next/link"; import { Suspense } from "react"; import { PencilIcon } from "lucide-react"; @@ -6,9 +5,7 @@ import { PencilIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { VisitorPresence } from "@/components/public/visitor-presence"; import { PublicNavigation } from "@/components/public/public-navigation"; -import { PublicAccountMenu } from "@/components/public/public-account-menu"; -import { NotificationBell } from "@/components/notifications/notification-bell"; -import { ThemeSwitcher } from "@/components/theme-switcher"; +import { HeaderShell } from "@/components/header-shell"; import { getAdminSession } from "@/lib/auth/server"; import { HttpError } from "@/lib/security/http"; @@ -30,27 +27,14 @@ async function AdminEditLink({ editHref }: { editHref: string }) { export function SiteHeader({ editHref = "/admin", guideId }: { editHref?: string; guideId?: string } = {}) { return ( -
-
- - - ไกด์เกนชินไม่ใช่เกมมือถือ - - -
- -
- - - - - - + + +
+
-
+ + + + ); }