// 게시판 상태 타입
export type BoardStatus = 'active' | 'inactive';

// 대상 타입 (전사, 부서, 권한)
export type BoardTarget = 'all' | 'department' | 'permission';

// 게시판 타입 (프론트엔드용)
export interface Board {
  id: string;
  boardCode: string;
  boardType?: string;
  target: BoardTarget;
  targetId?: number;
  targetName?: string; // 부서명 (target이 department일 때)
  permissions?: string[]; // 권한 코드 목록 (target이 permission일 때)
  boardName: string;
  description?: string;
  status: BoardStatus;
  isSystem: boolean;
  authorId: string;
  authorName: string;
  createdAt: string;
  updatedAt: string;
}

// ============================================================
// API 응답 타입
// ============================================================

// API extra_settings 구조
export interface BoardExtraSettings {
  target?: BoardTarget;
  target_id?: number;
  target_name?: string;
  permissions?: {
    read?: string[];
    write?: string[];
    manage?: string[];
  };
  [key: string]: unknown;
}

// API 게시판 응답 타입
export interface BoardApiData {
  id: number;
  tenant_id: number | null;
  is_system: boolean;
  board_type: string | null;
  board_code: string;
  name: string;
  description: string | null;
  editor_type: string;
  allow_files: boolean;
  max_file_count: number;
  max_file_size: number;
  extra_settings: BoardExtraSettings | null;
  is_active: boolean;
  created_by: number | null;
  updated_by: number | null;
  created_at: string;
  updated_at: string;
  deleted_at: string | null;
  creator?: {
    id: number;
    name: string;
  };
}

// 게시판 폼 데이터 타입
export interface BoardFormData {
  target: BoardTarget;
  targetName?: string;
  permissions?: string[]; // 권한 코드 목록 (target이 permission일 때)
  boardName: string;
  status: BoardStatus;
}

// 상태 라벨
export const BOARD_STATUS_LABELS: Record<BoardStatus, string> = {
  active: '사용함',
  inactive: '사용안함',
};

// 상태 색상
export const BOARD_STATUS_COLORS: Record<BoardStatus, string> = {
  active: 'bg-green-100 text-green-800 hover:bg-green-100',
  inactive: 'bg-gray-100 text-gray-800 hover:bg-gray-100',
};

// 대상 라벨
export const BOARD_TARGET_LABELS: Record<BoardTarget, string> = {
  all: '전사',
  department: '부서',
  permission: '권한',
};

// 대상 옵션
export const BOARD_TARGETS = [
  { value: 'all' as BoardTarget, label: '전사' },
  { value: 'department' as BoardTarget, label: '부서' },
  { value: 'permission' as BoardTarget, label: '권한' },
];
