blob: 46517cbc22730fce82a7d9bcd2d60b0a3a167e9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
"use client"
import { usePathname } from "next/navigation"
import { useEffect, useState } from "react"
export function DynamicTitleClient() {
const pathname = usePathname()
const [currentTitle, setCurrentTitle] = useState<string>("")
const [isLoading, setIsLoading] = useState(true)
useEffect(() => {
// 로딩 상태를 true로 설정
setIsLoading(true)
// 약간의 지연 후 제목 설정 (로딩 효과 방지)
const timer = setTimeout(() => {
let title = ""
if (pathname?.includes("/document-class")) {
title = "Document Class 관리"
} else if (pathname?.includes("/code-groups")) {
title = "Code Group 정의"
} else if (pathname?.includes("/combo-box-settings")) {
title = "Combo Box 설정"
} else if (pathname?.includes("/number-types")) {
title = "Number Type 관리"
} else if (pathname?.includes("/number-type-configs")) {
title = "Number Type별 설정"
} else {
title = "Document Numbering Rule (해양)"
}
setCurrentTitle(title)
setIsLoading(false)
}, 100) // 100ms 지연
return () => clearTimeout(timer)
}, [pathname])
// 로딩 중에는 아무것도 표시하지 않음
if (isLoading) {
return <div className="space-y-0.5">
<h2 className="text-2xl font-bold tracking-tight"> </h2>
</div>
}
return (
<div className="space-y-0.5">
<h2 className="text-2xl font-bold tracking-tight">{currentTitle}</h2>
</div>
)
}
|