This commit applies the modular refactoring to the web-ui,
including the new daily attendance tracking feature.
- **Modular Structure:** Re-introduced the modular files 'config.js',
'component-loader.js', and 'navigation.js' to centralize configuration,
component loading, and navigation logic.
- **Refactored Dashboard:** Refactored 'group-leader-dashboard.js' to use
the new 'apiCall' function from 'api-config.js' for API requests,
removing duplicated code and improving error handling.
- **ES6 Modules:** Updated 'group-leader.html' to load scripts as
ES6 modules ('type="module"'), ensuring compatibility with the
modular JavaScript files.
- **Clean-up:** Removed unnecessary global variables and duplicated
functions, improving code quality and maintainability.
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
// /js/navigation.js
|
|
import { config } from './config.js';
|
|
|
|
/**
|
|
* 지정된 URL로 페이지를 리디렉션합니다.
|
|
* @param {string} url - 이동할 URL
|
|
*/
|
|
function redirect(url) {
|
|
window.location.href = url;
|
|
}
|
|
|
|
/**
|
|
* 로그인 페이지로 리디렉션합니다.
|
|
*/
|
|
export function redirectToLogin() {
|
|
console.log(`🔄 로그인 페이지로 이동합니다: ${config.paths.loginPage}`);
|
|
redirect(config.paths.loginPage);
|
|
}
|
|
|
|
/**
|
|
* 사용자의 기본 대시보드 페이지로 리디렉션합니다.
|
|
* 백엔드가 지정한 URL이 있으면 그곳으로, 없으면 기본 URL로 이동합니다.
|
|
* @param {string} [backendRedirectUrl=null] - 백엔드에서 전달받은 리디렉션 URL
|
|
*/
|
|
export function redirectToDefaultDashboard(backendRedirectUrl = null) {
|
|
const destination = backendRedirectUrl || config.paths.defaultDashboard;
|
|
console.log(`🔄 대시보드로 이동합니다: ${destination}`);
|
|
|
|
// 부드러운 화면 전환 효과
|
|
document.body.style.transition = 'opacity 0.3s ease-out';
|
|
document.body.style.opacity = '0';
|
|
|
|
setTimeout(() => {
|
|
redirect(destination);
|
|
}, 300);
|
|
}
|
|
|
|
/**
|
|
* 시스템 대시보드 페이지로 리디렉션합니다.
|
|
*/
|
|
export function redirectToSystemDashboard() {
|
|
console.log(`🔄 시스템 대시보드로 이동합니다: ${config.paths.systemDashboard}`);
|
|
redirect(config.paths.systemDashboard);
|
|
}
|
|
|
|
/**
|
|
* 그룹 리더 대시보드 페이지로 리디렉션합니다.
|
|
*/
|
|
export function redirectToGroupLeaderDashboard() {
|
|
console.log(`🔄 그룹 리더 대시보드로 이동합니다: ${config.paths.groupLeaderDashboard}`);
|
|
redirect(config.paths.groupLeaderDashboard);
|
|
}
|
|
|
|
// 필요에 따라 더 많은 리디렉션 함수를 추가할 수 있습니다.
|
|
// export function redirectToUserProfile() { ... }
|