직접입력 구조 변경 및 튜토리얼 추가
This commit is contained in:
1 parent
b18dd7aa4d
commit
8d7d0a74a6
9 files changed
+244
-71
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
const REGIONS: { label: string; cities: string[] }[] = [
|
||||
export const REGIONS: { label: string; cities: string[] }[] = [
|
||||
{
|
||||
label: '특별시 / 광역시',
|
||||
cities: ['서울시', '부산시', '대구시', '인천시', '광주시', '대전시', '울산시', '세종시'],
|
||||
@@ -88,10 +88,11 @@ const CitySelectModal: React.FC<CitySelectModalProps> = ({ selected, onSelect, o
|
||||
return () => { document.body.style.overflow = ''; };
|
||||
}, []);
|
||||
|
||||
const cities = REGIONS.find(r => r.label === activeRegion)?.cities ?? [];
|
||||
const activeEntry = REGIONS.find(r => r.label === activeRegion);
|
||||
const cities = activeEntry?.cities ?? [];
|
||||
|
||||
const handleCityClick = (city: string) => {
|
||||
onSelect(city === selected ? '' : city);
|
||||
const handleSelect = (value: string) => {
|
||||
onSelect(value === selected ? '' : value);
|
||||
onClose();
|
||||
};
|
||||
|
||||
@@ -112,25 +113,38 @@ const CitySelectModal: React.FC<CitySelectModalProps> = ({ selected, onSelect, o
|
||||
|
||||
{activeRegion === null ? (
|
||||
<div className="city-modal-grid">
|
||||
{REGIONS.map(r => (
|
||||
<button
|
||||
key={r.label}
|
||||
className={`city-modal-region-item ${r.cities.includes(selected) ? 'has-selected' : ''}`}
|
||||
onClick={() => setActiveRegion(r.label)}
|
||||
>
|
||||
<span>{r.label}</span>
|
||||
{r.cities.includes(selected) && <span className="city-modal-region-badge">{selected}</span>}
|
||||
<span className="city-modal-arrow">›</span>
|
||||
</button>
|
||||
))}
|
||||
{REGIONS.map(r => {
|
||||
const isRegionSelected = selected === r.label;
|
||||
const hasCitySelected = r.cities.includes(selected);
|
||||
return (
|
||||
<button
|
||||
key={r.label}
|
||||
className={`city-modal-region-item ${isRegionSelected || hasCitySelected ? 'has-selected' : ''}`}
|
||||
onClick={() => setActiveRegion(r.label)}
|
||||
>
|
||||
<span>{r.label}</span>
|
||||
{isRegionSelected && <span className="city-modal-region-badge">전체</span>}
|
||||
{hasCitySelected && <span className="city-modal-region-badge">{selected}</span>}
|
||||
<span className="city-modal-arrow">›</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className="city-modal-item-wrap">
|
||||
{activeRegion !== '특별시 / 광역시' && (
|
||||
<button
|
||||
className={`city-modal-item city-modal-item-all ${selected === activeRegion ? 'active' : ''}`}
|
||||
onClick={() => handleSelect(activeRegion!)}
|
||||
>
|
||||
전체
|
||||
</button>
|
||||
)}
|
||||
{cities.map(city => (
|
||||
<button
|
||||
key={city}
|
||||
className={`city-modal-item ${selected === city ? 'active' : ''}`}
|
||||
onClick={() => handleCityClick(city)}
|
||||
onClick={() => handleSelect(city)}
|
||||
>
|
||||
{city}
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user