/* ============================================================================= * B01_Dashboard_UI_Views.ts * 대시보드 세부 페이지 등록부(546) — 한 줄 = 한 페이지 · 주소 `#/b01-account?view=<열쇠>&…`. * key = 주소 열쇠 · title = 메뉴 · 머리 글 · group = 메뉴 묶음(hidden = 메뉴에 안 보임 · 주소로만) * roles = 보이는 역할(없는 역할은 메뉴에서 숨고 주소로 와도 홈) · icon = ui_template_icons 이름 * mount(host, ctx) = host 에 그림 · 정리 함수를 돌려주면 떠날 때 부름(비동기 가능) * ctx = { me, role, companyId, go(view, params?) } — companyId = 시스템 관리자는 머리에서 고른 회사 * 새 페이지는 자기 줄만 갈아 끼움. * ========================================================================== */ import type { IconName } from "@ui/ui_template_icons"; import type { DashboardUser } from "./B01_Dashboard_Api_Fetch"; import { mountHome } from "./B01_Dashboard_UI_Home"; import { mountChat, mountGuide } from "./B01_Dashboard_UI_Nav"; import { mountAssigned } from "./B01_Dashboard_UI_View_Assigned"; import { mountCompany } from "./B01_Dashboard_UI_View_Company"; import { mountCompanyDefaults } from "./B01_Dashboard_UI_View_CompanyDefaults"; import { mountPeople } from "./B01_Dashboard_UI_View_People"; import { mountTemp } from "./B01_Dashboard_UI_View_Temp"; import { mountProjectDetail } from "./B01_Dashboard_UI_ProjectDetail"; import { mountProjectList } from "./B01_Dashboard_UI_ProjectList"; import { mountMe } from "./B01_Dashboard_UI_View_Me"; import { mountSysCompanies } from "./B01_Dashboard_UI_View_SysCompanies"; import { mountSysDefaults } from "./B01_Dashboard_UI_View_SysDefaults"; import { mountSysLogs } from "./B01_Dashboard_UI_View_SysLogs"; import { mountSysOverview } from "./B01_Dashboard_UI_View_SysOverview"; import { mountSysUsers } from "./B01_Dashboard_UI_View_SysUsers"; import { mountTrash } from "./B01_Dashboard_UI_View_Trash"; import { mountUiKit } from "@ui/ui_template_ui_kit"; /** 역할 넷 — 산림청 = 세션 is_forest_service 인 일반 사용자(회사 관리자 · 시스템 관리자가 앞섬) */ export type ViewRole = "USER" | "ADMIN" | "FOREST" | "SYSTEM_ADMIN"; export type ViewGroup = "work" | "company" | "system" | "help" | "hidden"; export interface ViewCtx { me: DashboardUser; role: ViewRole; companyId: number | null; go: (view: string, params?: Record) => void; } type Cleanup = (() => void) | void; export interface View { key: string; title: string; group: ViewGroup; roles: readonly ViewRole[]; icon?: IconName; mount: (host: HTMLElement, ctx: ViewCtx) => Cleanup | Promise; } export const DEFAULT_VIEW = "home"; const ALL: readonly ViewRole[] = ["USER", "ADMIN", "FOREST", "SYSTEM_ADMIN"]; // prettier-ignore export const VIEWS: View[] = [ // 작업 { key: "home", title: "홈", group: "work", roles: ALL, icon: "home", mount: mountHome }, { key: "projects", title: "프로젝트", group: "work", roles: ALL, icon: "folder", mount: mountProjectList }, { key: "project", title: "프로젝트 상세", group: "hidden", roles: ALL, mount: mountProjectDetail }, { key: "assigned", title: "받은 예정노선", group: "work", roles: ["USER", "ADMIN", "SYSTEM_ADMIN"], icon: "route", mount: mountAssigned }, { key: "temp", title: "임시 보관함", group: "work", roles: ALL, icon: "archive", mount: mountTemp }, // 회사 관리 { key: "people", title: "사람", group: "company", roles: ["ADMIN", "SYSTEM_ADMIN"], icon: "users", mount: mountPeople }, { key: "company", title: "회사 정보", group: "company", roles: ALL, icon: "building", mount: mountCompany }, { key: "company-defaults", title: "회사 설계 기본값", group: "company", roles: ["USER", "ADMIN", "FOREST"], icon: "adjustments", mount: mountCompanyDefaults }, { key: "company-trash", title: "휴지통", group: "company", roles: ["ADMIN"], icon: "trash", mount: mountTrash }, // 시스템 관리 { key: "sys-overview", title: "개요", group: "system", roles: ["SYSTEM_ADMIN"], icon: "gauge", mount: mountSysOverview }, { key: "sys-companies", title: "회사", group: "system", roles: ["SYSTEM_ADMIN"], icon: "building", mount: mountSysCompanies }, { key: "sys-users", title: "사용자", group: "system", roles: ["SYSTEM_ADMIN"], icon: "user", mount: mountSysUsers }, { key: "sys-defaults", title: "설계 기본값", group: "system", roles: ["SYSTEM_ADMIN"], icon: "database", mount: mountSysDefaults }, { key: "sys-logs", title: "시스템 로그", group: "system", roles: ["SYSTEM_ADMIN"], icon: "fileText", mount: mountSysLogs }, { key: "sys-trash", title: "휴지통", group: "system", roles: ["SYSTEM_ADMIN"], icon: "trash", mount: mountTrash }, { key: "ui-kit", title: "부품 모음", group: "system", roles: ["SYSTEM_ADMIN"], icon: "adjustments", mount: mountUiKit }, // 도움 { key: "guide", title: "사용자 가이드", group: "help", roles: ALL, icon: "book", mount: mountGuide }, { key: "chat", title: "지식 챗봇", group: "help", roles: ALL, icon: "chatbot", mount: mountChat }, // 사용자 메뉴 { key: "me", title: "내 정보", group: "hidden", roles: ALL, icon: "userCircle", mount: mountMe }, ]; /** 머리 [?] 가 먼저 여는 가이드 절(`A05_EduDetail/guide/B01/<절>.md`) — 없으면 B01 설명서 */ export const VIEW_HELP: Record = { home: "01_홈", projects: "02_프로젝트_목록", assigned: "03_받은_예정노선", temp: "04_임시_보관함", people: "05_회사와_팀원", project: "06_프로젝트_상세", company: "07_회사_정보", "company-defaults": "08_회사_설계_기본값", "sys-overview": "09_시스템_관리", "sys-companies": "09_시스템_관리", "sys-users": "09_시스템_관리", "sys-defaults": "09_시스템_관리", "sys-logs": "09_시스템_관리", "sys-trash": "09_시스템_관리", chat: "11_지식_챗봇", me: "12_내_정보", }; /** 역할 가르기 — 옛 B01 갈래(시스템 관리자 · 회사 관리자 · 그 밖) + 산림청 */ export function roleOf(me: DashboardUser, forest: boolean): ViewRole { if (me.role === "SYSTEM_ADMIN" || me.role === "ADMIN") return me.role; return forest ? "FOREST" : "USER"; } /** 주소 열쇠 → 페이지 · 없거나 권한 없으면 홈 */ export function viewFor(key: string | null, role: ViewRole): View { const found = VIEWS.find((v) => v.key === key && v.roles.includes(role)); return found ?? VIEWS.find((v) => v.key === DEFAULT_VIEW)!; }