refactor(supporters): 의료관광 연결을 /discovery 에서 서포터즈 사이트 /en/stay 로 옮김

붙일 자리를 잘못 잡았다. /discovery 는 INFINITH 제품의 진단 화면이고 병원마다 쓰는
범용 도구다. 외국인 환자가 보는 페이지는 병원 서포터즈 사이트다. 그쪽으로 옮겼다.

옮긴 것
- src/components/discovery/MedicalTourismPanel.tsx, src/types/medicalTourism.ts,
  src/data/medicalTourism.json 삭제. DiscoveryReportPage 원복.
- supporters/src/pages/en/stay.astro 신설. 독립 URL 과 자체 WebPage JSON-LD 를 가져
  AI 인용 단위가 된다. sitemap 에 등록하고 /visit 에서 hreflang 링크로 잇는다.
- 수집 스크립트 출력을 supporters/src/data/medicalTourism.json 으로 바꿨다.

영문 페이지 지원
- Base.astro 에 lang prop 추가(기본 ko). html lang · og:locale · 머리말 · 꼬리말이
  따라 바뀐다. 레이아웃을 하나로 유지해 한국어 페이지 동작은 그대로다.
- 의료광고 고지(지원 관계·부작용)는 규정 대상이라 임의로 번역하지 않는다. 병원이
  sponsorNoticeEn / sideEffectNoticeEn 을 확정하기 전에는 한국어 원문을 그대로 싣고
  영문 문구가 확인 대기임을 밝힌다.
- factSheet 에 nameEn / shortNameEn / shortNameEnSource 추가. 뷰성형외과 값의 근거는
  병원 자신의 영문 도메인 viewplasticsurgery.com 이며 한국관광공사 등재명도 같다.

페이지가 만들지 않는 것
- 평점·리뷰·영업시간: TourAPI 미제공이라 싣지 않는다.
- 식당의 회복 적합성: 의학 판단이라 병원이 확정한 영문 문구(site.json dietGuideEn)만
  싣는다. 확인 전에는 어떤 식당도 적합으로 표시하지 않는다고 페이지에 적는다.
- 회복 단계 일수: 병원 확정값(recoveryStagesEn). 단계는 이동 거리로만 정의한다.
- 하단에 이 페이지가 답하지 못하는 것 네 가지를 그대로 적었다.

템플릿 동기화
- templates/supporters-astro 에 같은 변경을 넣되 데이터는 빈 스캐폴드로 둔다.
  뷰성형외과 factSheet 와 관광 데이터가 새 병원 빌드에 새어 들어가면 안 된다.
  빈 데이터로 빌드해 6개 범주가 "No English listings" 로 나오는 것까지 확인했다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 5 committed 2026-09-09 11:42:46 +09:00
1 parent 5d3ce40f77
commit a807d5dd9c
18 files changed
+359 -574

No files matched your search

@@ -1,449 +0,0 @@
/**
* 의료관광 연결 패널 (/discovery/:id)
*
* 외국인 환자가 수술 전후에 쓸 주변 정보를 한 곳에 모은다.
* 숙박 · 음식점 · 웰니스(스파) · 관광 · 쇼핑 · 축제, 그리고 이동 반경 기준 회복 동선.
*
* 데이터는 `scripts/fetch_medical_tourism.py` 가 한국관광공사 TourAPI 다국어(영문)에서
* 미리 수집한 `src/data/medicalTourism.json` 이다. 사전 수집인 이유는 영문 커버리지가
* 얇아 필터링이 많이 필요하고, 시연 중 외부 API 상태에 화면이 종속되지 않게 하기 위해서다.
*
* 만들지 않는 것
* - 평점·리뷰·영업시간: TourAPI 미제공이므로 "미연동"으로 표시하고 비워 둔다.
* - 수술 전후 식이 적합성: 병원이 supporter_inputs('diet_guide')로 입력한 값만 쓴다.
* 입력 전에는 "병원 확인 대기"로 둔다. 개별 식당의 적합 여부를 추론하지 않는다.
* - 회복 단계가 며칠째인지: 의학 판단이라 병원 입력('recovery')을 따른다.
* 화면의 단계는 이동 반경으로만 정의한다.
*/
import { useEffect, useMemo, useState } from 'react';
import type { ReactNode } from 'react';
import { motion } from 'motion/react';
import { SectionWrapper } from '../report/ui/SectionWrapper';
import { supabase } from '../../lib/supabase';
import data from '../../data/medicalTourism.json';
import type {
MedicalTourismData,
PlaceCategory,
RecoveryStage,
TourPlace,
} from '../../types/medicalTourism';
import {
BedFilled,
ForkFilled,
SpaFilled,
MapPinFilled,
TicketFilled,
BagFilled,
TheaterFilled,
} from '../icons/FilledIcons';
const TOURISM = data as unknown as MedicalTourismData;
const CATEGORY_META: Record<
PlaceCategory,
{ label: string; en: string; Icon: typeof BedFilled }
> = {
stay: { label: '숙박', en: 'Stay', Icon: BedFilled },
restaurant: { label: '음식점', en: 'Dining', Icon: ForkFilled },
wellness: { label: '웰니스', en: 'Wellness', Icon: SpaFilled },
attraction: { label: '관광', en: 'Attractions', Icon: MapPinFilled },
culture: { label: '문화', en: 'Culture', Icon: TheaterFilled },
shopping: { label: '쇼핑', en: 'Shopping', Icon: BagFilled },
};
const CATEGORY_ORDER: PlaceCategory[] = [
'stay',
'restaurant',
'wellness',
'attraction',
'culture',
'shopping',
];
/**
* 회복 동선. 며칠째인지는 병원이 정한다(§ClinicInputsPanel 'recovery').
* 여기서는 이동 반경만 정의하므로 의학적 판단을 담지 않는다.
*/
const STAGES: RecoveryStage[] = [
{
id: 'near',
label: '병원 도보권',
maxDistanceM: 1000,
categories: ['stay', 'restaurant'],
note: '내원이 잦은 기간에 머무는 범위입니다.',
},
{
id: 'short',
label: '근거리 이동',
maxDistanceM: 3000,
categories: ['restaurant', 'wellness'],
note: '짧은 외출이 가능해지는 범위입니다.',
},
{
id: 'city',
label: '시내 이동',
maxDistanceM: 10000,
categories: ['attraction', 'culture', 'shopping'],
note: '관광 일정을 넣을 수 있는 범위입니다.',
},
];
function fmtDistance(m: number | null) {
if (m === null) return '거리 미상';
return m < 1000 ? `${m}m` : `${(m / 1000).toFixed(1)}km`;
}
function fmtDate(d: string | null) {
if (!d || d.length !== 8) return '';
return `${d.slice(0, 4)}.${d.slice(4, 6)}.${d.slice(6, 8)}`;
}
export function MedicalTourismPanel({ clinicId }: { clinicId: string }) {
const [tab, setTab] = useState<PlaceCategory | 'festival' | 'route'>('route');
const [clinicInput, setClinicInput] = useState<{
recovery?: string;
diet?: Record<string, string>;
}>({});
// 병원이 입력한 회복·식이 값을 읽는다. 같은 clinic_id 의 최신 행이 유효값이다.
useEffect(() => {
let alive = true;
(async () => {
const { data: rows } = await supabase
.from('supporter_inputs')
.select('key,value,created_at')
.eq('clinic_id', clinicId)
.in('key', ['recovery', 'diet_guide'])
.order('created_at', { ascending: true });
if (!alive || !rows) return;
const latest = new Map<string, Record<string, string>>();
for (const r of rows) latest.set(r.key, r.value as Record<string, string>);
setClinicInput({
recovery: latest.get('recovery')?.answer,
diet: latest.get('diet_guide'),
});
})();
return () => {
alive = false;
};
}, [clinicId]);
// 단계는 누적이 아니라 구간이다. 누적으로 하면 가까운 곳이 모든 단계에 중복으로 뜬다.
const stageBuckets = useMemo(
() =>
STAGES.map((s, i) => {
const minM = i === 0 ? 0 : STAGES[i - 1].maxDistanceM;
return {
stage: s,
minM,
items: s.categories
.flatMap((c) =>
(TOURISM.places[c] ?? []).map((p) => ({ ...p, category: c })),
)
.filter(
(p) =>
p.distanceM !== null &&
p.distanceM > minM &&
p.distanceM <= s.maxDistanceM,
)
.sort((a, b) => (a.distanceM ?? 0) - (b.distanceM ?? 0))
.slice(0, 6),
};
}),
[],
);
const totalPlaces =
CATEGORY_ORDER.reduce((n, c) => n + (TOURISM.places[c]?.length ?? 0), 0) +
TOURISM.festivals.length;
return (
<SectionWrapper
id="medical-tourism"
title="Medical Tourism Connect"
subtitle={`외국인 환자의 수술 전후 동선을 병원 반경 기준으로 연결합니다. 한국관광공사 TourAPI 영문 데이터 ${totalPlaces}건`}
dark
>
{/* 출처와 기준점 */}
<div className="mb-8 rounded-2xl bg-white/10 backdrop-blur-sm border border-white/10 p-5">
<div className="grid gap-4 md:grid-cols-3 text-sm">
<div>
<div className="text-xs font-medium text-purple-300 mb-1">기준 좌표</div>
<div className="text-white/90">{TOURISM.meta.origin.label}</div>
<div className="text-purple-200 text-xs mt-0.5">
{TOURISM.meta.origin.lat}, {TOURISM.meta.origin.lng} · {TOURISM.meta.origin.coordSource}
</div>
</div>
<div>
<div className="text-xs font-medium text-purple-300 mb-1">데이터 출처</div>
<div className="text-white/90">{TOURISM.meta.source}</div>
<div className="text-purple-200 text-xs mt-0.5">
수집 {TOURISM.meta.fetchedAt.replace('T', ' ')}
</div>
</div>
<div>
<div className="text-xs font-medium text-purple-300 mb-1">수집 반경</div>
<div className="text-white/90">
숙박·식사 5km · 관광·문화·쇼핑 10km
</div>
<div className="text-purple-200 text-xs mt-0.5">
축제 {TOURISM.meta.festivalRadiusKm}km 이내
</div>
</div>
</div>
</div>
{/* 탭 */}
<div className="flex flex-wrap gap-2 mb-8" data-no-print>
<TabButton active={tab === 'route'} onClick={() => setTab('route')}>
회복 동선
</TabButton>
{CATEGORY_ORDER.map((c) => (
<TabButton key={c} active={tab === c} onClick={() => setTab(c)}>
{CATEGORY_META[c].label} {TOURISM.places[c]?.length ?? 0}
</TabButton>
))}
<TabButton active={tab === 'festival'} onClick={() => setTab('festival')}>
축제 {TOURISM.festivals.length}
</TabButton>
</div>
{tab === 'route' && (
<div className="space-y-5">
<ClinicGate
title="회복 단계별 일수"
filled={clinicInput.recovery}
waiting="수술별로 각 단계가 며칠인지는 병원이 정합니다. 아래 '병원 확인 항목'의 회복 일정 칸에 입력하면 이 동선에 날짜가 붙습니다."
/>
{stageBuckets.map(({ stage, minM, items }, i) => (
<motion.div
key={stage.id}
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ delay: i * 0.1 }}
className="bg-white rounded-2xl shadow-[3px_4px_12px_rgba(0,0,0,0.06)] p-6"
>
<div className="flex items-baseline justify-between gap-3 mb-1 flex-wrap">
<h3 className="text-lg font-bold text-[#0A1128]">{stage.label}</h3>
<span className="text-xs font-medium text-slate-500">
병원 반경 {minM === 0 ? '' : `${fmtDistance(minM)} ~ `}
{fmtDistance(stage.maxDistanceM)}
</span>
</div>
<p className="text-sm text-slate-600 mb-4">{stage.note}</p>
{items.length === 0 ? (
<EmptyNote>이 반경에 담긴 영문 데이터가 없습니다.</EmptyNote>
) : (
<div className="grid gap-3 md:grid-cols-2 lg:grid-cols-3">
{items.map((p) => (
<PlaceCard key={`${p.category}-${p.id}`} place={p} category={p.category} compact />
))}
</div>
)}
</motion.div>
))}
</div>
)}
{tab !== 'route' && tab !== 'festival' && (
<>
{tab === 'restaurant' && (
<div className="mb-5">
<ClinicGate
title="수술 전후 식이 가이드"
filled={clinicInput.diet?.recommended}
waiting="어떤 음식이 회복에 맞는지는 의학 판단이라 병원이 정합니다. 병원이 권장·회피 분류를 입력하면 이 목록에 표시됩니다. 개별 식당의 적합 여부를 저희가 판정하지 않습니다."
/>
</div>
)}
<PlaceGrid items={TOURISM.places[tab] ?? []} category={tab} />
</>
)}
{tab === 'festival' && (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{TOURISM.festivals.map((f) => (
<div
key={f.id}
className="bg-white rounded-2xl shadow-[3px_4px_12px_rgba(0,0,0,0.06)] hover:shadow-[4px_6px_16px_rgba(0,0,0,0.09)] transition-shadow overflow-hidden"
>
<div className="h-36 bg-slate-100 flex items-center justify-center overflow-hidden">
{f.image ? (
<img src={f.image} alt="" className="w-full h-36 object-cover" loading="lazy" />
) : (
<span className="text-xs text-slate-400">사진 없음</span>
)}
</div>
<div className="p-5">
<div className="flex items-center gap-1.5 mb-2 text-[#6C5CE7]">
<TicketFilled size={16} />
<span className="text-xs font-semibold">{f.distanceKm}km</span>
</div>
<h4 className="text-base font-bold text-[#0A1128] mb-1.5">{f.title}</h4>
<p className="text-xs text-slate-500 mb-2">
{fmtDate(f.startDate)} ~ {fmtDate(f.endDate)}
</p>
<p className="text-sm text-slate-600">{f.address}</p>
</div>
</div>
))}
</div>
)}
{/* 한계를 숨기지 않는다 */}
<div className="mt-10 rounded-2xl border border-white/10 bg-white/5 p-5">
<div className="text-xs font-semibold tracking-wider text-purple-300 mb-3">
측정 가능 범위
</div>
<ul className="space-y-1.5">
{TOURISM.meta.limits.map((l) => (
<li key={l} className="text-sm text-white/80 flex gap-2">
<span className="text-purple-300 shrink-0">·</span>
<span>{l}</span>
</li>
))}
</ul>
</div>
</SectionWrapper>
);
}
/* ────────────────────────── 서브 컴포넌트 ────────────────────────── */
function TabButton({
active,
onClick,
children,
}: {
key?: string;
active: boolean;
onClick: () => void;
children: ReactNode;
}) {
return (
<button
onClick={onClick}
className={`px-4 py-2 rounded-full text-sm font-medium transition-colors ${
active
? 'bg-gradient-to-r from-[#4F1DA1] to-[#021341] text-white'
: 'bg-white/10 text-white/80 hover:bg-white/20'
}`}
>
{children}
</button>
);
}
function PlaceGrid({ items, category }: { items: TourPlace[]; category: PlaceCategory }) {
if (items.length === 0) return <EmptyNote>영문 데이터가 없습니다.</EmptyNote>;
return (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{items.map((p) => (
<PlaceCard key={p.id} place={p} category={category} />
))}
</div>
);
}
function PlaceCard({
place,
category,
compact = false,
}: {
key?: string;
place: TourPlace;
category: PlaceCategory;
compact?: boolean;
}) {
const { Icon, label } = CATEGORY_META[category];
return (
<div
className={`bg-white rounded-2xl overflow-hidden transition-shadow h-full flex flex-col ${
compact
? 'border border-slate-100 shadow-sm hover:shadow-[3px_4px_12px_rgba(0,0,0,0.06)]'
: 'shadow-[3px_4px_12px_rgba(0,0,0,0.06)] hover:shadow-[4px_6px_16px_rgba(0,0,0,0.09)]'
}`}
>
{!compact && (
// 이미지가 없는 항목이 섞여 그리드가 어긋나지 않도록 자리를 항상 차지하게 둔다.
<div className="h-36 bg-slate-100 flex items-center justify-center overflow-hidden">
{place.image ? (
<img src={place.image} alt="" className="w-full h-36 object-cover" loading="lazy" />
) : (
<span className="text-xs text-slate-400">사진 없음</span>
)}
</div>
)}
<div className={`flex-1 ${compact ? 'p-4' : 'p-5'}`}>
<div className="flex items-center gap-1.5 mb-2 text-[#6C5CE7]">
<Icon size={16} />
<span className="text-xs font-semibold">{label}</span>
<span className="text-xs text-slate-400">· {fmtDistance(place.distanceM)}</span>
</div>
<h4 className={`font-bold text-[#0A1128] mb-1.5 ${compact ? 'text-sm' : 'text-base'}`}>
{place.title}
</h4>
<p className="text-xs text-slate-500 mb-2">{place.address}</p>
{/* TourAPI 미제공 항목. 채우지 않고 미연동으로 둔다. */}
<div className="text-xs text-slate-400">
{place.rating === null ? '평점·영업시간 미연동' : `평점 ${place.rating}`}
</div>
</div>
</div>
);
}
/** 병원이 채워야 하는 값의 자리. 값이 없으면 비운 채로 무엇이 필요한지 밝힌다. */
function ClinicGate({
title,
filled,
waiting,
}: {
title: string;
filled?: string;
waiting: string;
}) {
const has = Boolean(filled && filled.trim());
return (
<div
className="rounded-2xl border p-5"
style={
has
? { background: '#F3F0FF', borderColor: '#D5CDF5' }
: { background: '#FFF6ED', borderColor: '#F5E0C5' }
}
>
<div className="flex items-center gap-2 mb-2">
<span
className="inline-block w-2.5 h-2.5 rounded-full"
style={{ background: has ? '#9B8AD4' : '#D4A872' }}
/>
<span className="text-sm font-bold" style={{ color: has ? '#4A3A7C' : '#7C5C3A' }}>
{title}
</span>
<span
className="text-xs font-semibold px-2 py-0.5 rounded-full"
style={
has
? { background: '#fff', color: '#4A3A7C' }
: { background: '#fff', color: '#7C5C3A' }
}
>
{has ? '병원 입력됨' : '병원 확인 대기'}
</span>
</div>
<p className="text-sm" style={{ color: has ? '#4A3A7C' : '#7C5C3A' }}>
{has ? filled : waiting}
</p>
</div>
);
}
function EmptyNote({ children }: { children: ReactNode }) {
return (
<div className="rounded-xl bg-white/10 border border-white/10 px-4 py-3 text-sm text-white/70">
{children}
</div>
);
}
File diff suppressed because it is too large. Load diff
-4
View File
@@ -7,7 +7,6 @@ import { AEO_GEO_RUBRIC_V2 } from '../data/aeoGeoRubricV2';
import { scoreDiscoveryV2 } from '../lib/discoveryScoreV2';
import { AeoGeoV2Panel } from '../components/discovery/AeoGeoV2Panel';
import { ClinicInputsPanel } from '../components/discovery/ClinicInputsPanel';
import { MedicalTourismPanel } from '../components/discovery/MedicalTourismPanel';
import { DISCOVERY_RESULTS } from '../data/discoveryResults';
import { scoreDiscovery, levelToSeverity } from '../lib/discoveryScore';
import type {
@@ -359,9 +358,6 @@ export default function DiscoveryReportPage() {
{/* ── 5b. 서포터즈 자동 빌드 · 병원 확인 항목 (light, v2 §7-5) ── */}
<ClinicInputsPanel clinicId={result.id} />
{/* ── 5c. 의료관광 연결 (dark) ── */}
<MedicalTourismPanel clinicId={result.id} />
{/* ── 6. 채점 기준표 (light) ── */}
<SectionWrapper
id="rubric"
-88
View File
@@ -1,88 +0,0 @@
/**
* 의료관광 연결 기능 타입.
*
* 데이터 출처는 한국관광공사 TourAPI 다국어(영문) 이며 `scripts/fetch_medical_tourism.py`
* 가 수집·필터링해 `src/data/medicalTourism.json` 으로 낸다.
*
* 원칙: 없는 값을 만들지 않는다.
* - rating/reviewCount/openingHours 는 TourAPI 가 주지 않는다. Google Places 승인 후 채운다.
* 그때까지 null 이며 화면은 빈 값을 그대로 "미연동"으로 보여준다.
* - 수술 전후 식이 적합성은 병원이 입력한 가이드로만 표시한다. 여기서 추론하지 않는다.
*/
/** 병원 반경 안에서 찾은 장소 한 곳. */
export interface TourPlace {
id: string;
title: string;
address: string;
image: string | null;
tel: string | null;
lat: number | null;
lng: number | null;
/** 병원으로부터의 거리(m). TourAPI 가 준 값을 그대로 쓰고, 없으면 좌표로 계산한다. */
distanceM: number | null;
/** 아래 셋은 TourAPI 미제공. Google Places 승인 전까지 null 이다. */
rating: number | null;
reviewCount: number | null;
openingHours: string | null;
}
/** 축제·행사. 영문 서비스는 areacode 가 비어 있어 좌표 거리로 걸렀다. */
export interface TourFestival extends TourPlace {
startDate: string | null;
endDate: string | null;
distanceKm: number;
}
export type PlaceCategory =
| 'stay'
| 'restaurant'
| 'wellness'
| 'attraction'
| 'culture'
| 'shopping';
export interface MedicalTourismData {
places: Record<PlaceCategory, TourPlace[]>;
festivals: TourFestival[];
meta: {
source: string;
fetchedAt: string;
origin: { lat: number; lng: number; label: string; coordSource: string };
radiusByType: Record<string, number>;
festivalRadiusKm: number;
counts: Record<string, Record<string, unknown>>;
/** 화면에 그대로 표시한다. 한계를 숨기지 않는다. */
limits: string[];
};
}
/**
* 회복 단계. 며칠째인지는 의학 판단이므로 여기서 정하지 않는다.
* 이 단계는 "병원에서 얼마나 멀리 움직이는가"라는 이동 반경 기준이며,
* 각 단계가 수술 후 며칠에 해당하는지는 병원이 supporter_inputs 로 입력한다.
*/
export interface RecoveryStage {
id: string;
label: string;
/** 이 단계에서 권하는 이동 반경(m). 거리로만 정의하며 의학적 판단을 담지 않는다. */
maxDistanceM: number;
/** 이 단계에 배치할 장소 범주. */
categories: PlaceCategory[];
note: string;
}
/** 병원이 입력하는 값. 없으면 화면은 "병원 확인 대기"로 둔다. */
export interface ClinicRecoveryInput {
/** supporter_inputs.key = 'recovery' */
recoveryNote?: string;
/** supporter_inputs.key = 'diet_guide' */
dietGuide?: {
/** 회복 단계별 권장 음식 분류. 병원이 적은 그대로 쓴다. */
recommended?: string;
/** 회복 단계별 피해야 할 음식 분류. */
avoid?: string;
/** 단계가 며칠씩인지. */
stageDays?: string;
};
}