fix: 품목기준관리 실시간 동기화 수정

- BOM 항목 추가/수정/삭제 시 섹션탭 즉시 반영
- 섹션 복제 시 UI 즉시 업데이트 (null vs undefined 이슈 해결)
- 항목 수정 기능 추가 (useTemplateManagement)
- 실시간 동기화 문서 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
byeongcheolryu
2025-11-27 22:19:50 +09:00
parent b73603822b
commit 65a8510c0b
130 changed files with 11031 additions and 2287 deletions

View File

@@ -27,31 +27,45 @@ export function LoginPage() {
const [showPassword, setShowPassword] = useState(false);
const [rememberMe, setRememberMe] = useState(false);
const [error, setError] = useState("");
const [isChecking, setIsChecking] = useState(true);
// 2025-11-27: isChecking 상태 제거 - 미들웨어에서 인증 체크하므로 불필요
// const [isChecking, setIsChecking] = useState(true);
const [isLoggingIn, setIsLoggingIn] = useState(false); // ✅ 로그인 진행 중 상태
// 이미 로그인된 상태인지 확인 (페이지 로드 시, 뒤로가기 시)
useEffect(() => {
const checkAuth = async () => {
try {
// 🔵 Next.js 내부 API - 쿠키에서 토큰 확인 (PHP 호출 X, 성능 최적화)
const response = await fetch('/api/auth/check');
if (response.ok) {
// 이미 로그인됨 → 대시보드로 리다이렉트 (replace로 히스토리에서 제거)
router.replace('/dashboard');
return;
}
// 인증 안됨 (401) → 현재 페이지 유지
} catch {
// API 호출 실패 → 현재 페이지 유지
} finally {
setIsChecking(false);
}
};
checkAuth();
}, [router]);
/**
* 🚫 2025-11-27: auth/check API 호출 제거
*
* [이전 동작]
* - 로그인 페이지 진입 시 /api/auth/check 호출
* - 이미 로그인된 사용자를 대시보드로 리다이렉트
*
* [제거 이유]
* 1. 미들웨어(middleware.ts)에서 이미 동일한 처리를 함
* - guestOnlyRoutes(/login, /signup)에서 인증된 사용자 → /dashboard 리다이렉트
* 2. 401 응답이 Network 탭에 에러로 표시되어 백엔드 개발자 혼란 유발
* 3. 불필요한 API 호출로 인한 성능 저하
*
* [대체 방안]
* - 미들웨어가 서버 사이드에서 쿠키 체크 후 리다이렉트 처리
* - 클라이언트에서 추가 API 호출 불필요
*
* @see middleware.ts - isGuestOnlyRoute(), checkAuthentication()
*/
// useEffect(() => {
// const checkAuth = async () => {
// try {
// const response = await fetch('/api/auth/check');
// if (response.ok) {
// router.replace('/dashboard');
// return;
// }
// } catch {
// // API 호출 실패 → 현재 페이지 유지
// } finally {
// setIsChecking(false);
// }
// };
// checkAuth();
// }, [router]);
const handleLogin = async () => {
// ✅ 중복 요청 방지
@@ -137,17 +151,17 @@ export function LoginPage() {
};
// 인증 체크 중일 때는 로딩 표시
if (isChecking) {
return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-center">
<div className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent mb-4"></div>
<p className="text-muted-foreground">Loading...</p>
</div>
</div>
);
}
// 2025-11-27: isChecking 로딩 UI 제거 - 미들웨어에서 처리하므로 불필요
// if (isChecking) {
// return (
// <div className="min-h-screen flex items-center justify-center">
// <div className="text-center">
// <div className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent mb-4"></div>
// <p className="text-muted-foreground">Loading...</p>
// </div>
// </div>
// );
// }
return (
<div className="min-h-screen bg-background flex flex-col">