-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTheatersList.tsx
More file actions
56 lines (49 loc) · 1.86 KB
/
TheatersList.tsx
File metadata and controls
56 lines (49 loc) · 1.86 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
import { useState } from 'react';
import { ToggleTab, Header, TheaterList } from '@/components';
import { useLocation, useNavigate } from 'react-router-dom';
import type { CinemaFormat } from '@/types/onboarding';
import { useTheatersQuery } from '@/hooks/queries/useTheatersQuery';
export default function TheaterListPage() {
const navigate = useNavigate();
const location = useLocation();
const queryTab = new URLSearchParams(location.search).get('tab');
const initialTab: CinemaFormat = queryTab === 'dolby' ? 'Dolby' : 'IMAX';
const [selectedTab, setSelectedTab] = useState<CinemaFormat>(initialTab);
const [selectedAuditorium, setSelectedAuditorium] = useState<string | null>(null);
const { data: theaters } = useTheatersQuery({ type: selectedTab, page: 1, size: 10 });
const handleTabChange = (tab: string) => {
setSelectedTab(tab as CinemaFormat);
setSelectedAuditorium(null);
};
return (
<div className="flex min-h-screen flex-col pt-11">
<Header leftSection="BACK" onBackClick={() => navigate('/home')} className="bg-gray-900">
영화관 리스트
</Header>
{/* 탭 */}
<div className="flex justify-center px-5 pt-5">
<div className="w-[375px]">
<ToggleTab
options={[
{ label: 'IMAX', value: 'IMAX' },
{ label: 'Dolby Cinema', value: 'Dolby' },
]}
selected={selectedTab}
onSelect={handleTabChange}
/>
</div>
</div>
<div className="mt-5 px-5">
{/* 리스트 */}
<TheaterList
data={theaters ?? []}
selected={selectedAuditorium ? [selectedAuditorium] : []}
onSelect={(id) => setSelectedAuditorium(id)}
onAuditoriumClick={(auditoriumId) => {
navigate(`/theaters/${auditoriumId}`);
}}
/>
</div>
</div>
);
}