Files
HMDesign/packages/org-chart/src/core/department-card-assets.ts
T

54 lines
2.9 KiB
TypeScript

import businessLeader from '../assets/cards/경영기획팀.svg?inline';
import businessEmployee from '../assets/cards/경영기획팀-sm.svg?inline';
import managementLeader from '../assets/cards/사업관리팀.svg?inline';
import managementEmployee from '../assets/cards/사업관리팀-sm.svg?inline';
import designLeader from '../assets/cards/디자인기획팀.svg?inline';
import designEmployee from '../assets/cards/디자인기획팀-sm.svg?inline';
import solutionLeader from '../assets/cards/솔루션통합팀.svg?inline';
import solutionEmployee from '../assets/cards/솔루션통합팀-sm.svg?inline';
import talentLeader from '../assets/cards/인재성장팀.svg?inline';
import talentEmployee from '../assets/cards/인재성장팀-sm.svg?inline';
import systemLeader from '../assets/cards/통합시스템 디비전.svg?inline';
import systemEmployee from '../assets/cards/통합시스템 디비전-sm.svg?inline';
export type DepartmentCardSize = 'leader' | 'employee';
export interface DepartmentCardAsset {
departmentId: string;
label: string;
size: DepartmentCardSize;
url: string;
width: number;
height: number;
}
// Presentation-only mapping. The ten supplied SVGs are copied byte-for-byte;
// business-management uses vectors generated from the supplied PNG's colors.
// Vite embeds both in ESM/IIFE bundles, including file:// consumers.
// User-approved alias: 솔루션통합팀 assets -> existing solution-sales data.
const departments = new Map([
['business-management', { label: '사업관리팀', leader: managementLeader, employee: managementEmployee }],
['business-planning', { label: '경영기획팀', leader: businessLeader, employee: businessEmployee }],
['design-planning', { label: '디자인기획팀', leader: designLeader, employee: designEmployee }],
['solution-sales', { label: '솔루션통합팀', leader: solutionLeader, employee: solutionEmployee }],
['talent-growth', { label: '인재성장팀', leader: talentLeader, employee: talentEmployee }],
['integrated-system', { label: '통합시스템 Div', leader: systemLeader, employee: systemEmployee }],
]);
/** Resolve actual ancestry; do not infer a department from ID spelling/colors.
* Unknown organizations and departments without supplied assets stay unchanged. */
export function getDepartmentCardAsset(
departmentId: string, size: DepartmentCardSize,
organizations: readonly { id: string; parentId: string | null }[] = [],
): DepartmentCardAsset | undefined {
const visited = new Set<string>();
let current: string | null = departmentId;
while (current && !visited.has(current)) {
visited.add(current);
const entry = departments.get(current);
if (entry) return { departmentId: current, label: entry.label, size, url: entry[size],
width: size === 'leader' ? 146 : 108, height: size === 'leader' ? 68 : 52 };
current = organizations.find(item => item.id === current)?.parentId ?? null;
}
return undefined;
}