kcg-ai-monitoring/frontend/src/shared/constants/eventStatuses.ts
htlee f589cb0f94 fix(frontend): 카탈로그 배지 테마 분리 + 단속 조치 가독성 수정
변경:
- badgeVariants 8 intent 모두 라이트/다크 팔레트 분리
  - 다크: 밝은 솔리드 배경(-400) + slate-900 글자 + 강한 보더(-600)
  - 라이트: 파스텔 배경(-100) + 진한 글자(-900) + 소프트 보더(-300)
  - base에서 text-on-bright 제거 (intent별로 관리)
- classes 기반 카탈로그 4종에 dark: 변형 추가로 라이트 모드 대응:
  - eventStatuses: bg-red-100 text-red-800 dark:bg-red-500/20 dark:text-red-400
  - enforcementResults: 동일 패턴 (red/purple/yellow/green)
  - patrolStatuses: border 포함 (7 상태)
  - enforcementActions: classes 필드 신규 추가 (기존에 없어서 fallback grey로 떨어져
    라이트 모드에서 글자 안 보이던 원인)
- CatalogSection fallback classes도 dark: 변형 추가 (안전장치)
- enforcementActions에 getEnforcementActionClasses() 헬퍼 신규

빌드 검증:
- tsc , vite build 
- CSS 확인: .dark\:bg-red-400:is(.dark *) 컴파일 정상
2026-04-08 11:23:38 +09:00

80 lines
2.2 KiB
TypeScript

/**
* 이벤트 처리 상태 공통 카탈로그
*
* SSOT: backend `code_master` 그룹 EVENT_STATUS (V008 시드).
* 향후 `GET /api/code-master?groupCode=EVENT_STATUS`로 fetch 예정.
*
* 사용처: EventList(처리상태 컬럼), 알림 처리, 단속 등록 액션
*/
export type EventStatus =
| 'NEW'
| 'ACK'
| 'IN_PROGRESS'
| 'RESOLVED'
| 'FALSE_POSITIVE';
export interface EventStatusMeta {
code: EventStatus;
i18nKey: string;
fallback: { ko: string; en: string };
classes: string; // bg + text 묶음
order: number;
}
export const EVENT_STATUSES: Record<EventStatus, EventStatusMeta> = {
NEW: {
code: 'NEW',
i18nKey: 'eventStatus.NEW',
fallback: { ko: '신규', en: 'New' },
classes: 'bg-red-100 text-red-800 dark:bg-red-500/20 dark:text-red-400',
order: 1,
},
ACK: {
code: 'ACK',
i18nKey: 'eventStatus.ACK',
fallback: { ko: '확인', en: 'Acknowledged' },
classes: 'bg-orange-100 text-orange-800 dark:bg-orange-500/20 dark:text-orange-400',
order: 2,
},
IN_PROGRESS: {
code: 'IN_PROGRESS',
i18nKey: 'eventStatus.IN_PROGRESS',
fallback: { ko: '처리중', en: 'In Progress' },
classes: 'bg-blue-100 text-blue-800 dark:bg-blue-500/20 dark:text-blue-400',
order: 3,
},
RESOLVED: {
code: 'RESOLVED',
i18nKey: 'eventStatus.RESOLVED',
fallback: { ko: '완료', en: 'Resolved' },
classes: 'bg-green-100 text-green-800 dark:bg-green-500/20 dark:text-green-400',
order: 4,
},
FALSE_POSITIVE: {
code: 'FALSE_POSITIVE',
i18nKey: 'eventStatus.FALSE_POSITIVE',
fallback: { ko: '오탐', en: 'False Positive' },
classes: 'bg-muted text-muted-foreground',
order: 5,
},
};
export function getEventStatusMeta(status: string): EventStatusMeta | undefined {
return EVENT_STATUSES[status as EventStatus];
}
export function getEventStatusLabel(
status: string,
t: (key: string, opts?: { defaultValue?: string }) => string,
lang: 'ko' | 'en' = 'ko',
): string {
const meta = getEventStatusMeta(status);
if (!meta) return status;
return t(meta.i18nKey, { defaultValue: meta.fallback[lang] });
}
export function getEventStatusClasses(status: string): string {
return getEventStatusMeta(status)?.classes ?? 'bg-muted text-muted-foreground';
}