import { colors } from '../theme/colors';

export type NotificationType =
  | 'CLIENT_ASSIGNED'
  | 'SERVICE_BOOKED'
  | 'SERVICE_PAID'
  | 'PACKAGE_TOPUP'
  | 'BOOKING_CANCELLED'
  | 'TRAINING_DEDUCTED'
  | 'TRAININGS_ENDING'
  | 'CLIENT_RETURNED'
  | 'CLIENT_BIRTHDAY';

export interface Notification {
  id: string;
  clubId: string;
  userId: string;
  type: NotificationType;
  title: string;
  body: string;
  data: Record<string, string> | null;
  isRead: boolean;
  sentAt: string;
  createdAt: string;
}

export interface FindNotificationsParams {
  cursor?: string;
  limit?: number;
  isRead?: boolean;
}

export const NOTIFICATION_TYPE_LABELS: Record<NotificationType, string> = {
  CLIENT_ASSIGNED: 'Новый клиент',
  SERVICE_BOOKED: 'Запись на услугу',
  SERVICE_PAID: 'Оплата услуги',
  PACKAGE_TOPUP: 'Доплата пакета',
  BOOKING_CANCELLED: 'Отмена записи',
  TRAINING_DEDUCTED: 'Списание тренировки',
  TRAININGS_ENDING: 'Окончание тренировок',
  CLIENT_RETURNED: 'Возврат клиента',
  CLIENT_BIRTHDAY: 'День рождения',
};

export const NOTIFICATION_TYPE_ICONS: Record<NotificationType, string> = {
  CLIENT_ASSIGNED: 'person-add',
  SERVICE_BOOKED: 'calendar',
  SERVICE_PAID: 'card',
  PACKAGE_TOPUP: 'add-circle',
  BOOKING_CANCELLED: 'close-circle',
  TRAINING_DEDUCTED: 'checkmark-circle',
  TRAININGS_ENDING: 'warning',
  CLIENT_RETURNED: 'return-down-back',
  CLIENT_BIRTHDAY: 'gift',
};

/** Returns notification color from current theme. Call at render time, not module level. */
export function getNotificationTypeColor(type: NotificationType): string {
  const map: Record<NotificationType, string> = {
    CLIENT_ASSIGNED: colors.primary,
    SERVICE_BOOKED: colors.primary,
    SERVICE_PAID: colors.success,
    PACKAGE_TOPUP: colors.success,
    BOOKING_CANCELLED: colors.error,
    TRAINING_DEDUCTED: colors.success,
    TRAININGS_ENDING: colors.warning,
    CLIENT_RETURNED: colors.primary,
    CLIENT_BIRTHDAY: '#9C27B0',
  };
  return map[type];
}
