// frontend/components/mail/MailSidebar.tsx — 좌측 사이드바 // 계정 루트 트리: 전체 받은편지함 + 각 계정 아래 '실제' 폴더/라벨(Gmail 라벨·Outlook 폴더)을 서브트리로. "use client"; import { useState } from "react"; import { Icon } from "@/components/Icon"; import type { IconName } from "@/components/icons/paths"; import type { AccountFolder, MailAccount } from "@/lib/types"; // 한 계정(또는 통합) 가지: 부모 행 + 실제 폴더 자식들. function Branch({ nodeKey, scope, unread, label, sub, dot, open, folders, acctFilter, folder, onToggle, onSelectScope, }: { nodeKey: string; scope: string | null; // null=통합, 그 외=계정 id unread: number; label: string; sub?: string; dot?: string; // 계정 색 open: boolean; folders: AccountFolder[]; // 이 가지에 표시할 실제 폴더/라벨 acctFilter: string | null; folder: string; onToggle: (key: string) => void; onSelectScope: (acctFilter: string | null, folder: string) => void; }) { const scopeActive = acctFilter === scope && folder !== "smart"; return (
{open && (
{folders.map((f) => { const on = acctFilter === scope && folder === f.slug; return ( ); })}
)}
); } export function MailSidebar({ accounts, folder, acctFilter, smartCount, unifiedUnread, accUnread, unifiedFolders, foldersByAccount, accColor, onCompose, onSelectSmart, onSelectScope, onToast, }: { accounts: MailAccount[]; folder: string; acctFilter: string | null; smartCount: number; unifiedUnread: number; accUnread: (id: string) => number; unifiedFolders: AccountFolder[]; foldersByAccount: Record; accColor: (id: string) => string; onCompose: () => void; onSelectSmart: () => void; onSelectScope: (acctFilter: string | null, folder: string) => void; onToast: (msg: string, tone: string) => void; }) { // 펼친 계정 집합(기본은 전부 접힘). 키: 계정 id. const [openAccts, setOpenAccts] = useState>(new Set()); const toggle = (key: string) => setOpenAccts((prev) => { const next = new Set(prev); if (next.has(key)) next.delete(key); else next.add(key); return next; }); return ( ); }