편집 화면이 "네이버 실시간 온라인 예약 / 캘린더에서 바로 확정 예약하실 수 있습니다" 를 그리고 있었다. 우리는 실시간 재고를 갖지 않고(PRODUCT.md 6절), 발행본은 날짜·시간을 고르는 화면이다 — 사장님이 에디터에서 본 것과 발행된 사이트가 서로 다른 물건이었다. 에디터가 보여주는 것이 곧 발행될 것이어야 한다. - booking/BookingCard: 발행본 구성(날짜 칩·도착 시간·인원·예약 요청·전화 창구)의 미리보기로 교체. 캔버스 클릭은 섹션 선택이라 상태를 두지 않고 첫 칸 선택 모습으로 고정. 시간 칸은 발행본과 같은 규칙 — 체크인 fact 가 있을 때만 그린다 - booking/BookingBanner: "실시간 캘린더에서 남은 날짜" → "날짜와 시간을 고르고 예약 창구로" - rooms/RoomCard: "실시간 예약 신청" → "예약 안내 보기" - hero/HeroEditorial: "실시간 예약" → "예약 안내" - api/generated linkChannel: NAVER_BOOKING=7 추가. ★ npm run orval 을 그대로 돌리면 141파일 6,400줄이 바뀌는데 전부 따옴표·줄바꿈 포매팅 드리프트다 — 생성물을 되돌리고 스펙 변경분 한 줄만 남겼다 tsc·eslint 통과(frontend·site), vitest 51 passed. solution-site 재빌드 후 번들에서 옛 문구 0건 확인.
149 lines
6.8 KiB
TypeScript
149 lines
6.8 KiB
TypeScript
/**
|
|
* 예약 · 카드 — **발행본의 예약 안내를 그대로 미리 보여준다.**
|
|
*
|
|
* ★ 왜 갈아엎었나 (2026-09-09)
|
|
* 이 카드는 "네이버 실시간 온라인 예약 / 캘린더에서 바로 확정 예약" 을 그리고 있었다.
|
|
* 우리는 실시간 예약을 하지 않는다(PRODUCT.md 6절 — 재고도 결제도 갖지 않는다).
|
|
* 게다가 발행본은 날짜·시간을 고르는 화면인데 캔버스만 다른 문구를 보여줘서,
|
|
* 사장님이 편집 화면에서 본 것과 발행된 사이트가 서로 다른 물건이었다.
|
|
* **에디터가 보여주는 것이 곧 발행될 것**이어야 한다.
|
|
*
|
|
* ★ 여기서는 **누르지 않는다.** 캔버스의 클릭은 "이 섹션을 고른다" 는 뜻이라
|
|
* 상태를 가진 위젯을 넣으면 선택과 싸운다. 첫 칸이 골라진 모습으로 고정해 두고,
|
|
* 실제 동작은 발행본(`solution/site` StayBookingDemo)이 한다.
|
|
*
|
|
* ★ 시간 칸은 **체크인 fact 가 있을 때만** 그린다. 발행본과 같은 규칙이다 —
|
|
* 체크인이 16:00 인데 미리보기가 14:00 을 보여주면 사장님은 그 선택지가 생긴 줄 안다.
|
|
*/
|
|
import {CalendarDays, Clock, Minus, Phone, Plus} from 'lucide-react';
|
|
import type {InfoField} from '@o2o/shared';
|
|
import {SectionBody, SectionFrame, SectionHeading} from '../../primitives';
|
|
import type {SectionRenderProps} from '../../types';
|
|
|
|
const WEEKDAY_LABEL = ['일', '월', '화', '수', '목', '금', '토'] as const;
|
|
|
|
/** 오늘부터 7칸. 캔버스는 브라우저에서만 도므로 날짜를 그대로 그려도 된다
|
|
* (발행본은 정적 HTML 이라 날짜를 굽지 않는다 — StayBookingDemo 머리주석). */
|
|
function nextDays(count: number) {
|
|
const today = new Date();
|
|
return Array.from({length: count}, (_, index) => {
|
|
const date = new Date(today.getFullYear(), today.getMonth(), today.getDate() + index);
|
|
return {day: date.getDate(), weekday: WEEKDAY_LABEL[date.getDay()]};
|
|
});
|
|
}
|
|
|
|
/** 확인된 값만 읽는다 — 캔버스도 발행본과 같은 규칙이다. */
|
|
function verified(fields: InfoField[], id: string): string | undefined {
|
|
const field = fields.find((f) => f.id === id);
|
|
if (!field || field.requiresVerification || !field.value?.trim()) return undefined;
|
|
return field.value.trim();
|
|
}
|
|
|
|
function arrivalSlots(checkIn?: string): string[] {
|
|
const match = /(\d{1,2})\s*:\s*(\d{2})/.exec(checkIn ?? '');
|
|
if (!match) return [];
|
|
const start = Number(match[1]);
|
|
if (!Number.isFinite(start)) return [];
|
|
return Array.from({length: 4}, (_, i) => start + i)
|
|
.filter((hour) => hour <= 23)
|
|
.map((hour) => `${String(hour).padStart(2, '0')}:${match[2]}`);
|
|
}
|
|
|
|
export function BookingCard(props: SectionRenderProps) {
|
|
const {section, isSelected, onSelect, template, infoFields} = props;
|
|
const days = nextDays(7);
|
|
const checkIn = verified(infoFields, 'check_in_time');
|
|
const slots = arrivalSlots(checkIn);
|
|
const phone = verified(infoFields, 'phone');
|
|
const accent = template.colors.primary;
|
|
|
|
return (
|
|
<SectionFrame section={section} isSelected={isSelected} onSelect={onSelect} tone="white">
|
|
<SectionBody>
|
|
<SectionHeading title={section.name} subtitle={section.description} colors={template.colors} />
|
|
|
|
<div className="mx-auto max-w-lg overflow-hidden rounded-xl border border-stone-200/80 bg-white shadow-2xs">
|
|
<p className="flex items-center gap-2 border-b border-stone-200/80 px-4 py-3 text-xs font-bold text-stone-900">
|
|
<CalendarDays className="size-3.5 text-stone-400" />
|
|
<span>날짜 · 시간 선택</span>
|
|
</p>
|
|
|
|
<div className="space-y-4 p-4">
|
|
<div>
|
|
<p className="mb-1.5 text-[11px] font-semibold text-stone-400">날짜</p>
|
|
<ul className="flex gap-1.5 overflow-hidden">
|
|
{days.map((day, index) => (
|
|
<li
|
|
key={day.day}
|
|
className="flex w-11 shrink-0 flex-col items-center gap-0.5 rounded-lg border px-2 py-1.5 text-xs"
|
|
style={
|
|
index === 0
|
|
? {borderColor: accent, backgroundColor: accent, color: '#fff'}
|
|
: {borderColor: 'rgb(231 229 228)', backgroundColor: 'rgb(250 250 249)'}
|
|
}
|
|
>
|
|
<span className="text-[10px] opacity-70">{day.weekday}</span>
|
|
<span className="font-bold">{day.day}</span>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
|
|
{slots.length > 0 && (
|
|
<div>
|
|
<p className="mb-1.5 flex items-center gap-1 text-[11px] font-semibold text-stone-400">
|
|
<Clock className="size-3" />
|
|
<span>도착 예정 시간 (체크인 {checkIn} 이후)</span>
|
|
</p>
|
|
<ul className="flex flex-wrap gap-1.5">
|
|
{slots.map((time, index) => (
|
|
<li
|
|
key={time}
|
|
className="rounded-md border px-2.5 py-1 text-xs"
|
|
style={
|
|
index === 0
|
|
? {borderColor: accent, backgroundColor: accent, color: '#fff'}
|
|
: {borderColor: 'rgb(231 229 228)', backgroundColor: 'rgb(250 250 249)'}
|
|
}
|
|
>
|
|
{time}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
)}
|
|
|
|
<div className="flex items-center justify-between">
|
|
<p className="text-[11px] font-semibold text-stone-400">인원</p>
|
|
<div className="flex items-center gap-2 text-stone-500">
|
|
<span className="flex size-6 items-center justify-center rounded-md border border-stone-200">
|
|
<Minus className="size-3" />
|
|
</span>
|
|
<span className="w-9 text-center text-sm font-bold text-stone-900">2명</span>
|
|
<span className="flex size-6 items-center justify-center rounded-md border border-stone-200">
|
|
<Plus className="size-3" />
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
className="rounded-lg px-4 py-2.5 text-center text-xs font-bold text-white"
|
|
style={{backgroundColor: accent}}
|
|
>
|
|
예약 요청 확인하기
|
|
</div>
|
|
|
|
{/* ★ 실제 예약이 되는 창구. 발행본과 같은 순서다 — 데모 다음에 진짜 창구가 온다. */}
|
|
{phone && (
|
|
<p className="flex items-center justify-center gap-1.5 text-[11px] text-stone-500">
|
|
<Phone className="size-3" />
|
|
<span>전화 예약 {phone}</span>
|
|
</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</SectionBody>
|
|
</SectionFrame>
|
|
);
|
|
}
|