[feat] solution/frontend: 섹션 아이템을 버튼으로 넣는다 — 레트로 템플릿이 기본 구성을 데려온다

시드에 세 아이템을 박아 두니 내용 없는 칸이 목록에 늘 붙어 있었다. 붙여넣기 아이템은
JSON 이 없으면 빈 섹션이라 "쓸 사람만 넣는" 쪽이 맞다.

- canvas/addable.ts: 추가 가능한 섹션 목록. dataSpec 이 단일 출처라 아이템을 만들면 여기 자동으로
  나타난다 — 목록을 따로 들면 만들어 놓고 고를 수 없는 상태가 된다
- SectionListPanel: 하단 [+ 섹션 추가] + 썸네일 목록. 나중에 넣은 섹션만 휴지통으로 뺀다
  (업종 기본 섹션은 스위치로 끄는 것이지 빼는 게 아니다). 내용이 있으면 빼기 전에 한 번 묻는다
- stores/builder: addSection 은 이미 있으면 새로 만들지 않고 켜기만 한다 — 새로 만들면 넣어 둔
  JSON 이 날아간다
- shared/TemplateItem.defaultSectionTypes + 업종마다 레트로 템플릿 하나(옛 항구·옛 다방·노포·시간여행).
  고르면 세 아이템이 함께 들어온다. 넣기만 하고 빼지 않는다 — 템플릿을 눌러 보다 넣어 둔 섹션이
  사라지면 사장님은 그게 템플릿 때문인 줄 모르고 자기가 지웠다고 생각한다
- siteTheme/applyTheme: 저장 payload 에 type 을 싣는다. 시드에 없는 섹션은 id 로 못 찾아 복원 때
  통째로 버려졌다 — 사장님이 채운 JSON 까지 같이 사라지는 자리였다
- industryData: 세 아이템을 시드에서 뺐다

tsc·eslint·vite build 통과(frontend·admin), 추가·삭제·템플릿 연동·저장복원 왕복 12건 확인
This commit is contained in:
minaChoi committed 2026-09-02 08:35:25 +09:00
1 parent 23162783f9
commit e6ffdad888
7 files changed
+317 -30

No files matched your search

@@ -0,0 +1,51 @@
/**
* 나중에 넣을 수 있는 섹션 — [+ 섹션 추가] 가 고르는 목록.
*
* 업종 시드(industryData)는 "처음부터 있는 것"이고 여기는 "필요하면 넣는 것"이다.
* 붙여넣기 아이템은 내용이 없으면 빈 섹션이라, 시드에 박아 두면 아무도 안 쓰는 칸이 늘 붙어 있다.
*/
import type {SectionItem} from '@o2o/shared';
import {SECTION_DATA_SPEC} from './dataSpec';
import {defaultVariant} from './registry';
import type {ThumbKey} from './types';
export interface AddableSection {
type: string;
name: string;
description: string;
thumb: ThumbKey;
}
/**
* 추가할 수 있는 섹션 목록.
*
* ★ dataSpec 이 단일 출처다 — 아이템을 하나 더 만들면 여기에도 자동으로 나타난다.
* 목록을 따로 들면 아이템을 추가하고 이 표를 잊어 "만들었는데 고를 수가 없는" 상태가 된다.
*/
export const ADDABLE_SECTIONS: AddableSection[] = Object.values(SECTION_DATA_SPEC).map((spec) => {
const variant = defaultVariant(spec.kind);
return {
type: spec.kind,
name: spec.label,
description: variant?.description ?? '',
thumb: variant?.thumb ?? 'cards',
};
});
export function addableSection(type: string): AddableSection | undefined {
return ADDABLE_SECTIONS.find((item) => item.type === type);
}
/** 목록에 새로 넣을 섹션 한 줄. id 는 타입과 같다 — 같은 아이템을 두 번 넣지 않는다. */
export function newSectionOf(type: string): SectionItem | undefined {
const addable = addableSection(type);
if (!addable) return undefined;
return {
id: type,
type,
name: addable.name,
description: addable.description,
isLocked: false,
isEnabled: true,
};
}