From fbb3b7f05737f9571b04b0a8f4f15c0928de8545 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 7 Jul 2025 01:43:36 +0000 Subject: (대표님) 변경사항 20250707 10시 43분 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/information/information-button.tsx | 189 +++++++++++++++----------- 1 file changed, 106 insertions(+), 83 deletions(-) (limited to 'components/information') diff --git a/components/information/information-button.tsx b/components/information/information-button.tsx index 38e8cb12..f8707439 100644 --- a/components/information/information-button.tsx +++ b/components/information/information-button.tsx @@ -11,7 +11,7 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog" -import { Info, Download, Edit } from "lucide-react" +import { Info, Download, Edit, Loader2 } from "lucide-react" import { getCachedPageInformation, getCachedEditPermission } from "@/lib/information/service" import { getCachedPageNotices } from "@/lib/notice/service" import { UpdateInformationDialog } from "@/lib/information/table/update-information-dialog" @@ -48,11 +48,13 @@ export function InformationButton({ const [selectedNotice, setSelectedNotice] = useState(null) const [isNoticeViewDialogOpen, setIsNoticeViewDialogOpen] = useState(false) const [dataLoaded, setDataLoaded] = useState(false) + const [isLoading, setIsLoading] = useState(false) // 데이터 로드 함수 (단순화) const loadData = React.useCallback(async () => { if (dataLoaded) return // 이미 로드되었으면 중복 방지 + setIsLoading(true) try { // pagePath 정규화 (앞의 / 제거) const normalizedPath = pagePath.startsWith('/') ? pagePath.slice(1) : pagePath @@ -74,6 +76,8 @@ export function InformationButton({ } } catch (error) { console.error("데이터 로딩 중 오류:", error) + } finally { + setIsLoading(false) } }, [pagePath, session?.user?.id, dataLoaded]) @@ -140,100 +144,119 @@ export function InformationButton({ -
- {/* 공지사항 섹션 */} - {notices.length > 0 && ( -
-
-

공지사항

- {notices.length}개 -
-
-
- {notices.map((notice) => ( -
handleNoticeClick(notice)} - > -
-
- {notice.title} -
-
- {formatDate(notice.createdAt)} - {notice.authorName && ( - {notice.authorName} - )} +
+ {isLoading ? ( +
+ + 정보를 불러오는 중... +
+ ) : ( +
+ {/* 공지사항 섹션 */} +
+
+

공지사항

+ {notices.length > 0 && ( + {notices.length}개 + )} +
+ {notices.length > 0 ? ( +
+
+ {notices.map((notice) => ( +
handleNoticeClick(notice)} + > +
+
+ {notice.title} +
+
+ {formatDate(notice.createdAt)} + {notice.authorName && ( + {notice.authorName} + )} +
+
-
+ ))}
- ))} -
+
+ ) : ( +
+
+ 공지사항이 없습니다 +
+
+ )}
-
- )} - {/* 인포메이션 컨텐츠 */} - {information?.informationContent && ( -
-
-

안내사항

- {hasEditPermission && information && ( - - )} -
-
-
- {information.informationContent} + {/* 인포메이션 컨텐츠 */} +
+
+

안내사항

+ {hasEditPermission && information && ( + + )} +
+
+ {information?.informationContent ? ( +
+ {information.informationContent} +
+ ) : ( +
+ 안내사항이 없습니다 +
+ )}
-
- )} - {/* 첨부파일 */} - {information?.attachmentFileName && ( -
-

첨부파일

-
-
-
-
- {information.attachmentFileName} -
- {information.attachmentFileSize && ( -
- {information.attachmentFileSize} + {/* 첨부파일 */} +
+

첨부파일

+
+ {information?.attachmentFileName ? ( +
+
+
+ {information.attachmentFileName} +
+ {information.attachmentFileSize && ( +
+ {information.attachmentFileSize} +
+ )}
- )} -
- + +
+ ) : ( +
+ 첨부파일이 없습니다 +
+ )}
)} - - {!information && notices.length === 0 && ( -
-

이 페이지에 대한 정보가 없습니다.

-
- )}
-- cgit v1.2.3