1- 'use client' ;
2-
3- import { useQuery } from '@tanstack/react-query' ;
4- import dynamic from 'next/dynamic' ;
5- import { notFound } from 'next/navigation' ;
6- import { useEffect } from 'react' ;
7-
1+ import CleanUp from '@/features/activityId/components/cleanup' ;
82import Header from '@/features/activityId/components/header' ;
93import AddressWithMap from '@/features/activityId/components/map/address-with-map' ;
4+ import ReservationModal from '@/features/activityId/components/reservation-modal' ;
5+ import ReviewsWrapper from '@/features/activityId/components/reviews-wrapper' ;
106import SubImages from '@/features/activityId/components/sub-images' ;
11- import { getActivityId } from '@/features/activityId/libs/api/getActivityId' ;
127import { textStyle } from '@/features/activityId/libs/constants/variants' ;
13- import { useCalendarStore } from '@/shared/components/calendar/libs/stores/useCalendarStore' ;
14- import LoadingSpinner from '@/shared/components/loading-spinner/loading-spinner' ;
15- import { useModalStore } from '@/shared/components/modal/libs/stores/useModalStore' ;
16- import { cn } from '@/shared/libs/cn' ;
17- const ReservationModal = dynamic (
18- ( ) => import ( '@/features/activityId/components/reservation-modal' ) ,
19- {
20- ssr : false ,
21- loading : ( ) => < LoadingSpinner /> ,
22- } ,
23- ) ;
24- const Reviews = dynamic (
25- ( ) => import ( '@/features/activityId/components/reviews' ) ,
26- {
27- ssr : false ,
28- loading : ( ) => < LoadingSpinner /> ,
29- } ,
30- ) ;
31-
32- const ActivityPageContent = ( { id } : { id : string } ) => {
33- const { closeModal } = useModalStore ( ) ;
34- const { setYear, setMonth, resetSelectedDate, resetDate } =
35- useCalendarStore ( ) ;
36-
37- const { data, isLoading, isError } = useQuery ( {
38- queryKey : [ 'activityId' , id ] ,
39- queryFn : ( ) => getActivityId ( id ) ,
40- staleTime : 1000 * 60 * 30 ,
41- } ) ;
42-
43- // notfound 페이지로 에러처리
44- if ( isError ) {
45- notFound ( ) ;
46- }
47-
48- // 언마운트 시 클린업
49- useEffect ( ( ) => {
50- return ( ) => {
51- // 모달 닫기
52- closeModal ( ) ;
53- // 캘린더 리셋
54- const today = new Date ( ) ;
55- setYear ( today . getFullYear ( ) ) ;
56- setMonth ( today . getMonth ( ) ) ;
57- resetSelectedDate ( ) ;
58- resetDate ( ) ;
59- } ;
60- } , [ closeModal , setMonth , setYear , resetDate , resetSelectedDate ] ) ;
61-
62- if ( isLoading || ! data ) return < LoadingSpinner /> ;
63-
8+ import { ActivityInfo } from '@/features/activityId/libs/types/activityInfo' ;
9+
10+ const ActivityPageContent = ( {
11+ id,
12+ data,
13+ } : {
14+ id : string ;
15+ data : ActivityInfo ;
16+ } ) => {
6417 return (
6518 < div className = "mx-auto w-full justify-center p-[2.4rem] md:px-[4rem] lg:max-w-[120rem] lg:pt-[1.6rem]" >
6619 { /* 체험 이미지 */ }
6720 < SubImages images = { data ?. subImages } />
68- < div className = { cn ( 'lg:grid lg:grid-cols-[1fr_41.9rem] lg:gap-[4rem]' ) } >
21+ < div className = { 'lg:grid lg:grid-cols-[1fr_41.9rem] lg:gap-[4rem]' } >
6922 < div >
7023 { /* 헤더 영역(분류, 제목, 별점, 주소, 드롭다운) */ }
71- < Header data = { data } />
24+ < Header data = { data } id = { id } />
7225 { /* 체험 설명 */ }
7326 < hr className = "mt-[2rem] mb-[2rem]" />
7427 < section >
@@ -80,11 +33,12 @@ const ActivityPageContent = ({ id }: { id: string }) => {
8033 < AddressWithMap address = { data ?. address } />
8134 { /* 체험 후기 */ }
8235 < hr className = "mb-[2rem] lg:mb-[4rem]" />
83- < Reviews activityId = { Number ( id ) } />
36+ < ReviewsWrapper activityId = { Number ( id ) } />
8437 </ div >
8538 { /* 체험 예약 캘린더 */ }
8639 < ReservationModal price = { data ?. price } activityId = { Number ( id ) } />
8740 </ div >
41+ < CleanUp />
8842 </ div >
8943 ) ;
9044} ;
0 commit comments