직접입력 구조 변경 및 튜토리얼 추가
This commit is contained in:
1 parent
b18dd7aa4d
commit
8d7d0a74a6
9 files changed
+244
-71
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import CitySelectModal, { REGIONS } from './CitySelectModal';
|
||||
|
||||
interface BusinessNameInputModalProps {
|
||||
onClose: () => void;
|
||||
@@ -9,7 +11,9 @@ interface BusinessNameInputModalProps {
|
||||
const BusinessNameInputModal: React.FC<BusinessNameInputModalProps> = ({ onClose, onSubmit }) => {
|
||||
const { t } = useTranslation();
|
||||
const [businessName, setBusinessName] = useState('');
|
||||
const [address, setAddress] = useState('');
|
||||
const [selectedCity, setSelectedCity] = useState('');
|
||||
const [detailAddress, setDetailAddress] = useState('');
|
||||
const [isCityModalOpen, setIsCityModalOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
document.body.style.overflow = 'hidden';
|
||||
@@ -25,11 +29,19 @@ const BusinessNameInputModal: React.FC<BusinessNameInputModalProps> = ({ onClose
|
||||
};
|
||||
}, [onClose]);
|
||||
|
||||
const isValid = businessName.trim().length > 0 && address.trim().length > 0;
|
||||
const handleCitySelect = (city: string) => {
|
||||
const region = REGIONS.find(r => r.cities.includes(city));
|
||||
// 특별시/광역시는 도 이름 없이 도시명만 사용
|
||||
const prefix = region && region.label !== '특별시 / 광역시' ? `${region.label} ` : '';
|
||||
setSelectedCity(`${prefix}${city}`);
|
||||
};
|
||||
|
||||
const isValid = businessName.trim().length > 0 && selectedCity.length > 0 && detailAddress.trim().length > 0;
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!isValid) return;
|
||||
onSubmit(businessName.trim(), address.trim());
|
||||
const fullAddress = `${selectedCity} ${detailAddress.trim()}`;
|
||||
onSubmit(businessName.trim(), fullAddress);
|
||||
onClose();
|
||||
};
|
||||
|
||||
@@ -37,58 +49,86 @@ const BusinessNameInputModal: React.FC<BusinessNameInputModalProps> = ({ onClose
|
||||
if (e.key === 'Enter' && isValid) handleSubmit();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="manual-modal-backdrop" onClick={onClose}>
|
||||
<div className="manual-modal" onClick={e => e.stopPropagation()}>
|
||||
<div className="manual-modal-header">
|
||||
<span className="manual-modal-title">{t('landing.hero.manualModalTitle')}</span>
|
||||
<button className="manual-modal-close" onClick={onClose}>✕</button>
|
||||
</div>
|
||||
// CitySelectModal의 selected prop용 — 도시명만 추출
|
||||
const cityOnly = selectedCity.split(' ').pop() ?? '';
|
||||
|
||||
<div className="manual-modal-body">
|
||||
<div className="manual-modal-field">
|
||||
<label className="manual-modal-label">{t('landing.hero.manualLabelName')}</label>
|
||||
<input
|
||||
type="text"
|
||||
className="manual-modal-input"
|
||||
placeholder={t('landing.hero.manualPlaceholderName')}
|
||||
value={businessName}
|
||||
onChange={e => setBusinessName(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
maxLength={50}
|
||||
autoFocus
|
||||
/>
|
||||
return createPortal(
|
||||
<>
|
||||
<div className="manual-modal-backdrop" onClick={onClose}>
|
||||
<div className="manual-modal" onClick={e => e.stopPropagation()}>
|
||||
<div className="manual-modal-header">
|
||||
<span className="manual-modal-title">{t('landing.hero.manualModalTitle')}</span>
|
||||
<button className="manual-modal-close" onClick={onClose}>✕</button>
|
||||
</div>
|
||||
|
||||
<div className="manual-modal-field">
|
||||
<label className="manual-modal-label">{t('landing.hero.manualLabelAddress')}</label>
|
||||
<input
|
||||
type="text"
|
||||
className="manual-modal-input"
|
||||
placeholder={t('landing.hero.manualPlaceholderAddress')}
|
||||
value={address}
|
||||
onChange={e => setAddress(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
maxLength={100}
|
||||
/>
|
||||
</div>
|
||||
<div className="manual-modal-body">
|
||||
<div className="manual-modal-field">
|
||||
<label className="manual-modal-label">{t('landing.hero.manualLabelName')}</label>
|
||||
<input
|
||||
type="text"
|
||||
className="manual-modal-input"
|
||||
placeholder={t('landing.hero.manualPlaceholderName')}
|
||||
value={businessName}
|
||||
onChange={e => setBusinessName(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
maxLength={50}
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="manual-modal-actions">
|
||||
<button type="button" className="manual-modal-cancel" onClick={onClose}>
|
||||
{t('common.cancel')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="manual-modal-submit"
|
||||
onClick={handleSubmit}
|
||||
disabled={!isValid}
|
||||
>
|
||||
{t('landing.hero.analyzeButton')}
|
||||
</button>
|
||||
<div className="manual-modal-field">
|
||||
<label className="manual-modal-label">{t('landing.hero.manualLabelRegion')}</label>
|
||||
<button
|
||||
type="button"
|
||||
className={`manual-modal-city-btn ${selectedCity ? 'selected' : ''}`}
|
||||
onClick={() => setIsCityModalOpen(true)}
|
||||
>
|
||||
<span>{selectedCity || t('landing.hero.manualPlaceholderRegion')}</span>
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M6 9l6 6 6-6" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="manual-modal-field">
|
||||
<label className="manual-modal-label">{t('landing.hero.manualLabelDetail')}</label>
|
||||
<input
|
||||
type="text"
|
||||
className="manual-modal-input"
|
||||
placeholder={t('landing.hero.manualPlaceholderDetail')}
|
||||
value={detailAddress}
|
||||
onChange={e => setDetailAddress(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
maxLength={100}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="manual-modal-actions">
|
||||
<button type="button" className="manual-modal-cancel" onClick={onClose}>
|
||||
{t('common.cancel')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="manual-modal-submit"
|
||||
onClick={handleSubmit}
|
||||
disabled={!isValid}
|
||||
>
|
||||
{t('landing.hero.analyzeButton')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isCityModalOpen && (
|
||||
<CitySelectModal
|
||||
selected={cityOnly}
|
||||
onSelect={(city) => { handleCitySelect(city); setIsCityModalOpen(false); }}
|
||||
onClose={() => setIsCityModalOpen(false)}
|
||||
/>
|
||||
)}
|
||||
</>,
|
||||
document.body
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -143,7 +143,11 @@ const TutorialOverlay: React.FC<TutorialOverlayProps> = ({
|
||||
};
|
||||
|
||||
const tryBind = (): boolean => {
|
||||
const el = document.querySelector(hint.targetSelector) as HTMLElement | null;
|
||||
const els = Array.from(document.querySelectorAll(hint.targetSelector));
|
||||
const el = (els.find(e => {
|
||||
const r = (e as HTMLElement).getBoundingClientRect();
|
||||
return r.width > 0 && r.height > 0;
|
||||
}) ?? els[0]) as HTMLElement | null;
|
||||
if (!el) return false;
|
||||
bindToTarget(el);
|
||||
return true;
|
||||
|
||||
@@ -64,6 +64,15 @@ export const tutorialSteps: TutorialStepDef[] = [
|
||||
noSpotlight: true,
|
||||
variant: 'bubble',
|
||||
},
|
||||
{
|
||||
targetSelector: '.hero-manual-button',
|
||||
titleKey: 'tutorial.landing.manual.title',
|
||||
descriptionKey: 'tutorial.landing.manual.desc',
|
||||
position: 'bottom',
|
||||
clickToAdvance: false,
|
||||
noSpotlight: true,
|
||||
variant: 'bubble',
|
||||
},
|
||||
{
|
||||
targetSelector: '.hero-button',
|
||||
titleKey: 'tutorial.landing.button.title',
|
||||
|
||||
Reference in new issue
Block a user