import {useState} from 'react'; import {Check} from 'lucide-react'; import type {IndustryType} from '@o2o/shared'; import {INDUSTRY_CONFIGS} from '@/data/industryData'; import {cn} from '@/lib/utils'; import {useBuilderStore} from '@/stores/builder'; import {INDUSTRY_ICONS} from './industryIcons'; import {useWizardStep} from './wizardUrl'; import {WizardFooter} from './WizardFooter'; import {WizardSteps} from './WizardSteps'; const INDUSTRY_ORDER: IndustryType[] = ['stay', 'cafe', 'restaurant', 'clinic']; /** * 업종 직접 고르기 — `?step=industry`. * * ★ 이 화면은 더 이상 위저드의 첫 화면이 아니다. 업종은 상호 검색 결과의 분류가 정하고 * (services/place_category.py), 여기는 **못 정했을 때와 바꿀 때만** 들른다. * 진행 표시에서 1번을 유지하는 이유도 같다 — 이건 '내 가게 확인' 안의 갈래다. * * ★ 못 정해서 들어온 경우에는 아무 카드도 선택된 것으로 보이지 않게 한다. 스토어에는 언제나 * 기본 업종이 들어 있어서, 그걸 그대로 칠하면 사장님은 자기가 고르지도 않은 업종이 * 이미 정해진 것으로 읽는다. */ export function Step1Industry() { const industry = useBuilderStore((s) => s.industry); const pendingPick = useBuilderStore((s) => s.pendingPick); const selectIndustry = useBuilderStore((s) => s.selectIndustry); const setPendingPick = useBuilderStore((s) => s.setPendingPick); const [, goToStep] = useWizardStep(); /** 검색이 업종을 못 정해 넘어온 경우 — 고르기 전에는 진행시키지 않는다. */ const mustChoose = Boolean(pendingPick && !pendingPick.industry); const [touched, setTouched] = useState(false); const showSelection = touched || !mustChoose; const pick = (id: IndustryType) => { setTouched(true); selectIndustry(id); }; /** * 고른 업종을 들고 검색 화면으로 돌아간다. * * ★ 후보를 들고 왔으면 그 후보에 업종을 찍어 돌려보낸다 — 확정(사업장 생성)은 검색 화면 * 한 곳에서만 한다. 두 화면이 각자 확정하면 같은 가게가 두 번 만들어지는 길이 생긴다. */ const goBack = () => { if (pendingPick) setPendingPick({...pendingPick, industry}); goToStep('search'); }; return (

{mustChoose ? '이 가게는 어떤 업종인가요?' : '업종을 바꿀까요?'}

{mustChoose ? '지도 분류만으로는 업종을 정하지 못했습니다. 업종에 맞는 항목만 수집하고, 그 항목만 검증합니다.' : '업종을 고르면 그 업종에 맞는 항목만 수집하고, 그 항목만 검증합니다.'}

{INDUSTRY_ORDER.map((id) => { const config = INDUSTRY_CONFIGS[id]; const Icon = INDUSTRY_ICONS[id]; const isSelected = showSelection && industry === id; return ( ); })}
선택된 업종:{' '} {INDUSTRY_CONFIGS[industry].name} {' '} ({INDUSTRY_CONFIGS[industry].subName}) ) : ( '업종을 하나 골라 주세요.' ) } onPrev={() => goToStep('search')} onNext={goBack} nextDisabled={!showSelection} nextLabel={pendingPick ? '이 업종으로 계속하기' : '내 가게 찾기로 돌아가기'} />
); }