Files
o2o-site-AEO/solution/site/src/sections/LocationSection.tsx
T
minaChoi 872d00f3c4 [feat] solution: 미니 블로그·이용후기·예약요청 추가, /s/stay 목업·발행 사이트 UI 다수 수정
인앱 미니 블로그(AI 자동 포스트, 이메일 승인)·이용후기(즉시 게시)·예약 요청(메일 발송)을
새로 붙였고, 병행해서 /s/stay 목업과 발행 사이트 공통 렌더러(UnitsSection·FestivalSection·
LocalGuideSection·WeatherSection 등)의 UI 버그를 다수 고쳤다. 범위가 넓지만 한 주 분량
작업을 한 커밋으로 묶어 달라는 요청에 따라 하나로 묶는다.

- solution/backend: post/review/booking_request 라우터·서비스·CRUD 추가, 스케줄러에
  블로그 초안 생성(새벽 4:10)·발송(아침 9:00) cron 등록, 마이그레이션 4건 추가
- solution/frontend, admin/frontend: 생성된 API 클라이언트 갱신, 리뷰 모더레이션·
  블로그 글 관리 페이지 추가
- solution/site/src: 객실 상세+실시간예약(날짜선택·연락처 폼)을 모달로 통합, 축제·
  주변안내 카드 클릭 시 모달 전환, 후기 목록 카드 UI, 공용 Modal 컴포넌트 신설,
  날씨 문구 동기화 버그 수정(하늘줄·기온줄 한 타이머로), 시설·편의 가능/불가 아이콘
  색상 하이라이트, 헤더 메뉴 순서를 실제 섹션 순서에 맞춤, 하단 탭바 아이콘 정렬 버그
  (line-height) 수정, 추천일정 점선 연결+데스크톱 자동펼침/모바일 축소, 채널 라벨에
  크롤링 원문("NOL")이 새던 것을 bookingLabel() 로 교체
- solution/site/scripts/mockup: /s/stay 패치 스크립트·주입 CSS·JS 다수 수정, stay4~6
  빌드 스크립트 추가(다른 세션 작업)

테스트: solution/site `npx tsc --noEmit` 통과, `npx vitest run` 93 passed,
solution/backend `pytest tests/test_booking_request.py` 6 passed(로컬 DB 대상).
예약 요청 메일은 실제 발송까지 확인(place 66894a1b 소유자 이메일 누락을 DB에서 보정).
2026-09-18 09:03:18 +09:00

173 lines
8.1 KiB
TypeScript

import {useState} from 'react';
import {Car, Check, Copy, Navigation} from 'lucide-react';
import {useSite} from '@site/lib/site-context';
import {kakaoDirectionsUrl, naverDirectionsUrl, osmEmbedUrl, tmapDirectionsUrl} from '@site/lib/format';
import {Section} from '@site/lib/ui';
/**
* 오시는 길.
*
* ★ 지도를 폭 전체에 눕히지 않는다. 16:9 지도가 1200px 폭을 차지하면 세로 675px 짜리
* 빈 회색 판이 화면 하나를 통째로 먹고, 정작 주소와 길찾기 버튼은 그 아래로 밀렸다.
* 넓은 화면에서는 지도(7) 옆에 주소·길찾기·소요시간(5)을 세운다.
*
* ★ 네이버 초록·카카오 노랑은 템플릿 색으로 바꾸지 않는다 — 그건 디자인이 아니라
* 남의 서비스 식별색이다. 손님은 색으로 버튼을 찾는다.
*/
export function LocationSection() {
const payload = useSite();
const {place, routes} = payload;
const [copied, setCopied] = useState(false);
const address = place.roadAddress ?? place.address;
if (!address) return null;
// 좌표가 있어야 지도도 길찾기도 정확해진다. 없으면 지도를 그리지 않고,
// 버튼은 검색으로 떨어진다(format.ts) — 틀린 핀을 찍느니 안 찍는다.
const {latitude: lat, longitude: lng} = place;
const hasGeo = lat != null && lng != null;
const tmap = tmapDirectionsUrl(place.name, lat, lng);
const handleCopy = async () => {
try {
await navigator.clipboard.writeText(address);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch {
// 클립보드 권한이 없으면 조용히 넘어간다 — 주소는 화면에 그대로 있다.
}
};
return (
<Section
id="location"
title="오시는 길"
lead="주소와 주요 거점까지의 이동 시간을 안내합니다."
>
<div className="grid gap-6 lg:grid-cols-12 lg:gap-8">
{hasGeo && (
<div className="border-line tpl-border overflow-hidden rounded-xl border lg:col-span-7">
{/* ★ loading="lazy" — 지도는 접힌 화면 아래에 있는 경우가 많고, 첫 화면 속도를
남의 서버 응답에 맡기지 않는다. title 은 스크린리더가 읽을 유일한 설명이다. */}
<iframe
title={`${place.name} 위치 지도`}
src={osmEmbedUrl(lat, lng)}
loading="lazy"
referrerPolicy="no-referrer-when-downgrade"
className="block aspect-4/3 w-full border-0 sm:aspect-video lg:aspect-auto lg:h-full lg:min-h-[24rem]"
/>
</div>
)}
<div className={hasGeo ? 'lg:col-span-5' : 'lg:col-span-12'}>
<div className="panel p-5 sm:p-6">
<p className="label mb-2">주소</p>
<div className="flex flex-wrap items-center gap-2">
{/* address 태그로 감싼다 — 기계가 "이게 이 업소의 주소"임을 안다. */}
<address className="text-[length:var(--fs-lead)] font-bold not-italic">
{address}
</address>
<button
type="button"
onClick={handleCopy}
title="주소 복사"
className="border-line tpl-border inline-flex items-center gap-1 rounded-md border bg-current/8 px-2.5 py-1.5 text-[length:var(--fs-xs)] font-medium transition-opacity hover:opacity-100"
>
{copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
<span>{copied ? '복사완료' : '복사'}</span>
</button>
</div>
{place.phone && (
<p className="text-muted mt-2 text-[length:var(--fs-sm)]">
문의:{' '}
<a href={`tel:${place.phone}`} className="underline-offset-2 hover:underline">
{place.phone}
</a>
</p>
)}
{/*
★ 줄바꿈을 막고 자리가 모자라면 아래로 내린다 (2026-09-04, 사장님: "3안 버튼 깨짐")
xl 에서 가로로 세웠는데, 본문 칸이 좁은 안(oasi 는 716px 고정)에서는
"네이버 / 길찾기" 로 두 줄이 되고 화살표만 세로 가운데에 남아 깨져 보였다.
글자는 안 자르고(nowrap), 대신 버튼이 통째로 다음 줄로 내려간다(wrap).
*/}
<div className="mt-5 flex flex-wrap gap-2.5">
<a
href={naverDirectionsUrl(place.name, lat, lng)}
target="_blank"
rel="noopener noreferrer nofollow"
className="tap flex flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#03C75A] px-4 text-[length:var(--fs-sm)] font-bold text-white transition-opacity hover:opacity-100"
>
<Navigation className="size-4" />
<span>네이버 길찾기</span>
</a>
<a
href={kakaoDirectionsUrl(place.name, lat, lng)}
target="_blank"
rel="noopener noreferrer nofollow"
className="tap flex flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#FEE500] px-4 text-[length:var(--fs-sm)] font-bold text-[#191600] transition-opacity hover:opacity-100"
>
<Navigation className="size-4" />
<span>카카오 길찾기</span>
</a>
{/* 티맵은 앱 스킴뿐이라 터치 기기에서만 — PC 에서는 눌러도 아무 일이 없다. */}
{tmap && (
<a
href={tmap}
className="tap only-touch flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#0064FF] px-4 text-[length:var(--fs-sm)] font-bold text-white transition-opacity hover:opacity-100"
>
<Navigation className="size-4" />
<span>티맵 길찾기</span>
</a>
)}
</div>
</div>
</div>
</div>
{routes.length > 0 && (
<div className="mt-8">
<h3 className="mb-3 flex items-center gap-2 text-[length:var(--fs-sm)] font-bold">
<Car className="size-4 opacity-100" />
<span>주요 거점 소요시간</span>
</h3>
<div className="panel overflow-hidden">
{/* 좁은 화면에서는 표를 가로로 민다 — 열을 접으면 값이 사라져 인용이 끊긴다. */}
<div className="slider-viewport">
<table className="w-full min-w-[34rem] text-left text-[length:var(--fs-sm)]">
<caption className="sr-only">
{payload.place.name}에서 주요 거점까지의 이동 시간
</caption>
<thead className="panel-sunken border-line border-b font-semibold">
<tr>
<th scope="col" className="p-4">목적지</th>
<th scope="col" className="p-4">차량</th>
<th scope="col" className="p-4">도보 / 대중교통</th>
<th scope="col" className="p-4">거리</th>
<th scope="col" className="hidden p-4 md:table-cell">비고</th>
</tr>
</thead>
<tbody className="divide-line divide-y">
{routes.map((route) => (
<tr key={route.destination}>
<th scope="row" className="p-4 text-left font-bold">
{route.destination}
</th>
<td className="p-4 font-semibold">{route.byCar ?? '—'}</td>
<td className="p-4 opacity-100">{route.byTransit ?? '—'}</td>
<td className="text-muted p-4 tabular-nums">{route.distanceText ?? '—'}</td>
<td className="text-muted hidden p-4 md:table-cell">{route.note ?? ''}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
)}
</Section>
);
}