/**
 * Error codes returned by the GraphQL API.
 */
export const ERROR_CODES = {
  MAX_ENROLLMENTS: 'MAX_ENROLLMENTS',
  SAME_PROFESSOR: 'SAME_PROFESSOR',
  STUDENT_NOT_FOUND: 'STUDENT_NOT_FOUND',
  SUBJECT_NOT_FOUND: 'SUBJECT_NOT_FOUND',
  DUPLICATE_ENROLLMENT: 'DUPLICATE_ENROLLMENT',
  VALIDATION_ERROR: 'VALIDATION_ERROR',
  NETWORK_ERROR: 'NETWORK_ERROR',
  SERVER_ERROR: 'SERVER_ERROR',
  UNKNOWN: 'UNKNOWN',
} as const;

export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];

/**
 * User-friendly error messages in Spanish.
 * Maps API error codes to display messages.
 */
export const ERROR_MESSAGES: Record<ErrorCode, string> = {
  [ERROR_CODES.MAX_ENROLLMENTS]: 'Has alcanzado el límite máximo de 3 materias',
  [ERROR_CODES.SAME_PROFESSOR]: 'Ya tienes una materia con este profesor',
  [ERROR_CODES.STUDENT_NOT_FOUND]: 'El estudiante no existe en el sistema',
  [ERROR_CODES.SUBJECT_NOT_FOUND]: 'La materia seleccionada no existe',
  [ERROR_CODES.DUPLICATE_ENROLLMENT]: 'Ya estás inscrito en esta materia',
  [ERROR_CODES.VALIDATION_ERROR]: 'Los datos ingresados no son válidos',
  [ERROR_CODES.NETWORK_ERROR]: 'No se pudo conectar con el servidor',
  [ERROR_CODES.SERVER_ERROR]: 'Error interno del servidor',
  [ERROR_CODES.UNKNOWN]: 'Ha ocurrido un error inesperado',
};

/**
 * Translations for enrollment restriction reasons.
 * Maps API English messages to Spanish display messages.
 */
export const RESTRICTION_TRANSLATIONS: Record<string, string> = {
  'Already enrolled': 'Ya inscrito',
  'Already have a subject with this professor': 'Ya tienes una materia con este profesor',
  'Maximum 3 subjects reached': 'Máximo 3 materias alcanzado',
};
