1
1
import { useGetPerformanceDetail } from "@apis/domains/performances/queries" ;
2
2
import { ActionBottomSheet , Button , Loading } from "@components/commons" ;
3
3
import OuterLayout from "@components/commons/bottomSheet/OuterLayout" ;
4
+ import MetaTag from "@components/commons/meta/MetaTag" ;
4
5
import { NAVIGATION_STATE } from "@constants/navigationState" ;
5
6
import { useHeader , useLogin } from "@hooks" ;
7
+ import NotFound from "@pages/notFound/NotFound" ;
6
8
import { navigateAtom } from "@stores" ;
7
9
import { requestKakaoLogin } from "@utils/kakaoLogin" ;
8
10
import { useAtom } from "jotai" ;
@@ -12,7 +14,6 @@ import Content from "./components/content/Content";
12
14
import ShowInfo from "./components/showInfo/ShowInfo" ;
13
15
import { SHOW_TYPE_KEY } from "./constants" ;
14
16
import * as S from "./Gig.styled" ;
15
- import MetaTag from "@components/commons/meta/MetaTag" ;
16
17
17
18
const Gig = ( ) => {
18
19
const navigate = useNavigate ( ) ;
@@ -25,12 +26,18 @@ const Gig = () => {
25
26
26
27
const [ isSheetOpen , setIsSheetOpen ] = useState ( false ) ;
27
28
29
+ const nowDate = new Date ( ) ;
30
+ const lastPerformanceDate = new Date (
31
+ data ?. scheduleList [ data ?. scheduleList . length - 1 ] ?. performanceDate
32
+ ) ;
33
+ // 현재 시간이 마지막 공연 시간보다 크면 예매 버튼 비활성화
34
+ const isBookDisabled = nowDate > lastPerformanceDate ;
35
+
28
36
const handleBookClick = ( ) => {
29
37
if ( isLogin ) {
30
38
navigate ( `/book/${ performanceId } ` ) ;
31
39
return ;
32
40
}
33
-
34
41
setIsSheetOpen ( true ) ;
35
42
} ;
36
43
@@ -44,19 +51,25 @@ const Gig = () => {
44
51
} ;
45
52
46
53
useEffect ( ( ) => {
47
- setHeader ( {
48
- headerStyle : NAVIGATION_STATE . ICON_TITLE ,
49
- title : data ?. performanceTitle ,
50
- leftOnClick : ( ) => {
51
- navigate ( "/main" ) ;
52
- } ,
53
- } ) ;
54
+ if ( data ) {
55
+ setHeader ( {
56
+ headerStyle : NAVIGATION_STATE . ICON_TITLE ,
57
+ title : data ?. performanceTitle ,
58
+ leftOnClick : ( ) => {
59
+ navigate ( "/main" ) ;
60
+ } ,
61
+ } ) ;
62
+ }
54
63
} , [ data ] ) ;
55
64
56
65
if ( isLoading ) {
57
66
return < Loading /> ;
58
67
}
59
68
69
+ if ( ! data ) {
70
+ return < NotFound /> ;
71
+ }
72
+
60
73
return (
61
74
< S . ContentWrapper >
62
75
< MetaTag
@@ -86,7 +99,9 @@ const Gig = () => {
86
99
staffList = { data ?. staffList ?? [ ] }
87
100
/>
88
101
< S . FooterContainer >
89
- < Button onClick = { handleBookClick } > 예매하기</ Button >
102
+ < Button onClick = { handleBookClick } disabled = { isBookDisabled } >
103
+ { isBookDisabled ? "종료된 공연은 예매할 수 없습니다." : "예매하기" }
104
+ </ Button >
90
105
</ S . FooterContainer >
91
106
92
107
< ActionBottomSheet
0 commit comments