feat(frontend): add centralized constants for enrollment limits

- Create enrollment.constants.ts with MAX_SUBJECTS, MAX_CREDITS, CREDITS_PER_SUBJECT
- Create error-messages.constants.ts with ERROR_CODES and RESTRICTION_TRANSLATIONS
- Remove empty folders: core/state, shared/directives, features/dashboard
- Use 'as const' for type-safe constants

This improves maintainability by having a single source of truth for business rules.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Andrés Eduardo García Márquez 2026-01-08 00:30:09 -05:00
parent 0f3984b8c9
commit 6201adb093
3 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,15 @@
/**
* Enrollment business rules constants.
* These values must match the backend domain rules.
*/
export const ENROLLMENT_LIMITS = {
/** Maximum number of subjects a student can enroll in */
MAX_SUBJECTS: 3,
/** Maximum total credits a student can have */
MAX_CREDITS: 9,
/** Credits per subject (fixed value) */
CREDITS_PER_SUBJECT: 3,
} as const;
/** Type for enrollment limits to ensure type safety */
export type EnrollmentLimits = typeof ENROLLMENT_LIMITS;

View File

@ -0,0 +1,42 @@
/**
* 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',
};

View File

@ -0,0 +1,2 @@
export * from './enrollment.constants';
export * from './error-messages.constants';