diff options
Diffstat (limited to 'components')
| -rw-r--r-- | components/layout/Header.tsx | 19 | ||||
| -rw-r--r-- | components/ship-vendor-document/new-revision-dialog.tsx | 41 | ||||
| -rw-r--r-- | components/ship-vendor-document/user-vendor-document-table-container.tsx | 20 |
3 files changed, 52 insertions, 28 deletions
diff --git a/components/layout/Header.tsx b/components/layout/Header.tsx index b12c673c..b70749c7 100644 --- a/components/layout/Header.tsx +++ b/components/layout/Header.tsx @@ -53,7 +53,8 @@ const HIDDEN_MENU_SECTION_KEYS = [ "menu.vendor.procurement.title", ]; -const HIDDEN_ADDITIONAL_MENU_KEYS = [ +// partners 도메인에서만 숨길 추가 메뉴 키 목록 +const HIDDEN_ADDITIONAL_MENU_KEYS_PARTNERS = [ "menu.additional.system_settings", ]; @@ -72,15 +73,22 @@ const filterMenusByEnvironment = (sections: MenuSection[]): MenuSection[] => { /** * 환경변수에 따라 추가 메뉴 항목을 필터링하는 함수 + * @param items 필터링할 메뉴 항목 배열 + * @param isPartners partners 도메인 여부 */ -const filterAdditionalMenusByEnvironment = (items: MenuItem[]): MenuItem[] => { +const filterAdditionalMenusByEnvironment = (items: MenuItem[], isPartners: boolean): MenuItem[] => { const shouldHideMenus = process.env.NEXT_PUBLIC_HIDE_PARTNERS_MENU_BEFORE_OPEN === 'true'; if (!shouldHideMenus) { return items; } - return items.filter(item => !HIDDEN_ADDITIONAL_MENU_KEYS.includes(item.titleKey)); + // partners 도메인일 때만 system_settings 필터링 + if (isPartners) { + return items.filter(item => !HIDDEN_ADDITIONAL_MENU_KEYS_PARTNERS.includes(item.titleKey)); + } + + return items; }; export function Header() { @@ -168,9 +176,12 @@ export function Header() { const { main: originalMain, additional: originalAdditional, logoHref, brandNameKey, basePath } = getDomainConfig(pathname); + // partners 도메인 여부 확인 + const isPartners = pathname?.includes("/partners") ?? false; + // 1단계: 환경변수에 따른 메뉴 필터링 const envFilteredMain = filterMenusByEnvironment(originalMain); - const envFilteredAdditional = filterAdditionalMenusByEnvironment(originalAdditional); + const envFilteredAdditional = filterAdditionalMenusByEnvironment(originalAdditional, isPartners); // 2단계: 활성 메뉴만 필터링 (로딩 중이거나 에러 시에는 환경변수 필터링만 적용) const main = isLoading ? envFilteredMain : filterActiveMenus(envFilteredMain, activeMenus); diff --git a/components/ship-vendor-document/new-revision-dialog.tsx b/components/ship-vendor-document/new-revision-dialog.tsx index bdbb1bc6..39025fa4 100644 --- a/components/ship-vendor-document/new-revision-dialog.tsx +++ b/components/ship-vendor-document/new-revision-dialog.tsx @@ -248,6 +248,14 @@ export function NewRevisionDialog({ // Serial No 조회 const fetchNextSerialNo = React.useCallback(async () => { console.log('🔍 fetchNextSerialNo called with documentId:', documentId) + + // documentId 유효성 검사 + if (!documentId || documentId === undefined || documentId === null) { + console.warn('⚠️ Invalid documentId, using default serialNo: 1') + setNextSerialNo("1") + return + } + setIsLoadingSerialNo(true) try { const apiUrl = `/api/revisions/max-serial-no?documentId=${documentId}` @@ -267,11 +275,16 @@ export function NewRevisionDialog({ setNextSerialNo(serialNoString) console.log('🔍 nextSerialNo state updated') } else { - console.error('🔍 API call failed with status:', response.status) + const errorData = await response.json().catch(() => ({})) + console.error('🔍 API call failed with status:', response.status, errorData) + // API 실패 시 기본값 1 사용 + console.warn('⚠️ Using default serialNo: 1') + setNextSerialNo("1") } } catch (error) { console.error('❌ Failed to fetch serial no:', error) // 에러 시 기본값 1 사용 + console.warn('⚠️ Using default serialNo: 1 due to error') setNextSerialNo("1") } finally { setIsLoadingSerialNo(false) @@ -280,12 +293,15 @@ export function NewRevisionDialog({ // Dialog 열릴 때 Serial No 조회 React.useEffect(() => { - console.log('🎯 useEffect triggered - open:', open, 'documentId:', documentId) - if (open && documentId) { - console.log('🎯 Calling fetchNextSerialNo') - fetchNextSerialNo() - } else { - console.log('🎯 Conditions not met for fetchNextSerialNo') + console.log('🎯 useEffect triggered - open:', open, 'documentId:', documentId, 'type:', typeof documentId) + if (open) { + if (documentId && typeof documentId === 'number' && documentId > 0) { + console.log('🎯 Calling fetchNextSerialNo') + fetchNextSerialNo() + } else { + console.warn('🎯 Invalid documentId, using default serialNo: 1') + setNextSerialNo("1") + } } }, [open, documentId, fetchNextSerialNo]) @@ -475,17 +491,12 @@ export function NewRevisionDialog({ <DialogDescription className="text-sm space-y-1"> <div>Document: {documentTitle}</div> <div className="text-xs text-muted-foreground"> - Drawing Type: {drawingKind} | Serial No: {nextSerialNo} - {isLoadingSerialNo && ( + Drawing Type: {drawingKind} | Serial No: {isLoadingSerialNo ? ( <> - <Loader2 className="inline-block ml-2 h-3 w-3 animate-spin" /> + <Loader2 className="inline-block ml-1 h-3 w-3 animate-spin" /> <span className="ml-1">Loading...</span> </> - )} - {/* 디버그용 임시 표시 */} - <div className="mt-1 text-xs text-orange-600"> - Debug: nextSerialNo={nextSerialNo}, isLoading={isLoadingSerialNo} - </div> + ) : nextSerialNo} </div> </DialogDescription> )} diff --git a/components/ship-vendor-document/user-vendor-document-table-container.tsx b/components/ship-vendor-document/user-vendor-document-table-container.tsx index 0c3390d1..1670732a 100644 --- a/components/ship-vendor-document/user-vendor-document-table-container.tsx +++ b/components/ship-vendor-document/user-vendor-document-table-container.tsx @@ -833,7 +833,7 @@ function SubTables() { const handleDownloadFile = React.useCallback(async (attachment: AttachmentInfo) => { try { // 파일 경로 처리 - let downloadPath = attachment.filePath + const downloadPath = attachment.filePath // 공용 다운로드 함수 사용 (보안 검증, 파일 체크 모두 포함) const result = await downloadFile(downloadPath, attachment.fileName, { @@ -1240,14 +1240,16 @@ function SubTables() { </DialogContent> </Dialog> - <NewRevisionDialog - open={newRevisionDialogOpen} - onOpenChange={setNewRevisionDialogOpen} - documentId={selectedDocument.documentId} - documentTitle={selectedDocument.title} - drawingKind={selectedDocument.drawingKind || 'B4'} - onSuccess={handleRevisionUploadSuccess} - /> + {selectedDocument && ( + <NewRevisionDialog + open={newRevisionDialogOpen} + onOpenChange={setNewRevisionDialogOpen} + documentId={selectedDocument.documentId} + documentTitle={selectedDocument.title} + drawingKind={selectedDocument.drawingKind || 'B4'} + onSuccess={handleRevisionUploadSuccess} + /> + )} {/* ✅ 리비전 수정 다이얼로그 */} <EditRevisionDialog |
