Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-03-31 14:39:04 -03:00
parent 8b792e1d44
commit 0bea4173f5
18 changed files with 517 additions and 192 deletions
+6 -4
View File
@@ -1,3 +1,5 @@
const LEARNING_DOMAIN = process.env.NEXT_PUBLIC_LEARNING_DOMAIN || 'learning.norteamericano.com';
const getApiBaseUrl = (defaultPort: string, envVar?: string) => {
if (envVar && envVar.trim() !== '') {
return envVar;
@@ -11,14 +13,14 @@ const getApiBaseUrl = (defaultPort: string, envVar?: string) => {
};
export const getLmsApiUrl = () => {
if (typeof window !== 'undefined' && window.location.hostname === 'learning.norteamericano.com') {
return `${window.location.protocol}//learning.norteamericano.com/lms-api`;
if (typeof window !== 'undefined' && window.location.hostname === LEARNING_DOMAIN) {
return `${window.location.protocol}//${LEARNING_DOMAIN}/lms-api`;
}
return getApiBaseUrl("3002", process.env.NEXT_PUBLIC_LMS_API_URL);
};
export const getCmsApiUrl = () => {
if (typeof window !== 'undefined' && window.location.hostname === 'learning.norteamericano.com') {
return `${window.location.protocol}//learning.norteamericano.com/cms-api`;
if (typeof window !== 'undefined' && window.location.hostname === LEARNING_DOMAIN) {
return `${window.location.protocol}//${LEARNING_DOMAIN}/cms-api`;
}
return getApiBaseUrl("3001", process.env.NEXT_PUBLIC_CMS_API_URL);
};