export const ROLE_OPTIONS = [
  { name: '관리자', value: 'admin' },
  { name: '클럽 관리자', value: 'clubadmin' },
  { name: '일반 사용자', value: 'user' }
];

export const ROLE_LABELS = ROLE_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export function getRoleName(role) {
  return ROLE_LABELS[role] || role;
}

export const GENDER_OPTIONS = [
  { name: '남성', value: 'male' },
  { name: '여성', value: 'female' }
];
export const GENDER_LABELS = GENDER_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export const MEMBER_TYPE_OPTIONS = [
  { name: '정회원', value: 'regular' },
  { name: '준회원', value: 'associate' },
  { name: '게스트', value: 'guest' },
  { name: '운영진', value: 'manager' },
  { name: '모임장', value: 'owner' }
];
export const MEMBER_TYPE_LABELS = MEMBER_TYPE_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export const STATUS_OPTIONS = [
  { name: '활성', value: 'active' },
  { name: '비활성', value: 'inactive' },
  { name: '정지', value: 'suspended' },
  { name: '삭제', value: 'deleted' }
];
export const STATUS_LABELS = STATUS_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export const PARTICIPANT_STATUS_OPTIONS = [
  { name: '참가예정', value: 'pending' },
  { name: '참가확정', value: 'confirmed' },
  { name: '취소', value: 'canceled' }
];
export const PARTICIPANT_STATUS_LABELS = PARTICIPANT_STATUS_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export const EVENT_STATUS_OPTIONS = [
  { name: '준비', value: 'ready' },
  { name: '활성', value: 'active' },
  { name: '완료', value: 'completed' },
  { name: '취소', value: 'canceled' },
  { name: '삭제', value: 'deleted' }
];
export const EVENT_STATUS_LABELS = EVENT_STATUS_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export const EVENT_TYPE_OPTIONS = [
  { name: '정기전', value: 'regular' },
  { name: '교류전', value: 'exchange' },
  { name: '토너먼트', value: 'tournament' },
  { name: '번개', value: 'lightning' },
  { name: '친선전', value: 'friendly' },
  { name: '기타', value: 'other' }
];
export const EVENT_TYPE_LABELS = EVENT_TYPE_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export const PAYMENT_STATUS_OPTIONS = [
  { name: '미납', value: 'unpaid' },
  { name: '납부완료', value: 'paid' }
];
export const PAYMENT_STATUS_LABELS = PAYMENT_STATUS_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);


export const AVERAGE_CALCULATION_PERIOD_OPTIONS = [
  { name: '전체', value: 'total' },
  { name: '최근 1년', value: '1year' },
  { name: '최근 6개월', value: '6month' },
  { name: '최근 3개월', value: '3month' },
  { name: '상반기', value: 'firsthalf' },
  { name: '하반기', value: 'secondhalf' },
  { name: '분기별', value: 'quarterly' }
];
export const AVERAGE_CALCULATION_PERIOD_LABELS = AVERAGE_CALCULATION_PERIOD_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export const CLUB_STATUS_OPTIONS = [
  { name: '활성', value: 'active' },
  { name: '비활성', value: 'inactive' }
];
export const CLUB_STATUS_LABELS = CLUB_STATUS_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);  

export const SUBSCRIPTION_STATUS_OPTIONS = [
  { name: '활성', value: 'active' },
  { name: '만료', value: 'expired' },
  { name: '일시중지', value: 'paused' }
];
export const SUBSCRIPTION_STATUS_LABELS = SUBSCRIPTION_STATUS_OPTIONS.reduce(
  (acc, cur) => ({ ...acc, [cur.value]: cur.name }),
  {}
);

export function getGenderLabel(code) {
  return GENDER_LABELS[code] || code;
}
export function getMemberTypeLabel(code) {
  return MEMBER_TYPE_LABELS[code] || code;
}
export function getStatusLabel(code) {
  return STATUS_LABELS[code] || code;
}

export function getParticipantStatusLabel(code) {
  return PARTICIPANT_STATUS_LABELS[code] || code;
}

export function getEventStatusLabel(code) {
  return EVENT_STATUS_LABELS[code] || code;
}
export function getEventTypeLabel(code) {
  return EVENT_TYPE_LABELS[code] || code;
}

export function getPaymentStatusLabel(code) {
  return PAYMENT_STATUS_LABELS[code] || code;
}

export function getAverageCalculationPeriodLabel(code) {
  return AVERAGE_CALCULATION_PERIOD_LABELS[code] || code;
}

export function getClubStatusLabel(code) {
  return CLUB_STATUS_LABELS[code] || code;
}

export function getSubscriptionStatusLabel(code) {
  return SUBSCRIPTION_STATUS_LABELS[code] || code;
}

export function getMemberTypeSeverity(type) {
  switch (type) {
    case 'regular': return 'success';
    case 'associate': return 'info';
    case 'guest': return 'warning';
    case 'manager': return 'primary';
    case 'owner': return 'danger';
    default: return 'secondary';
  }
}

// 이벤트 유형별 Badge 색상 반환
export function getEventTypeSeverity(type) {
  switch (type) {
    case 'regular': return 'success';
    case 'exchange': return 'primary';
    case 'tournament': return 'warning';
    case 'lightning': return 'info';
    case 'friendly': return 'success';
    case 'other': return 'secondary';
    default: return 'secondary';
  }
}

export function getStatusSeverity(status) {
  switch (status) {
    case 'ready': return 'info';
    case 'active': return 'success';
    case 'completed': return 'primary';
    case 'canceled': return 'danger';
    case 'deleted': return 'secondary';
    default: return 'secondary';
  }
}

export function getPaymentStatusSeverity(status) {
  switch (status) {
    case 'unpaid': return 'danger';
    case 'paid': return 'success';
    case 'pending': return 'warning';
    case 'canceled': return 'danger';
    default: return 'secondary';
  }
}

export function getParticipantStatusSeverity(status) {
  switch (status) {
    case 'pending': return 'info';
    case 'confirmed': return 'success';
    case 'canceled': return 'danger';
    default: return 'secondary';
  }
}

export function getRoleSeverity(role) {
  switch (role) {
    case 'admin': return 'danger';
    case 'clubadmin': return 'warning';
    case 'user': return 'info';
    default: return 'info';
  }
}

export function getClubStatusSeverity(status) {
  switch (status) {
    case 'active': return 'success';
    case 'inactive': return 'danger';
    default: return 'secondary';
  }
}
  
export function getSubscriptionStatusSeverity(status) {
  switch (status) {
    case 'active': return 'success';
    case 'expired': return 'danger';
    case 'paused': return 'warning';
    default: return 'secondary';
  }
}
  