-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
98 lines (88 loc) · 2.92 KB
/
index.tsx
File metadata and controls
98 lines (88 loc) · 2.92 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import Image from 'next/image';
import { cn } from '@/shared/lib';
import { ControlBar } from '@/shared/components';
import { BottomNav } from '@/shared/components/tab/BottomNav';
import { useCourseSelection } from '@/shared/hooks/useCourseSelection';
import CourseSelectGroup from '@/shared/components/map/components/CourseSelectGroup';
import CourseInputSection from '@/shared/components/map/components/CourseInputSection';
import { useRouter } from 'next/router';
import { useRecommendCourse } from '@/shared/api/course/queries/useRecommendCourse';
import { useState } from 'react';
export default function CourseSettingPage() {
const router = useRouter();
const { mutate, isPending } = useRecommendCourse();
const { purpose, setPurpose, stay, setStay, move, setMove } = useCourseSelection();
const [mustVisitPlace, setMustVisitPlace] = useState('');
const canProceed = Boolean(purpose && stay && move);
const handleNext = () => {
if (!canProceed) return;
mutate(
{
travelPurpose: purpose!,
stayDuration: stay!,
transportation: move!,
userLatitude: 37.4985,
userLongitude: 126.7822,
mustVisitPlace: mustVisitPlace || "",
},
{
onSuccess: (res) => {
if (res.isSuccess) {
router.push(`/map/result?sessionId=${res.result.sessionId}`);
}
},
onError: (err) => {
console.error('AI 코스 추천 실패:', err);
},
},
);
};
return (
<div
className={cn(
'relative px-[2.4rem] bg-white flex flex-col h-full pt-[1.3rem] pb-[12rem]',
)}
role='form'
aria-labelledby='course-setting-title'
aria-describedby='course-setting-desc'
>
<ControlBar className='fixed top-[1rem] left-0 right-0 z-50 px-[2rem]' />
<main
className='w-full pt-[3.4rem] flex flex-col overflow-auto'
aria-live='polite'
>
<section className='mb-[3.6rem] text-center'>
<h1 id='course-setting-title' className='sr-only'>
여행 코스 설정
</h1>
<Image
src='/assets/bannerMap.svg'
alt='여행 코스 추천 배너 이미지'
width={354}
height={79}
className='w-full h-auto object-cover block'
/>
<p id='course-setting-desc' className='sr-only'>
여행 목적, 체류 시간, 이동 방식을 선택하고, 원하는 장소를 입력할 수
있습니다.
</p>
</section>
<CourseSelectGroup
purpose={purpose}
stay={stay}
move={move}
setPurpose={setPurpose}
setStay={setStay}
setMove={setMove}
/>
<CourseInputSection
value={mustVisitPlace}
onChange={setMustVisitPlace}
onNext={handleNext}
isLoading={isPending}
/>
</main>
<BottomNav />
</div>
);
}