summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/[lng]/engineering/(engineering)/document-list-ship/page.tsx5
-rw-r--r--app/[lng]/evcp/(evcp)/document-list-ship/page.tsx5
-rw-r--r--app/[lng]/partners/(partners)/document-list-ship/page.tsx5
-rw-r--r--components/information/information-button.tsx96
4 files changed, 73 insertions, 38 deletions
diff --git a/app/[lng]/engineering/(engineering)/document-list-ship/page.tsx b/app/[lng]/engineering/(engineering)/document-list-ship/page.tsx
index 321ce909..e3915419 100644
--- a/app/[lng]/engineering/(engineering)/document-list-ship/page.tsx
+++ b/app/[lng]/engineering/(engineering)/document-list-ship/page.tsx
@@ -37,7 +37,7 @@ export default async function IndexPage(props: IndexPageProps) {
<h2 className="text-2xl font-bold tracking-tight">
문서 관리
</h2>
- <InformationButton pagePath="partners/document-list-ship" />
+
</div>
{/* <p className="text-muted-foreground">
소속 회사의 모든 도서/도면을 확인하고 관리합니다.
@@ -107,9 +107,12 @@ export default async function IndexPage(props: IndexPageProps) {
<Shell className="gap-2">
<div className="flex items-center justify-between space-y-2">
<div>
+ <div className="flex items-center gap-2">
<h2 className="text-2xl font-bold tracking-tight">
조선 Document Management
</h2>
+ <InformationButton pagePath="evcp/document-list-ship" />
+ </div>
<p className="text-muted-foreground">
</p>
diff --git a/app/[lng]/evcp/(evcp)/document-list-ship/page.tsx b/app/[lng]/evcp/(evcp)/document-list-ship/page.tsx
index 321ce909..822e7cd4 100644
--- a/app/[lng]/evcp/(evcp)/document-list-ship/page.tsx
+++ b/app/[lng]/evcp/(evcp)/document-list-ship/page.tsx
@@ -37,7 +37,6 @@ export default async function IndexPage(props: IndexPageProps) {
<h2 className="text-2xl font-bold tracking-tight">
문서 관리
</h2>
- <InformationButton pagePath="partners/document-list-ship" />
</div>
{/* <p className="text-muted-foreground">
소속 회사의 모든 도서/도면을 확인하고 관리합니다.
@@ -107,9 +106,13 @@ export default async function IndexPage(props: IndexPageProps) {
<Shell className="gap-2">
<div className="flex items-center justify-between space-y-2">
<div>
+ <div className="flex items-center gap-2">
<h2 className="text-2xl font-bold tracking-tight">
조선 Document Management
</h2>
+ <InformationButton pagePath="evcp/document-list-ship" />
+ </div>
+
<p className="text-muted-foreground">
</p>
diff --git a/app/[lng]/partners/(partners)/document-list-ship/page.tsx b/app/[lng]/partners/(partners)/document-list-ship/page.tsx
index ad3bf30d..c70a0c03 100644
--- a/app/[lng]/partners/(partners)/document-list-ship/page.tsx
+++ b/app/[lng]/partners/(partners)/document-list-ship/page.tsx
@@ -36,7 +36,6 @@ export default async function IndexPage(props: IndexPageProps) {
<h2 className="text-2xl font-bold tracking-tight">
문서 관리
</h2>
- <InformationButton pagePath="partners/document-list-ship" />
</div>
{/* <p className="text-muted-foreground">
소속 회사의 모든 도서/도면을 확인하고 관리합니다.
@@ -108,9 +107,13 @@ export default async function IndexPage(props: IndexPageProps) {
<Shell className="gap-2">
<div className="flex items-center justify-between space-y-2">
<div>
+ <div className="flex items-center gap-2">
<h2 className="text-2xl font-bold tracking-tight">
{vendorName} Document Management
</h2>
+ <InformationButton pagePath="partners/document-list-ship" />
+ </div>
+
<p className="text-muted-foreground">
</p>
diff --git a/components/information/information-button.tsx b/components/information/information-button.tsx
index 17f10502..69cbb106 100644
--- a/components/information/information-button.tsx
+++ b/components/information/information-button.tsx
@@ -50,61 +50,87 @@ export function InformationButton({
const [isNoticeViewDialogOpen, setIsNoticeViewDialogOpen] = useState(false)
const [dataLoaded, setDataLoaded] = useState(false)
const [isLoading, setIsLoading] = useState(false)
+ const [retryCount, setRetryCount] = useState(0)
- // 데이터 로드 함수 (단순화)
+ // 데이터 로드 함수
const loadData = React.useCallback(async () => {
- if (dataLoaded) return // 이미 로드되었으면 중복 방지
+ if (dataLoaded) return
setIsLoading(true)
try {
- // pagePath 정규화 (앞의 / 제거)
- const normalizedPath = pagePath.startsWith('/') ? pagePath.slice(1) : pagePath
-
- console.log('🔍 Information Button - 데이터 로딩:', {
- originalPath: pagePath,
- normalizedPath: normalizedPath,
- sessionUserId: session?.user?.id
- })
+ // 경로 정규화 - 더 안전한 방식
+ let normalizedPath = pagePath
+ if (normalizedPath.startsWith('/')) {
+ normalizedPath = normalizedPath.slice(1)
+ }
+ // 빈 문자열이면 기본값 설정
+ if (!normalizedPath) {
+ normalizedPath = 'home'
+ }
- // 병렬로 데이터 조회
- const [infoResult, noticesResult] = await Promise.all([
- getPageInformationDirect(normalizedPath),
- getPageNotices(normalizedPath)
- ])
+ // 약간의 지연 추가 (프로덕션에서 DB 연결 안정성)
+ if (retryCount > 0) {
+ await new Promise(resolve => setTimeout(resolve, 500 * retryCount))
+ }
- console.log('📊 조회 결과:', {
- infoResult: infoResult ? {
- id: infoResult.id,
- pagePath: infoResult.pagePath,
- pageName: infoResult.pageName,
- attachmentsCount: infoResult.attachments?.length || 0
- } : null,
- noticesCount: noticesResult.length
- })
+ // 순차적으로 데이터 조회 (프로덕션 안정성)
+ const infoResult = await getPageInformationDirect(normalizedPath)
+ const noticesResult = await getPageNotices(normalizedPath)
setInformation(infoResult)
setNotices(noticesResult)
setDataLoaded(true)
+ setRetryCount(0) // 성공시 재시도 횟수 리셋
- // 권한 확인
- if (session?.user?.id) {
- const hasPermission = await getEditPermissionDirect(normalizedPath, session.user.id)
- setHasEditPermission(hasPermission)
+ // 권한 확인 - 세션이 확실히 있을 때만
+ if (session?.user?.id && infoResult) {
+ try {
+ const hasPermission = await getEditPermissionDirect(normalizedPath, session.user.id)
+ setHasEditPermission(hasPermission)
+ } catch (permError) {
+ setHasEditPermission(false)
+ }
}
} catch (error) {
- console.error("데이터 로딩 중 오류:", error)
+ // 재시도 로직
+ if (retryCount < 2) {
+ setRetryCount(prev => prev + 1)
+ setIsLoading(false)
+ return
+ }
+
+ // 최대 재시도 후 기본값 설정
+ setInformation(null)
+ setNotices([])
+ setHasEditPermission(false)
+ setDataLoaded(true)
+ setRetryCount(0)
} finally {
setIsLoading(false)
}
- }, [pagePath, session?.user?.id, dataLoaded])
+ }, [pagePath, session?.user?.id, dataLoaded, retryCount])
+
+ // 세션이 준비되면 자동으로 데이터 로드
+ React.useEffect(() => {
+ if (isOpen && !dataLoaded && session !== undefined) {
+ loadData()
+ }
+ }, [isOpen, dataLoaded, session])
+
+ // 재시도 처리
+ React.useEffect(() => {
+ if (retryCount > 0 && retryCount <= 2) {
+ const timer = setTimeout(() => {
+ setDataLoaded(false) // 재시도를 위해 리셋
+ }, 500 * retryCount)
+ return () => clearTimeout(timer)
+ }
+ }, [retryCount])
// 다이얼로그 열기
const handleDialogOpen = (open: boolean) => {
setIsOpen(open)
-
- if (open && !dataLoaded) {
- loadData()
- }
+ // useEffect에서 데이터 로딩 처리하므로 여기서는 제거
}
// 편집 관련 핸들러
@@ -116,7 +142,7 @@ export function InformationButton({
setIsEditDialogOpen(false)
// 편집 후 데이터 다시 로드
setDataLoaded(false)
- loadData()
+ setRetryCount(0)
}
// 공지사항 클릭 핸들러