260515_01_ENH: 클라이언트 수정사항 반영 및 다른 조사들 data 연결
This commit is contained in:
@@ -11,7 +11,9 @@ import {usePathname} from "next/navigation";
|
||||
interface HeaderProps {
|
||||
topMenus: TopMenuItem[];
|
||||
userName: string;
|
||||
isAdmin: boolean;
|
||||
isAuthenticated: boolean;
|
||||
baseDateLabel: string;
|
||||
onNavigate: (path: string) => void;
|
||||
onLogin: () => void;
|
||||
onLogout: () => void;
|
||||
@@ -20,7 +22,9 @@ interface HeaderProps {
|
||||
const Header = ({
|
||||
topMenus,
|
||||
userName,
|
||||
isAdmin,
|
||||
isAuthenticated,
|
||||
baseDateLabel,
|
||||
onNavigate,
|
||||
onLogin,
|
||||
onLogout,
|
||||
@@ -29,71 +33,74 @@ const Header = ({
|
||||
|
||||
return (
|
||||
<header className="app-header sticky top-0 z-40">
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-4 px-4 h-16">
|
||||
<div className="flex min-w-0 items-center gap-4">
|
||||
<div className="flex items-center gap-2 cursor-pointer w-37 h-15 justify-center">
|
||||
<div className="relative grid h-[4rem] grid-cols-[10rem_minmax(0,1fr)_minmax(12rem,auto)] grid-rows-[2rem_2rem] items-center gap-x-4 px-4">
|
||||
<div className="row-span-2 flex h-full min-w-0 items-center">
|
||||
<button
|
||||
type="button"
|
||||
className="flex h-full w-37 cursor-pointer items-center justify-center gap-2 bg-transparent p-0"
|
||||
onClick={() => onNavigate("/safety-inspection")}
|
||||
>
|
||||
<Image
|
||||
src="/head_logo.png"
|
||||
alt="logo"
|
||||
width={150}
|
||||
height={90}
|
||||
className="object-contain"
|
||||
onClick={() => onNavigate("/safety-inspection")}
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
|
||||
<nav className="flex min-w-0 items-center gap-3 ml-5 overflow-hidden">
|
||||
{topMenus.map((topMenu) => {
|
||||
const active = topMenu.match?.(pathname) ?? pathname === topMenu.path;
|
||||
return (
|
||||
<button
|
||||
key={topMenu.id}
|
||||
type="button"
|
||||
onClick={() => onNavigate(topMenu.path)}
|
||||
className={cn(
|
||||
"relative h-8 inline-flex items-center font-bold transition-colors cursor-pointer",
|
||||
"content-text-lg bg-transparent px-1",
|
||||
active
|
||||
? "text-header-primary"
|
||||
: "text-header-secondary-hover"
|
||||
)}
|
||||
>
|
||||
{topMenu.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex items-center justify-center">
|
||||
<div className="pointer-events-none absolute left-1/2 top-0 flex h-10 -translate-x-1/2 items-center justify-center">
|
||||
<h1 className="font-bold content-text-2xl text-header-color">{SITE_TITLE}</h1>
|
||||
</div>
|
||||
<div className="flex min-w-0 items-center justify-end gap-4">
|
||||
{
|
||||
/* 클라이언트 요청으로 로그인 제외
|
||||
{isAuthenticated && (
|
||||
<span className="content-text-base text-header-color hidden max-w-40 truncate sm:inline font-bold">
|
||||
{userName}
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
className="gap-2 border border-transparent bg-green-600 text-white w-25 shadow-sm hover:bg-green-500 hover:text-white"
|
||||
onClick={isAuthenticated ? onLogout : onLogin}
|
||||
>
|
||||
{isAuthenticated ? (
|
||||
<>
|
||||
<LogOut className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"관리자 로그아웃"}</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<LogIn className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"관리자 로그인"}</span>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
*/
|
||||
}
|
||||
<div className="col-start-3 row-start-1 flex min-w-0 items-center justify-end gap-4">
|
||||
{isAdmin && (
|
||||
<>
|
||||
<span className="content-text-base text-header-color hidden max-w-40 truncate sm:inline font-bold">
|
||||
{userName}
|
||||
</span>
|
||||
<Button
|
||||
className="gap-2 border border-transparent bg-green-600 text-white w-25 shadow-sm hover:bg-green-500 hover:text-white"
|
||||
onClick={isAuthenticated ? onLogout : onLogin}
|
||||
>
|
||||
{isAuthenticated ? (
|
||||
<>
|
||||
<LogOut className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">로그아웃</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<LogIn className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">로그인</span>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<nav className="col-start-2 row-start-2 flex min-w-0 items-center gap-3 overflow-hidden pb-1.5">
|
||||
{topMenus.map((topMenu) => {
|
||||
const active = topMenu.match?.(pathname) ?? pathname === topMenu.path;
|
||||
return (
|
||||
<button
|
||||
key={topMenu.id}
|
||||
type="button"
|
||||
onClick={() => onNavigate(topMenu.path)}
|
||||
className={cn(
|
||||
"relative inline-flex h-5 cursor-pointer items-center font-bold transition-colors",
|
||||
"content-text-lg bg-transparent px-1",
|
||||
active
|
||||
? "text-header-primary"
|
||||
: "text-header-secondary-hover"
|
||||
)}
|
||||
>
|
||||
{topMenu.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
<div className="col-start-3 row-start-2 flex min-w-0 items-center justify-end gap-4 content-text-base font-bold text-header-color">
|
||||
{baseDateLabel}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user