'use client';

import type { AdminNotification } from '@/lib/domain/notification';
import type { SidebarMenu } from '@/lib/domain/sidebar-menu';
import { AdminFooter } from './admin-footer';
import styles from './admin-shell.module.scss';
import { AdminHeader } from './admin-header';
import { AdminSidebar } from './admin-sidebar';

interface AdminShellProps {
  children: React.ReactNode;
  /** 헤더 프로필에 표시할 관리자 이름 — 세션을 읽는 상위 Server Component가 넘긴다. */
  adminName: string;
  /** 계정 권한에 맞춰 서버가 구성한 사이드바 메뉴. */
  menu: SidebarMenu;
  /** 헤더 종 버튼이 펼치는 알림 목록. */
  notifications: AdminNotification[];
}

/**
 * Basic 레이아웃의 상호작용 경계 — 헤더·사이드바·풋터를 조립한다. page 콘텐츠(children)는
 * 상위 Server Component가 렌더한 결과를 props로 그대로 통과시켜 RSC를 유지한다 — 이 컴포넌트
 * 자신은 children의 내용을 알거나 가공하지 않는다.
 *
 * 사이드바 열림/접힘 상태(useSidebar)는 더 이상 여기서 소유하지 않는다. 시안의 헤더·사이드바
 * 어디에도 그 토글이 없어 헤더 구현 때 함께 걷어냈다 — 접힘 모양이 시안에 정의되면 그때
 * 다시 붙인다.
 */
export function AdminShell({
  children,
  adminName,
  menu,
  notifications,
}: AdminShellProps) {
  return (
    <div className={styles.shell}>
      <AdminHeader adminName={adminName} notifications={notifications} />
      <div className={styles.body}>
        <AdminSidebar menu={menu} />
        <div className={styles.content}>
          <main className={styles.main}>{children}</main>
          <AdminFooter className={styles.footer} />
        </div>
      </div>
    </div>
  );
}
