[feat] solution/frontend: 온보딩을 상호명부터 — 단계를 주소창으로 옮기고 업종은 검색이 정한다
업종을 먼저 고르게 하면 경계에서 멈춘다("우리는 카페인가 음식점인가"). 그런데 상호명은
100% 안다. 그리고 업종은 AI 를 부를 필요가 없다 — 카카오·네이버 검색 응답에 분류가
이미 들어 있고(category_group_code), 지금까지 받아 놓고 안 썼다.
- 단계가 스토어에서 주소창으로: ?step=search|industry|collect|template|generating|editor.
번호가 아니라 이름인 이유 — 단계가 4→3 으로 줄어 옛 북마크가 다른 화면을 연다
- 시작점이 상호명 검색(Step2PlaceSearch)이다. 업종 선택은 못 정했을 때의 갈래로 남는다
- 업종은 후보의 category 로 잡히고, 못 정하면 고르게 하고, 정해져도 [바꾸기] 로 바꾼다.
★ 확정 뒤 변경은 신원 확인부터 다시 받는다 — Req_UpdatePlace 에 category 가 없어
PATCH 로 못 고치고, placeAdapter 가 리페치마다 덮어써서 조용히 되돌아간다
- 랜딩 진입: ?new=1 · ?q=<상호명> · ?industry=<업종>. 한 번 읽고 replace 로 지운다
- ★ ?new=1 이 setSearchParams({}) 로 **모든 쿼리를 날리던 것**을 고쳤다 — q 가 읽히기 전에 사라졌다
- selectIndustry 가 사장님이 친 상호·위치를 지우던 것도 고쳤다(업종이 첫 화면일 땐 늘 빈 값이라 안 보였다)
- 로고는 어디서나 / 로 간다. 에디터에서는 span 이라 아예 안 눌렸다
tsc·eslint·vite build 통과
This commit is contained in:
1 parent
41e49c693b
commit
a61f9724ea
34 files changed
+1137
-443
No files matched your search
@@ -1,25 +1,34 @@
|
||||
import {useEffect, useRef} from 'react';
|
||||
import {useEffect} from 'react';
|
||||
import {ArrowLeft, ExternalLink, Loader2, LogOut, TriangleAlert} from 'lucide-react';
|
||||
import {Link, useSearchParams} from 'react-router';
|
||||
import {SiteStatus} from '@o2o/shared';
|
||||
import {SiteStatus, type IndustryType} from '@o2o/shared';
|
||||
import {getAccessToken} from '@/api';
|
||||
import {EditorSignInGate} from '@/features/auth/EditorSignInGate';
|
||||
import {
|
||||
EDITOR_STEP,
|
||||
Step1Industry,
|
||||
Step2PlaceSearch,
|
||||
Step3DataReview,
|
||||
Step4Template,
|
||||
Step5Generating,
|
||||
useWizardStep,
|
||||
} from '@/features/onboarding';
|
||||
import {EditorLayout} from '@/features/builder';
|
||||
import {useAutoLogin} from '@/hooks/useAutoLogin';
|
||||
import {usePlaceSync} from '@/hooks/usePlaceSync';
|
||||
import {userLabel, useAuthStore} from '@/stores/auth';
|
||||
import {EDITOR_STEP, useBuilderStore} from '@/stores/builder';
|
||||
import {useBuilderStore} from '@/stores/builder';
|
||||
|
||||
/** 발행 사이트 렌더러의 개발 서버. 프로덕션에서는 실제 발행 주소로 바뀐다. */
|
||||
const SITE_PREVIEW_URL = import.meta.env.VITE_SITE_PREVIEW_URL ?? window.location.origin;
|
||||
|
||||
/** 랜딩이 `?industry=` 로 넘길 수 있는 값. 주소창 값이라 아무 문자열이나 들어올 수 있다. */
|
||||
const INDUSTRY_VALUES: IndustryType[] = ['stay', 'cafe', 'restaurant', 'clinic'];
|
||||
|
||||
function parseIndustry(value: string | null): IndustryType | null {
|
||||
return INDUSTRY_VALUES.includes(value as IndustryType) ? (value as IndustryType) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* "발행본 사이트 열기" 가 향할 주소.
|
||||
*
|
||||
@@ -36,32 +45,55 @@ function siteUrl(domain: string | null | undefined): string | null {
|
||||
export function BuilderPage() {
|
||||
useAutoLogin();
|
||||
/**
|
||||
* 어떤 사업장을 편집할지는 쿼리스트링으로 받는다 — `/builder?placeId=<uuid>`.
|
||||
* ★ 이 화면이 무엇을 그릴지는 **전부 주소창이 정한다.**
|
||||
*
|
||||
* ★ 라우트(`/builder/:placeId`)로 받지 않는 이유: 빌더는 로그인 없이 도는 데모 경로이고
|
||||
* (router.tsx 주석), placeId 는 있을 수도 없을 수도 있는 선택값이다. 쿼리스트링이면
|
||||
* 라우트를 하나도 안 건드리고 두 경우를 같은 화면이 받는다.
|
||||
* placeId 가 없으면 아래 훅은 네트워크를 한 번도 타지 않는다 — 데모는 지금 그대로다.
|
||||
* ?step= 어느 단계인가(없으면 wizardUrl.defaultStep 이 정한다)
|
||||
* ?placeId= 어떤 사업장인가 — 라우트(`/builder/:placeId`)로 받지 않는 이유는
|
||||
* 빌더가 로그인 없이 도는 경로이고 placeId 는 있을 수도 없을 수도 있어서다.
|
||||
* ?flow=onboarding 위저드가 방금 만든 사업장이다(딥링크로 편집하러 온 것과 구분한다)
|
||||
* ?new=1 ?q= ?industry= 랜딩에서 넘어온 입구. 한 번 읽고 주소창에서 지운다.
|
||||
*/
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [step, goToStep] = useWizardStep();
|
||||
const urlPlaceId = searchParams.get('placeId');
|
||||
const isOnboarding = searchParams.get('flow') === 'onboarding';
|
||||
|
||||
/**
|
||||
* `?new=1` 로 들어오면 위저드를 1단계(업종 선택)부터 시작한다.
|
||||
* 랜딩에서 넘어온 입구를 한 번만 읽는다 — `?new=1` · `?q=` · `?industry=`.
|
||||
*
|
||||
* ★ 저장된 상태를 그대로 두면 지난번 에디터가 복원된다 — 새 가게를 만들러 온 사람에게는
|
||||
* 자기가 만든 적 없는 화면이 뜨는 셈이다. 비운 뒤에는 주소창에서 플래그를 지워,
|
||||
* 새로고침할 때마다 작업하던 내용이 날아가지 않게 한다.
|
||||
* ★ `?new=1` 은 저장된 상태를 비운다. 안 비우면 새 가게를 만들러 온 사람에게 지난번 에디터가
|
||||
* 복원돼 뜬다. 읽은 뒤 주소창에서 지우는 이유는 두 가지다 — 새로고침마다 작업하던 내용이
|
||||
* 날아가지 않게, 그리고 사장님이 화면에서 고친 상호·업종을 링크 값이 도로 덮지 않게.
|
||||
* ★ **다른 쿼리는 남긴다.** 예전엔 `setSearchParams({})` 로 통째로 비웠는데, 그러면
|
||||
* `?new=1&q=...` 로 들어온 상호가 읽히기도 전에 사라진다.
|
||||
*/
|
||||
const reset = useBuilderStore((s) => s.reset);
|
||||
const selectIndustry = useBuilderStore((s) => s.selectIndustry);
|
||||
const setStoreName = useBuilderStore((s) => s.setStoreName);
|
||||
const isNew = searchParams.get('new') === '1';
|
||||
const seedQuery = searchParams.get('q');
|
||||
const seedIndustry = searchParams.get('industry');
|
||||
useEffect(() => {
|
||||
if (!isNew) return;
|
||||
reset();
|
||||
setSearchParams({}, {replace: true});
|
||||
}, [isNew, reset, setSearchParams]);
|
||||
if (!isNew && seedQuery === null && seedIndustry === null) return;
|
||||
if (isNew) reset();
|
||||
// 순서가 뒤집히면 안 된다 — selectIndustry 는 시드를 통째로 갈아 상호를 비운다.
|
||||
const industry = parseIndustry(seedIndustry);
|
||||
if (industry) selectIndustry(industry);
|
||||
if (seedQuery) setStoreName(seedQuery);
|
||||
setSearchParams(
|
||||
(prev) => {
|
||||
const next = new URLSearchParams(prev);
|
||||
next.delete('new');
|
||||
next.delete('q');
|
||||
next.delete('industry');
|
||||
return next;
|
||||
},
|
||||
{replace: true},
|
||||
);
|
||||
}, [isNew, seedQuery, seedIndustry, reset, selectIndustry, setStoreName, setSearchParams]);
|
||||
|
||||
/**
|
||||
* 위저드 2단계에서 확정한 사업장. 주소창에 placeId 가 없어도 이걸로 배선한다.
|
||||
* 위저드 1단계에서 확정한 사업장. 주소창에 placeId 가 없어도 이걸로 배선한다.
|
||||
*
|
||||
* ★ 이게 없으면 위저드를 끝까지 걸어온 사장님이 에디터에서 **업종 예시값**을 본다 —
|
||||
* 방금 27건을 확인해 놓고 '독채 3개 동' 같은 남의 가게 값이 뜬다. 실제로 그랬다.
|
||||
@@ -69,21 +101,8 @@ export function BuilderPage() {
|
||||
*/
|
||||
const wizardPlaceId = useBuilderStore((s) => s.confirmedIdentity?.placeId ?? null);
|
||||
const placeId = urlPlaceId ?? wizardPlaceId;
|
||||
/**
|
||||
* 에디터로 바로 들어갈지.
|
||||
*
|
||||
* ★ **처음 들어온 순간**의 주소창만 본다. 위저드 2단계가 확정 뒤에 `?placeId=` 를 붙이는데
|
||||
* (새로고침 복원용), 그걸 실시간으로 보면 "URL 붙여넣고 확인 → 곧장 에디터" 가 된다 —
|
||||
* 수집 결과를 보여주는 3·4·5단계가 통째로 건너뛰어진다. 실제로 그렇게 됐다.
|
||||
* 사업장 목록에서 딥링크로 들어온 경우(이미 만든 가게를 여는 것)만 에디터로 보낸다.
|
||||
*/
|
||||
const enteredWithPlace = useRef(
|
||||
Boolean(urlPlaceId) && searchParams.get('flow') !== 'onboarding',
|
||||
).current;
|
||||
const sync = usePlaceSync(placeId, {enterEditor: enteredWithPlace});
|
||||
const sync = usePlaceSync(placeId, {isOnboarding});
|
||||
|
||||
const step = useBuilderStore((s) => s.step);
|
||||
const goToStep = useBuilderStore((s) => s.goToStep);
|
||||
const storeName = useBuilderStore((s) => s.storeName);
|
||||
// 에디터는 AppShell(사이드바)을 안 쓴다 — 누구로 로그인했는지·나가는 길이 여기 없으면 아예 없다.
|
||||
const user = useAuthStore((s) => s.user);
|
||||
@@ -128,7 +147,7 @@ export function BuilderPage() {
|
||||
|
||||
// 에디터에 들어갈 때 로그인을 받는다. 위저드(1~5단계)는 요구하지 않는다.
|
||||
if (step === EDITOR_STEP && !isSignedIn) {
|
||||
return <EditorSignInGate onBack={() => goToStep(4)} />;
|
||||
return <EditorSignInGate onBack={() => goToStep('template')} />;
|
||||
}
|
||||
|
||||
if (step === EDITOR_STEP) {
|
||||
@@ -225,7 +244,9 @@ export function BuilderPage() {
|
||||
return (
|
||||
<div className="flex h-screen w-screen flex-col overflow-hidden bg-background text-foreground">
|
||||
<div className="flex shrink-0 items-center justify-between border-b border-border px-4 py-2.5">
|
||||
<img src="/brand/web4ai-wordmark.svg" alt="Web4Ai" className="h-6 w-auto" />
|
||||
<Link to="/" className="transition-opacity hover:opacity-60">
|
||||
<img src="/brand/web4ai-wordmark.svg" alt="Web4Ai" className="h-6 w-auto" />
|
||||
</Link>
|
||||
{/* 비로그인은 돌아갈 목록이 없다 — 그 자리에는 로그인을 둔다(빈 버튼을 두지 않는다). */}
|
||||
{isSignedIn ? (
|
||||
<Link
|
||||
@@ -246,11 +267,11 @@ export function BuilderPage() {
|
||||
</div>
|
||||
|
||||
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto">
|
||||
{step === 1 && <Step1Industry />}
|
||||
{step === 2 && <Step2PlaceSearch />}
|
||||
{step === 3 && <Step3DataReview />}
|
||||
{step === 4 && <Step4Template />}
|
||||
{step === 5 && <Step5Generating />}
|
||||
{step === 'search' && <Step2PlaceSearch />}
|
||||
{step === 'industry' && <Step1Industry />}
|
||||
{step === 'collect' && <Step3DataReview />}
|
||||
{step === 'template' && <Step4Template />}
|
||||
{step === 'generating' && <Step5Generating />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user