feat: real API integration + YouTube Data API v3 + progressive loading

- Replace mock useReport() with real Supabase API data pipeline
- Add transformReport.ts to map API responses to MarketingReport type
- Add useEnrichment() hook for background channel data enrichment
- Replace Apify YouTube scraper with YouTube Data API v3
- Add mergeEnrichment() for progressive data loading
- Add EmptyState component for graceful empty data handling
- Add socialHandles to generate-report metadata
- Graceful empty data in ClinicSnapshot, YouTube, Instagram, Facebook
- Add Supabase Edge Functions and DB migrations
- Add developer handoff documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 4.6 committed 2026-04-02 10:57:14 +09:00
1 parent c6e18b6a67
commit 60cd055042
30 files changed
+2905 -142

No files matched your search

+48 -40
View File
@@ -14,15 +14,15 @@ function formatNumber(n: number): string {
}
const infoFields = (data: ClinicSnapshotType) => [
{ label: '개원', value: `${data.established} (${data.yearsInBusiness}년)`, icon: Calendar },
{ label: '의료진', value: `${data.staffCount}명`, icon: Users },
{ label: '강남언니 평점', value: `${data.overallRating} / 5.0`, icon: Star },
{ label: '리뷰 수', value: formatNumber(data.totalReviews), icon: Star },
{ label: '시술 가격대', value: `${data.priceRange.min} ~ ${data.priceRange.max}`, icon: Globe },
{ label: '위치', value: `${data.location} (${data.nearestStation})`, icon: MapPin },
{ label: '전화', value: data.phone, icon: Phone },
{ label: '도메인', value: data.domain, icon: Globe },
];
data.established ? { label: '개원', value: `${data.established} (${data.yearsInBusiness}년)`, icon: Calendar } : null,
data.staffCount > 0 ? { label: '의료진', value: `${data.staffCount}명`, icon: Users } : null,
data.overallRating > 0 ? { label: '강남언니 평점', value: `${data.overallRating} / 5.0`, icon: Star } : null,
data.totalReviews > 0 ? { label: '리뷰 수', value: formatNumber(data.totalReviews), icon: Star } : null,
data.priceRange.min !== '-' ? { label: '시술 가격대', value: `${data.priceRange.min} ~ ${data.priceRange.max}`, icon: Globe } : null,
data.location ? { label: '위치', value: data.nearestStation ? `${data.location} (${data.nearestStation})` : data.location, icon: MapPin } : null,
data.phone ? { label: '전화', value: data.phone, icon: Phone } : null,
data.domain ? { label: '도메인', value: data.domain, icon: Globe } : null,
].filter((f): f is NonNullable<typeof f> => f !== null);
export default function ClinicSnapshot({ data }: ClinicSnapshotProps) {
const fields = infoFields(data);
@@ -55,38 +55,46 @@ export default function ClinicSnapshot({ data }: ClinicSnapshotProps) {
})}
</div>
{/* Lead Doctor Highlight */}
<motion.div
className="rounded-2xl bg-gradient-to-r from-[#4F1DA1]/5 to-[#021341]/5 border border-purple-100 p-6 mb-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.3 }}
>
<div className="flex items-center gap-2 mb-3">
<Award size={20} className="text-[#6C5CE7]" />
<h3 className="font-serif font-bold text-2xl text-[#0A1128]">대표 원장</h3>
</div>
<p className="text-xl font-bold text-[#0A1128] mb-1">{data.leadDoctor.name}</p>
<p className="text-sm text-slate-600 mb-3">{data.leadDoctor.credentials}</p>
<div className="flex items-center gap-4">
<div className="flex items-center gap-1">
{Array.from({ length: 5 }).map((_, i) => (
<Star
key={i}
size={16}
className={i < Math.round(data.leadDoctor.rating) ? 'text-[#6B2D8B] fill-[#6B2D8B]' : 'text-slate-200'}
/>
))}
<span className="text-sm font-semibold text-[#0A1128] ml-1">
{data.leadDoctor.rating}
</span>
{/* Lead Doctor Highlight — only show if doctor name exists */}
{data.leadDoctor.name && (
<motion.div
className="rounded-2xl bg-gradient-to-r from-[#4F1DA1]/5 to-[#021341]/5 border border-purple-100 p-6 mb-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.3 }}
>
<div className="flex items-center gap-2 mb-3">
<Award size={20} className="text-[#6C5CE7]" />
<h3 className="font-serif font-bold text-2xl text-[#0A1128]">대표 원장</h3>
</div>
<span className="text-sm text-slate-500">
리뷰 {formatNumber(data.leadDoctor.reviewCount)}건
</span>
</div>
</motion.div>
<p className="text-xl font-bold text-[#0A1128] mb-1">{data.leadDoctor.name}</p>
{data.leadDoctor.credentials && (
<p className="text-sm text-slate-600 mb-3">{data.leadDoctor.credentials}</p>
)}
{data.leadDoctor.rating > 0 && (
<div className="flex items-center gap-4">
<div className="flex items-center gap-1">
{Array.from({ length: 5 }).map((_, i) => (
<Star
key={i}
size={16}
className={i < Math.round(data.leadDoctor.rating) ? 'text-[#6B2D8B] fill-[#6B2D8B]' : 'text-slate-200'}
/>
))}
<span className="text-sm font-semibold text-[#0A1128] ml-1">
{data.leadDoctor.rating}
</span>
</div>
{data.leadDoctor.reviewCount > 0 && (
<span className="text-sm text-slate-500">
리뷰 {formatNumber(data.leadDoctor.reviewCount)}건
</span>
)}
</div>
)}
</motion.div>
)}
{/* Certifications */}
{data.certifications.length > 0 && (
+4
View File
@@ -325,6 +325,10 @@ function ConsolidationCard({ text }: { text: string }) {
/* ─── Main Component ─── */
export default function FacebookAudit({ data }: { data: FacebookAuditType }) {
const hasData = data.pages.length > 0 || data.diagnosis.length > 0;
if (!hasData) return null;
return (
<SectionWrapper id="facebook-audit" title="Facebook Analysis" subtitle="페이스북 페이지 분석">
{/* Page cards side by side */}
+13 -1
View File
@@ -1,6 +1,7 @@
import { motion } from 'motion/react';
import { Instagram, AlertCircle, FileText, Users, Eye } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import { EmptyState } from './ui/EmptyState';
import { MetricCard } from './ui/MetricCard';
import { DiagnosisRow } from './ui/DiagnosisRow';
import type { InstagramAudit as InstagramAuditType, InstagramAccount } from '../../types/report';
@@ -107,14 +108,25 @@ function AccountCard({ account, index }: { key?: string | number; account: Insta
}
export default function InstagramAudit({ data }: InstagramAuditProps) {
const hasAccounts = data.accounts.length > 0 && data.accounts.some(a => a.handle || a.followers > 0);
return (
<SectionWrapper id="instagram-audit" title="Instagram Analysis" subtitle="인스타그램 채널 분석">
{!hasAccounts && data.diagnosis.length === 0 && (
<EmptyState
message="Instagram 계정 데이터 수집 중"
subtext="채널 데이터 보강이 완료되면 계정 정보와 분석 결과가 표시됩니다."
/>
)}
{/* Account cards */}
{hasAccounts && (
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
{data.accounts.map((account, i) => (
<AccountCard key={account.handle} account={account} index={i} />
<AccountCard key={account.handle || i} account={account} index={i} />
))}
</div>
)}
{/* Diagnosis */}
{data.diagnosis.length > 0 && (
+12
View File
@@ -1,6 +1,7 @@
import { motion } from 'motion/react';
import { Youtube, Users, Video, Eye, TrendingUp, ExternalLink } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import { EmptyState } from './ui/EmptyState';
import { MetricCard } from './ui/MetricCard';
import { DiagnosisRow } from './ui/DiagnosisRow';
import type { YouTubeAudit as YouTubeAuditType } from '../../types/report';
@@ -16,8 +17,18 @@ function formatNumber(n: number): string {
}
export default function YouTubeAudit({ data }: YouTubeAuditProps) {
const hasData = data.subscribers > 0 || data.totalVideos > 0 || data.topVideos.length > 0 || data.diagnosis.length > 0;
return (
<SectionWrapper id="youtube-audit" title="YouTube Analysis" subtitle="유튜브 채널 분석">
{!hasData && (
<EmptyState
message="YouTube 채널 데이터 수집 중"
subtext="채널 데이터 보강이 완료되면 구독자, 영상, 조회수 정보가 표시됩니다."
/>
)}
{hasData && <>
{/* Metrics row */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
<MetricCard
@@ -172,6 +183,7 @@ export default function YouTubeAudit({ data }: YouTubeAuditProps) {
))}
</motion.div>
)}
</>}
</SectionWrapper>
);
}
+31
View File
@@ -0,0 +1,31 @@
import { motion } from 'motion/react';
import { Search } from 'lucide-react';
interface EmptyStateProps {
message?: string;
subtext?: string;
}
/**
* Shown inside report sections when data is not yet available
* (e.g., before enrichment completes or when a channel is not found).
*/
export function EmptyState({
message = '데이터 수집 중',
subtext = '채널 데이터 보강이 완료되면 자동으로 업데이트됩니다.',
}: EmptyStateProps) {
return (
<motion.div
className="flex flex-col items-center justify-center py-12 text-center"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.4 }}
>
<div className="w-12 h-12 rounded-2xl bg-slate-100 flex items-center justify-center mb-4">
<Search size={20} className="text-slate-400" />
</div>
<p className="text-sm font-medium text-slate-500">{message}</p>
<p className="text-xs text-slate-400 mt-1 max-w-xs">{subtext}</p>
</motion.div>
);
}