import { RIGHTS } from '@/utils/rights';
export const BASE_URL = process.env.NEXT_PUBLIC_API_URL;
export const WS_BASE_URL = process.env.NEXT_PUBLIC_WSAPI_URL;

//URL-Back-End

// GESTION LOGIN
export const BE_AUTH_NEW_PASSWORD_URL = `${BASE_URL}/Auth/newPassword`;
export const BE_AUTH_REGISTER_URL = `${BASE_URL}/Auth/subscribe`;
export const BE_AUTH_RESET_PASSWORD_URL = `${BASE_URL}/Auth/resetPassword`;
export const BE_AUTH_LOGIN_URL = `${BASE_URL}/Auth/login`;
export const BE_AUTH_REFRESH_JWT_URL = `${BASE_URL}/Auth/refreshJWT`;
export const BE_AUTH_LOGOUT_URL = `${BASE_URL}/Auth/logout`;
export const BE_AUTH_PROFILES_URL = `${BASE_URL}/Auth/profiles`;
export const BE_AUTH_PROFILES_ROLES_URL = `${BASE_URL}/Auth/profileRoles`;
export const BE_AUTH_CSRF_URL = `${BASE_URL}/Auth/csrf`;
export const BE_AUTH_INFO_SESSION = `${BASE_URL}/Auth/infoSession`;

// GESTION INSCRIPTION
export const BE_SUBSCRIPTION_STUDENTS_URL = `${BASE_URL}/Subscriptions/students`; // Récupère la liste des élèves inscrits ou en cours d'inscriptions
export const BE_SUBSCRIPTION_SEARCH_STUDENTS_URL = `${BASE_URL}/Subscriptions/search-students`;
export const BE_SUBSCRIPTION_CHILDRENS_URL = `${BASE_URL}/Subscriptions/children`; // Récupère la liste des élèves d'un profil
export const BE_SUBSCRIPTION_REGISTERFORMS_URL = `${BASE_URL}/Subscriptions/registerForms`;
export const BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL = `${BASE_URL}/Subscriptions/registrationFileGroups`;
export const BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_MASTERS_URL = `${BASE_URL}/Subscriptions/registrationSchoolFileMasters`;
export const BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_TEMPLATES_URL = `${BASE_URL}/Subscriptions/registrationSchoolFileTemplates`;
export const BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_MASTERS_URL = `${BASE_URL}/Subscriptions/registrationParentFileMasters`;
export const BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_TEMPLATES_URL = `${BASE_URL}/Subscriptions/registrationParentFileTemplates`;
export const BE_SUBSCRIPTION_LAST_GUARDIAN_ID_URL = `${BASE_URL}/Subscriptions/lastGuardianId`;
export const BE_SUBSCRIPTION_ABSENCES_URL = `${BASE_URL}/Subscriptions/absences`;
export const BE_SUBSCRIPTION_STUDENT_COMPETENCIES_URL = `${BASE_URL}/Subscriptions/studentCompetencies`;

//GESTION ECOLE
export const BE_SCHOOL_SPECIALITIES_URL = `${BASE_URL}/School/specialities`;
export const BE_SCHOOL_SCHOOLCLASSES_URL = `${BASE_URL}/School/schoolClasses`;
export const BE_SCHOOL_TEACHERS_URL = `${BASE_URL}/School/teachers`;
export const BE_SCHOOL_PLANNINGS_URL = `${BASE_URL}/School/plannings`;
export const BE_SCHOOL_FEES_URL = `${BASE_URL}/School/fees`;
export const BE_SCHOOL_DISCOUNTS_URL = `${BASE_URL}/School/discounts`;
export const BE_SCHOOL_PAYMENT_PLANS_URL = `${BASE_URL}/School/paymentPlans`;
export const BE_SCHOOL_PAYMENT_MODES_URL = `${BASE_URL}/School/paymentModes`;
export const BE_SCHOOL_ESTABLISHMENT_COMPETENCIES_URL = `${BASE_URL}/School/establishmentCompetencies`;
export const BE_SCHOOL_EVALUATIONS_URL = `${BASE_URL}/School/evaluations`;
export const BE_SCHOOL_STUDENT_EVALUATIONS_URL = `${BASE_URL}/School/studentEvaluations`;
export const BE_SCHOOL_SCHOOL_YEARS_URL = `${BASE_URL}/School/schoolYears`;

// ESTABLISHMENT
export const BE_SCHOOL_ESTABLISHMENT_URL = `${BASE_URL}/Establishment/establishments`;

// GESTION PLANNING
export const BE_PLANNING_PLANNINGS_URL = `${BASE_URL}/Planning/plannings`;
export const BE_PLANNING_EVENTS_URL = `${BASE_URL}/Planning/events`;

// GESTION EMAIL
export const BE_GESTIONEMAIL_SEND_EMAIL_URL = `${BASE_URL}/GestionEmail/send-email/`;
export const BE_GESTIONEMAIL_SEARCH_RECIPIENTS_URL = `${BASE_URL}/GestionEmail/search-recipients`;
export const BE_GESTIONEMAIL_SEND_FEEDBACK_URL = `${BASE_URL}/GestionEmail/send-feedback/`;

// GESTION MESSAGERIE
export const BE_GESTIONMESSAGERIE_CONVERSATIONS_URL = `${BASE_URL}/GestionMessagerie/conversations`;
export const BE_GESTIONMESSAGERIE_CONVERSATION_MESSAGES_URL = `${BASE_URL}/GestionMessagerie/conversations/messages`;
export const BE_GESTIONMESSAGERIE_MARK_AS_READ_URL = `${BASE_URL}/GestionMessagerie/conversations/mark-as-read`;
export const BE_GESTIONMESSAGERIE_DELETE_CONVERSATION_URL = `${BASE_URL}/GestionMessagerie/conversations`;
export const BE_GESTIONMESSAGERIE_MESSAGES_URL = `${BASE_URL}/GestionMessagerie/messages`;
export const BE_GESTIONMESSAGERIE_SEND_MESSAGE_URL = `${BASE_URL}/GestionMessagerie/send-message`;
export const BE_GESTIONMESSAGERIE_CREATE_CONVERSATION_URL = `${BASE_URL}/GestionMessagerie/create-conversation/`;
export const BE_GESTIONMESSAGERIE_SEARCH_RECIPIENTS_URL = `${BASE_URL}/GestionMessagerie/search-recipients`;
export const BE_GESTIONMESSAGERIE_UPLOAD_FILE_URL = `${BASE_URL}/GestionMessagerie/upload-file/`;

// WEBSOCKET MESSAGERIE
export const WS_CHAT_URL = (userId) => {
  return `${WS_BASE_URL}/ws/chat/${userId}/`;
};

// SETTINGS
export const BE_SETTINGS_SMTP_URL = `${BASE_URL}/Settings/smtp-settings`;

// URL FRONT-END
export const FE_HOME_URL = '/';

// USERS
export const FE_USERS_LOGIN_URL = '/users/login';
export const FE_USERS_SUBSCRIBE_URL = '/users/subscribe';
export const FE_USERS_RESET_PASSWORD_URL = '/users/password/reset';
export const FE_USERS_NEW_PASSWORD_URL = '/users/password/new';

// ADMIN
export const FE_ADMIN_HOME_URL = '/admin';

// ADMIN/SUBSCRIPTIONS URL
export const FE_ADMIN_SUBSCRIPTIONS_URL = '/admin/subscriptions';
export const FE_ADMIN_SUBSCRIPTIONS_CREATE_URL =
  '/admin/subscriptions/createSubscription';
export const FE_ADMIN_SUBSCRIPTIONS_EDIT_URL =
  '/admin/subscriptions/editSubscription';
export const FE_ADMIN_SUBSCRIPTIONS_VALIDATE_URL =
  '/admin/subscriptions/validateSubscription';

//ADMIN/CLASSES URL
export const FE_ADMIN_CLASSES_URL = '/admin/classes';

//ADMIN/STRUCTURE URL
export const FE_ADMIN_STRUCTURE_URL = '/admin/structure';
export const FE_ADMIN_STRUCTURE_SCHOOLCLASS_MANAGEMENT_URL =
  '/admin/structure/SchoolClassManagement';
export const FE_ADMIN_STRUCTURE_FORM_BUILDER_URL =
  '/admin/structure/FormBuilder';

//ADMIN/DIRECTORY URL
export const FE_ADMIN_DIRECTORY_URL = '/admin/directory';

//ADMIN/GRADES URL
export const FE_ADMIN_GRADES_URL = '/admin/grades';
export const FE_ADMIN_GRADES_STUDENT_COMPETENCIES_URL =
  '/admin/grades/studentCompetencies';

//ADMIN/TEACHERS URL
export const FE_ADMIN_TEACHERS_URL = '/admin/teachers';

//ADMIN/PLANNING URL
export const FE_ADMIN_PLANNING_URL = '/admin/planning';

//ADMIN/SETTINGS URL
export const FE_ADMIN_SETTINGS_URL = '/admin/settings';

//ADMIN/MESSAGERIE URL
export const FE_ADMIN_MESSAGERIE_URL = '/admin/messagerie';

//ADMIN/FEEDBACK URL
export const FE_ADMIN_FEEDBACK_URL = '/admin/feedback';

// PARENT HOME
export const FE_PARENTS_HOME_URL = '/parents';
export const FE_PARENTS_MESSAGERIE_URL = '/parents/messagerie';
export const FE_PARENTS_EDIT_SUBSCRIPTION_URL = '/parents/editSubscription';

/**
 * Fonction pour obtenir l'URL de redirection en fonction du rôle
 * @param {RIGHTS} role
 * @returns {string|null} L'URL de redirection ou null si le rôle n'est pas géré
 */
export function getRedirectUrlFromRole(role) {
  switch (role) {
    case RIGHTS.ADMIN:
      return FE_ADMIN_HOME_URL;
    case RIGHTS.TEACHER:
      return FE_ADMIN_HOME_URL;
    case RIGHTS.PARENT:
      return FE_PARENTS_HOME_URL;
    default:
      return '';
  }
}
