chore: 프론트엔드 마이그레이션 + 아키텍처 정의

- 백엔드 SDK 이전: FastAPI OpenAPI → orval 자동생성 (React Query 훅 포함)
- HTTP 어댑터: ky 기반 customFetcher, fetch httpClient 시그니처
- 아키텍처: features 모듈 / shared 레이어 컨벤션 정의
- 디자인 시스템: Tailwind v4 CSS-first 토큰 (브랜드 색 / status / shadcn)
- 커스텀 CSS: utilities / animations 를 custom.css 로 분리
- Docker: 개발(Dockerfile.dev + compose) / 프로덕션(nginx) 셋업
- README: 기술 스펙 / 프로젝트 구조 / 디자인 토큰 / 폰트 / SDK 사용법 정리

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 4.7 committed 2026-05-13 11:38:07 +09:00
commit e66b208318
219 files changed
+36881

No files matched your search

@@ -0,0 +1,76 @@
import type { ComponentType } from 'react';
import { motion } from 'motion/react';
import { Youtube, Instagram, Globe, Star, Facebook, Search } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import { ScoreRing } from './ui/ScoreRing';
import { SeverityBadge } from './ui/SeverityBadge';
import type { ChannelScore } from '@/features/report/types/report';
interface ChannelOverviewProps {
channels: ChannelScore[];
}
const iconMap: Record<string, ComponentType<{ size?: number; className?: string }>> = {
youtube: Youtube,
instagram: Instagram,
facebook: Facebook,
star: Star,
globe: Globe,
search: Search,
};
const channelLabel: Record<string, string> = {
naverBlog: '네이버 블로그',
naverPlace: '네이버 플레이스',
gangnamUnni: '강남언니',
instagram: 'Instagram',
youtube: 'YouTube',
facebook: 'Facebook',
website: '웹사이트',
tiktok: 'TikTok',
blog: '블로그',
};
const brandColor: Record<string, string> = {
facebook: '#1877F2',
instagram: '#E1306C',
youtube: '#FF0000',
globe: '#6B2D8B',
};
function getChannelColor(icon: string | undefined): string | undefined {
return brandColor[icon?.toLowerCase() ?? ''];
}
export default function ChannelOverview({ channels }: ChannelOverviewProps) {
return (
<SectionWrapper id="channel-overview" title="Channel Health Score" subtitle="채널별 건강도 종합">
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4">
{channels.map((ch, i) => {
const Icon = iconMap[ch.icon?.toLowerCase()] ?? Globe;
const color = getChannelColor(ch.icon);
return (
<motion.div
key={ch.channel}
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-4 text-center flex flex-col items-center gap-3"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: i * 0.08 }}
>
<div className="w-10 h-10 rounded-xl bg-slate-50 flex items-center justify-center">
<Icon size={20} style={color ? { color } : undefined} className={color ? '' : 'text-slate-500'} />
</div>
<p className="text-sm font-medium text-[#0A1128]">{channelLabel[ch.channel] || ch.channel}</p>
<ScoreRing score={ch.score} maxScore={ch.maxScore} size={60} color={color} />
<p className="text-xs text-slate-500 line-clamp-2 leading-relaxed">
{ch.headline}
</p>
<SeverityBadge severity={ch.status} />
</motion.div>
);
})}
</div>
</SectionWrapper>
);
}
@@ -0,0 +1,184 @@
import { motion } from 'motion/react';
import { Calendar, Users, MapPin, Phone, Award, Star, Globe, ExternalLink, Building2 } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import type { ClinicSnapshot as ClinicSnapshotType } from '@/features/report/types/report';
interface ClinicSnapshotProps {
data: ClinicSnapshotType;
}
function formatNumber(n: number): string {
return n.toLocaleString();
}
interface InfoField {
label: string;
value: string;
icon: typeof Calendar;
href?: string;
}
const infoFields = (data: ClinicSnapshotType): InfoField[] => [
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 ? `${data.overallRating} / 10` : `${data.overallRating} / 5.0`, icon: Star } : null,
data.totalReviews > 0 ? { label: '리뷰 수', value: formatNumber(data.totalReviews), icon: Star } : null,
data.registryData?.district ? { label: '지역구', value: data.registryData.district, icon: Building2 } : null,
data.location ? { label: '위치', value: data.nearestStation ? `${data.location} (${data.nearestStation})` : data.location, icon: MapPin } : null,
data.phone ? { label: '전화', value: data.phone, icon: Phone, href: `tel:${data.phone.replace(/[^+0-9]/g, '')}` } : null,
data.domain ? { label: '도메인', value: data.domain, icon: Globe, href: `https://${data.domain.replace(/^https?:\/\//, '')}` } : null,
data.registryData?.websiteEn ? { label: '영문 사이트', value: data.registryData.websiteEn, icon: Globe, href: data.registryData.websiteEn } : null,
].filter(Boolean) as InfoField[];
export default function ClinicSnapshot({ data }: ClinicSnapshotProps) {
const fields = infoFields(data);
const isVerified = data.source === 'registry';
return (
<SectionWrapper id="clinic-snapshot" title="Clinic Overview" subtitle="병원 기본 정보">
{/* 외부 검증 배지는 내부 관리용이므로 리포트에서 제외 */}
{/* Registry 외부 링크 (강남언니, 네이버 플레이스, 구글 맵) */}
{isVerified && (data.registryData?.naverPlaceUrl || data.registryData?.gangnamUnniUrl || data.registryData?.googleMapsUrl) && (
<motion.div
className="flex flex-wrap gap-2 mb-6"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.4, delay: 0.1 }}
>
{data.registryData?.gangnamUnniUrl && (
<a
href={data.registryData.gangnamUnniUrl}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1.5 rounded-lg bg-pink-50 border border-pink-200 px-3 py-1.5 text-xs font-medium text-pink-700 hover:bg-pink-100 transition-colors"
>
강남언니 <ExternalLink size={11} />
</a>
)}
{data.registryData?.naverPlaceUrl && (
<a
href={data.registryData.naverPlaceUrl}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1.5 rounded-lg bg-green-50 border border-green-200 px-3 py-1.5 text-xs font-medium text-green-700 hover:bg-green-100 transition-colors"
>
네이버 플레이스 <ExternalLink size={11} />
</a>
)}
{data.registryData?.googleMapsUrl && (
<a
href={data.registryData.googleMapsUrl}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1.5 rounded-lg bg-blue-50 border border-blue-200 px-3 py-1.5 text-xs font-medium text-blue-700 hover:bg-blue-100 transition-colors"
>
Google Maps <ExternalLink size={11} />
</a>
)}
</motion.div>
)}
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mb-8">
{fields.map((field, i) => {
const Icon = field.icon;
return (
<motion.div
key={field.label}
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-5"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: i * 0.05 }}
>
<div className="flex items-start gap-3">
<div className="shrink-0 w-8 h-8 rounded-lg bg-slate-50 flex items-center justify-center">
<Icon size={16} className="text-slate-400" />
</div>
<div className="min-w-0">
<p className="text-xs text-slate-500 uppercase tracking-wide">{field.label}</p>
{field.href ? (
<a
href={field.href}
target={field.href.startsWith('tel:') ? undefined : '_blank'}
rel="noopener noreferrer"
className="text-lg font-semibold text-[#0A1128] mt-1 hover:text-[#6C5CE7] inline-flex items-center gap-1.5"
>
{field.value}
{!field.href.startsWith('tel:') && <ExternalLink size={14} className="text-[#6C5CE7] shrink-0" />}
</a>
) : (
<p className="text-lg font-semibold text-[#0A1128] mt-1">{field.value}</p>
)}
</div>
</div>
</motion.div>
);
})}
</div>
{/* 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>
<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 && (
<motion.div
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.4 }}
>
<p className="text-sm font-semibold text-slate-700 mb-3">인증 및 자격</p>
<div className="flex flex-wrap gap-2">
{data.certifications.map((cert) => (
<span
key={cert}
className="rounded-full bg-white/60 backdrop-blur-sm border border-white/40 px-3 py-1 text-sm font-medium text-slate-700"
>
{cert}
</span>
))}
</div>
</motion.div>
)}
</SectionWrapper>
);
}
@@ -0,0 +1,367 @@
import { useState } from 'react';
import { motion } from 'motion/react';
import {
Facebook, AlertCircle, AlertTriangle, ExternalLink, CheckCircle2, XCircle,
ArrowRight, Link2, MessageCircle, TrendingUp, Eye, ImageIcon, Globe,
} from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import { SeverityBadge } from './ui/SeverityBadge';
import { EvidenceGallery } from './ui/EvidenceGallery';
import { Button } from '@/shared/ui/button';
import type {
FacebookAudit as FacebookAuditType,
FacebookPage,
BrandInconsistency,
DiagnosisItem,
} from '@/features/report/types/report';
function formatNumber(n: number): string {
return n.toLocaleString();
}
/* ─── Page Card ─── */
function PageCard({ page, index }: { key?: string | number; page: FacebookPage; index: number }) {
const isKR = page.language === 'KR';
const langColor = isKR ? 'bg-slate-100 text-slate-700' : 'bg-brand-tint-violet text-brand-purple-faint';
const isLogoMismatch = page.logo?.includes('불일치');
const isLowFollowers = page.followers < 500;
return (
<motion.div
className={`rounded-2xl border shadow-sm p-6 ${
isKR && isLowFollowers
? 'bg-brand-rose-bg/30 border-brand-rose-soft/60'
: 'bg-white border-slate-100'
}`}
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: index * 0.15 }}
>
{/* Header */}
<div className="flex items-center justify-between mb-4">
<div className="flex items-center gap-2">
<span className={`text-xs font-medium px-3 py-1 rounded-full ${langColor}`}>
{page.label}
</span>
<div className="w-8 h-8 rounded-lg bg-[#1877F2] flex items-center justify-center">
<Facebook size={16} className="text-white" />
</div>
</div>
{isKR && isLowFollowers && (
<span className="text-xs font-medium px-3 py-1 rounded-full bg-brand-rose-bg text-brand-rose">
방치 상태
</span>
)}
{page.hasWhatsApp && (
<span className="text-xs font-medium px-3 py-1 rounded-full bg-brand-tint-purple text-brand-purple-muted">
WhatsApp 연결
</span>
)}
</div>
<h3 className="font-bold text-lg text-brand-navy mb-1">
{page.url ? (
<a
href={
page.url.startsWith('http')
? page.url
: page.url.startsWith('facebook.com/') || page.url.startsWith('www.facebook.com/')
? `https://${page.url.replace(/^www\./, 'www.')}`
: `https://www.facebook.com/${page.url.replace(/^@/, '')}`
}
target="_blank"
rel="noopener noreferrer"
className="hover:text-brand-purple-vivid inline-flex items-center gap-1"
>
{page.pageName}
<ExternalLink size={13} className="text-brand-purple-vivid" />
</a>
) : page.pageName}
</h3>
<p className="text-xs text-slate-500 mb-4">{page.category}</p>
{/* Metrics grid */}
<div className="grid grid-cols-3 gap-2 mb-5">
<div className="rounded-xl bg-slate-50 p-3 text-center">
<p className="text-xs text-slate-400 uppercase tracking-wide">팔로워</p>
<p className={`text-lg font-bold ${isLowFollowers ? 'text-brand-rose' : 'text-brand-navy'}`}>
{formatNumber(page.followers)}
</p>
</div>
<div className="rounded-xl bg-slate-50 p-3 text-center">
<p className="text-xs text-slate-400 uppercase tracking-wide">리뷰</p>
<p className={`text-lg font-bold ${page.reviews === 0 ? 'text-brand-rose' : 'text-brand-navy'}`}>
{page.reviews}
</p>
</div>
<div className="rounded-xl bg-slate-50 p-3 text-center">
<p className="text-xs text-slate-400 uppercase tracking-wide">팔로잉</p>
<p className="text-lg font-bold text-brand-navy">{formatNumber(page.following)}</p>
</div>
</div>
{/* Detail rows */}
<div className="space-y-3 mb-5 text-sm">
<div className="flex items-center justify-between py-1 border-b border-slate-100 last:border-0">
<span className="text-slate-500 flex items-center gap-2"><Eye size={13} /> 최근 게시물</span>
<span className="font-medium text-brand-navy">{page.recentPostAge}</span>
</div>
{page.postFrequency && (
<div className="flex items-center justify-between py-1 border-b border-slate-100 last:border-0">
<span className="text-slate-500 flex items-center gap-2"><TrendingUp size={13} /> 게시 빈도</span>
<span className="font-medium text-brand-navy">{page.postFrequency}</span>
</div>
)}
{page.topContentType && (
<div className="flex items-center justify-between py-1 border-b border-slate-100 last:border-0">
<span className="text-slate-500 flex items-center gap-2"><ImageIcon size={13} /> 콘텐츠 유형</span>
<span className="font-medium text-brand-navy text-right text-xs max-w-[180px]">{page.topContentType}</span>
</div>
)}
{page.engagement && (
<div className="flex items-center justify-between py-1 border-b border-slate-100 last:border-0">
<span className="text-slate-500 flex items-center gap-2"><MessageCircle size={13} /> 참여율</span>
<span className={`font-medium text-right text-xs max-w-[180px] ${
page.engagement.includes('0~3') ? 'text-brand-rose' : 'text-brand-navy'
}`}>{page.engagement}</span>
</div>
)}
</div>
{/* Logo analysis - the enhanced version */}
<div className={`rounded-xl p-4 mb-4 ${
isLogoMismatch
? 'bg-brand-rose-bg border border-brand-rose-soft'
: 'bg-brand-tint-purple border border-brand-tint-lavender'
}`}>
<div className="flex items-start gap-2 mb-2">
{isLogoMismatch
? <AlertTriangle size={16} className="text-brand-rose shrink-0 mt-1" />
: <CheckCircle2 size={16} className="text-brand-purple-soft shrink-0 mt-1" />
}
<p className={`text-sm font-semibold ${isLogoMismatch ? 'text-brand-rose' : 'text-brand-purple-muted'}`}>
로고 {page.logo}
</p>
</div>
<p className={`text-xs leading-relaxed ml-6 ${isLogoMismatch ? 'text-brand-rose' : 'text-brand-purple-muted'}`}>
{page.logoDescription}
</p>
</div>
{/* Domain link */}
<div className="rounded-xl bg-slate-50 p-3 mb-4">
<div className="flex items-center gap-2 mb-1">
<Link2 size={12} className="text-slate-400" />
<p className="text-xs text-slate-400 uppercase tracking-wide">연결 도메인</p>
</div>
<p className={`text-sm font-mono ${
page.linkedDomain?.includes('다름') ? 'text-brand-earth' : 'text-slate-700'
}`}>
{page.linkedDomain || page.link}
</p>
</div>
{/* Bio */}
<div className="rounded-xl bg-slate-50 p-3 mb-4">
<p className="text-xs text-slate-400 uppercase tracking-wide mb-1">Bio</p>
<p className="text-sm text-slate-600 italic">"{page.bio}"</p>
</div>
{/* Link moved to page name header */}
</motion.div>
);
}
/* ─── Brand Inconsistency Map ─── */
function BrandConsistencyMap({ inconsistencies }: { inconsistencies: BrandInconsistency[] }) {
const [expanded, setExpanded] = useState<number | null>(0);
return (
<motion.div
className="mt-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.3 }}
>
<h3 className="font-serif font-bold text-xl text-brand-navy mb-2">Brand Consistency Map</h3>
<p className="text-sm text-slate-500 mb-5">전 채널 브랜드 일관성 분석</p>
<div className="space-y-3">
{inconsistencies.map((item, i) => (
<div
key={item.field}
className="rounded-2xl border border-slate-100 bg-white shadow-sm overflow-hidden"
>
{/* Header - clickable */}
<Button
type="button"
variant="ghost"
onClick={() => setExpanded(expanded === i ? null : i)}
className="w-full flex items-center justify-between p-5 h-auto text-left hover:bg-slate-50/50 rounded-none"
>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-lg bg-primary-900 flex items-center justify-center text-white text-xs font-bold">
{item.values.filter(v => !v.isCorrect).length}
</div>
<div>
<p className="font-semibold text-brand-navy">{item.field}</p>
<p className="text-xs text-slate-500">
{item.values.filter(v => !v.isCorrect).length}개 채널 불일치
</p>
</div>
</div>
<ArrowRight
size={16}
className={`text-slate-400 transition-transform ${expanded === i ? 'rotate-90' : ''}`}
/>
</Button>
{/* Expanded content */}
{expanded === i && (
<div className="px-5 pb-5 border-t border-slate-100">
{/* Channel values */}
<div className="grid gap-2 mt-4 mb-4">
{item.values.map((v) => (
<div
key={v.channel}
className={`flex items-center justify-between py-3 px-3 rounded-lg text-sm ${
v.isCorrect ? 'bg-brand-tint-purple/60' : 'bg-brand-rose-bg/60'
}`}
>
<span className="font-medium text-slate-700 min-w-[100px]">{v.channel}</span>
<span className={`flex-1 text-right ${v.isCorrect ? 'text-brand-purple-muted' : 'text-brand-rose'}`}>
{v.value}
</span>
<span className="ml-3">
{v.isCorrect
? <CheckCircle2 size={15} className="text-brand-purple-soft" />
: <XCircle size={15} className="text-brand-rose-mid" />
}
</span>
</div>
))}
</div>
{/* Impact */}
<div className="rounded-xl bg-brand-earth-bg border border-brand-earth-soft p-4 mb-3">
<p className="text-xs font-semibold text-brand-earth uppercase tracking-wide mb-1">
<AlertCircle size={12} className="inline mr-1" />
Impact
</p>
<p className="text-sm text-brand-earth">{item.impact}</p>
</div>
{/* Recommendation */}
<div className="rounded-xl bg-brand-tint-purple border border-brand-tint-lavender p-4">
<p className="text-xs font-semibold text-brand-purple-muted uppercase tracking-wide mb-1">
<CheckCircle2 size={12} className="inline mr-1" />
Recommendation
</p>
<p className="text-sm text-brand-purple-muted">{item.recommendation}</p>
</div>
</div>
)}
</div>
))}
</div>
</motion.div>
);
}
/* ─── Diagnosis Section ─── */
function DiagnosisSection({ items }: { items: DiagnosisItem[] }) {
return (
<motion.div
className="mt-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.4 }}
>
<h3 className="font-serif font-bold text-xl text-brand-navy mb-2">진단 결과</h3>
<p className="text-sm text-slate-500 mb-4">Facebook 채널 문제점</p>
<div className="rounded-2xl border border-slate-100 bg-white shadow-sm overflow-hidden">
{items.map((item, i) => (
<div
key={i}
className={`p-5 ${
i < items.length - 1 ? 'border-b border-slate-100' : ''
}`}
>
<div className="flex items-start gap-4">
<div className="min-w-[120px] md:min-w-[160px]">
<p className="font-semibold text-sm text-brand-navy">{item.category}</p>
</div>
<p className="flex-1 text-sm text-slate-600">{item.detail}</p>
<div className="shrink-0">
<SeverityBadge severity={item.severity} />
</div>
</div>
{item.evidenceIds && item.evidenceIds.length > 0 && (
<EvidenceGallery evidenceIds={item.evidenceIds} compact />
)}
</div>
))}
</div>
</motion.div>
);
}
/* ─── Consolidation Recommendation ─── */
function ConsolidationCard({ text }: { text: string }) {
return (
<motion.div
className="mt-8 rounded-2xl bg-gradient-to-r from-brand-purple to-brand-purple-deep p-6 md:p-8 text-white"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.5 }}
>
<div className="flex items-start gap-3">
<div className="w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0">
<Globe size={20} className="text-white" />
</div>
<div>
<h4 className="font-serif font-bold text-2xl mb-2">통합 권장 사항</h4>
<p className="text-sm text-purple-200 leading-relaxed">{text}</p>
</div>
</div>
</motion.div>
);
}
/* ─── 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 */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
{data.pages.map((page, i) => (
<PageCard key={page.pageName} page={page} index={i} />
))}
</div>
{/* Brand Consistency Map - the new enhanced section */}
{data.brandInconsistencies && data.brandInconsistencies.length > 0 && (
<BrandConsistencyMap inconsistencies={data.brandInconsistencies} />
)}
{/* Diagnosis table */}
{data.diagnosis && data.diagnosis.length > 0 && (
<DiagnosisSection items={data.diagnosis} />
)}
{/* Consolidation recommendation */}
{data.consolidationRecommendation && (
<ConsolidationCard text={data.consolidationRecommendation} />
)}
</SectionWrapper>
);
}
@@ -0,0 +1,158 @@
import { motion } from 'motion/react';
import { Instagram, AlertCircle, FileText, Users, Eye, 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 { InstagramAudit as InstagramAuditType, InstagramAccount } from '@/features/report/types/report';
interface InstagramAuditProps {
data: InstagramAuditType;
}
function formatNumber(n: number): string {
return n.toLocaleString();
}
function AccountCard({ account, index }: { key?: string | number; account: InstagramAccount; index: number }) {
const langColor = account.language === 'KR'
? 'bg-slate-100 text-slate-700'
: 'bg-[#EFF0FF] text-[#3A3F7C]';
return (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: index * 0.1 }}
>
{/* Language badge + handle */}
<div className="flex items-center gap-2 mb-4">
<span className={`text-xs font-medium px-3 py-1 rounded-full ${langColor}`}>
{account.label}
</span>
<div className="w-8 h-8 rounded-lg bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center">
<Instagram size={16} className="text-white" />
</div>
</div>
<h3 className="font-bold text-lg text-[#0A1128] mb-1">
{account.handle ? (
<a
href={`https://instagram.com/${account.handle.replace(/^@/, '')}`}
target="_blank"
rel="noopener noreferrer"
className="hover:text-[#6C5CE7] inline-flex items-center gap-1"
>
{account.handle}
<ExternalLink size={13} className="text-[#6C5CE7]" />
</a>
) : account.handle}
</h3>
<p className="text-xs text-slate-500 mb-4">{account.category}</p>
{/* Compact metrics */}
<div className="grid grid-cols-3 gap-2 mb-4">
<div className="rounded-xl bg-slate-50 p-3 text-center">
<p className="text-xs text-slate-500">게시물</p>
<p className="text-lg font-bold text-[#0A1128]">{formatNumber(account.posts)}</p>
</div>
<div className="rounded-xl bg-slate-50 p-3 text-center">
<p className="text-xs text-slate-500">팔로워</p>
<p className="text-lg font-bold text-[#0A1128]">{formatNumber(account.followers)}</p>
</div>
<div className="rounded-xl bg-slate-50 p-3 text-center">
<p className="text-xs text-slate-500">팔로잉</p>
<p className="text-lg font-bold text-[#0A1128]">{formatNumber(account.following)}</p>
</div>
</div>
{/* Format & reels */}
<div className="space-y-2 mb-4">
<div className="flex items-center justify-between text-sm">
<span className="text-slate-500">콘텐츠 포맷</span>
<span className="font-medium text-[#0A1128]">{account.contentFormat}</span>
</div>
<div className="flex items-center justify-between text-sm">
<span className="text-slate-500">릴스 수</span>
<span className={`font-medium ${account.reelsCount === 0 ? 'text-[#7C3A4B]' : 'text-[#0A1128]'}`}>
{account.reelsCount === 0 ? (
<span className="inline-flex items-center gap-1">
<AlertCircle size={14} className="text-[#D4889A]" />
0 (미운영)
</span>
) : (
account.reelsCount
)}
</span>
</div>
</div>
{/* Highlights */}
{account.highlights.length > 0 && (
<div className="mb-4">
<p className="text-xs text-slate-500 mb-2">하이라이트</p>
<div className="flex flex-wrap gap-2">
{account.highlights.map((h) => (
<span
key={h}
className="rounded-full bg-white/60 backdrop-blur-sm border border-white/40 px-3 py-1 text-sm font-medium text-slate-700"
>
{h}
</span>
))}
</div>
</div>
)}
{/* Bio */}
{account.bio && (
<div className="rounded-xl bg-slate-50 p-3">
<p className="text-xs text-slate-400 mb-1">Bio</p>
<p className="text-sm text-slate-600 whitespace-pre-line">{account.bio}</p>
</div>
)}
</motion.div>
);
}
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 || i} account={account} index={i} />
))}
</div>
)}
{/* Diagnosis */}
{data.diagnosis.length > 0 && (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.3 }}
>
<p className="text-sm font-semibold text-slate-700 mb-4">진단 결과</p>
{data.diagnosis.map((item, i) => (
<DiagnosisRow key={i} category={item.category} detail={item.detail} severity={item.severity} evidenceIds={item.evidenceIds} />
))}
</motion.div>
)}
</SectionWrapper>
);
}
@@ -0,0 +1,132 @@
import { motion } from 'motion/react';
import { useParams, useNavigate } from 'react-router';
import { TrendingUp, ArrowUpRight, Download, Loader2 } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import { Button } from '@/shared/ui/button';
import { useExportPDF } from '@/features/report/hooks/useExportPDF';
import type { KPIMetric } from '@/features/report/types/report';
interface KPIDashboardProps {
metrics: KPIMetric[];
clinicName?: string;
}
function isNegativeValue(value: string | number): boolean {
const lower = String(value).toLowerCase();
return lower === '0' || lower.includes('없음') || lower.includes('불가') || lower === 'n/a' || lower === '-' || lower.includes('측정 불가');
}
/** 가독성을 위해 큰 숫자 포맷팅: 150000 → 150K, 1500000 → 1.5M */
function formatKpiValue(value: string | number): string {
const str = String(value ?? '');
// 이미 포맷된 경우(K, M, %, ~, 월, 건 등 포함) 그대로 반환
if (/[KkMm%~월건회개명/]/.test(str)) return str;
// 순수 숫자로 파싱 시도
const num = parseInt(str.replace(/,/g, ''), 10);
if (isNaN(num)) return str;
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
if (num >= 10_000) return `${Math.round(num / 1_000)}K`;
if (num >= 1_000) return `${(num / 1_000).toFixed(1)}K`;
return str;
}
export default function KPIDashboard({ metrics, clinicName }: KPIDashboardProps) {
const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
const { exportPDF, isExporting } = useExportPDF();
return (
<SectionWrapper id="kpi-dashboard" title="KPI Dashboard" subtitle="핵심 성과 지표 목표">
{/* KPI Table */}
<motion.div
className="rounded-2xl overflow-hidden border border-slate-100 mb-10"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5 }}
>
{/* Header */}
<div className="grid grid-cols-4 bg-brand-navy text-white">
<div className="px-6 py-4 text-sm font-semibold">Metric</div>
<div className="px-6 py-4 text-sm font-semibold">Current</div>
<div className="px-6 py-4 text-sm font-semibold">3-Month Target</div>
<div className="px-6 py-4 text-sm font-semibold">12-Month Target</div>
</div>
{/* Data rows */}
{metrics.map((metric, i) => (
<motion.div
key={metric.metric}
className={`grid grid-cols-4 items-center ${i % 2 === 0 ? 'bg-white' : 'bg-slate-50/60'} border-b border-slate-100 last:border-b-0`}
initial={{ opacity: 0, y: 10 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.3, delay: i * 0.03 }}
>
<div className="px-6 py-4 text-sm font-medium text-brand-navy">{metric.metric}</div>
<div
className={`px-6 py-4 text-sm font-semibold ${
isNegativeValue(metric.current) ? 'text-brand-rose' : 'text-brand-navy'
}`}
>
{formatKpiValue(metric.current)}
</div>
<div className="px-6 py-4 text-sm font-medium text-brand-purple-muted">{formatKpiValue(metric.target3Month)}</div>
<div className="px-6 py-4 text-sm font-medium text-brand-purple-muted">{formatKpiValue(metric.target12Month)}</div>
</motion.div>
))}
</motion.div>
{/* CTA Card */}
<motion.div
data-cta-card
className="rounded-2xl bg-gradient-to-r from-brand-grad-peach via-brand-grad-violet to-brand-grad-sky p-8 md:p-12 text-center relative overflow-hidden"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.6, delay: 0.3 }}
>
<div className="relative">
<div className="w-14 h-14 rounded-2xl bg-brand-purple-deep/10 flex items-center justify-center mx-auto mb-6">
<TrendingUp size={28} className="text-brand-purple-deep" />
</div>
<h3 className="font-serif text-2xl md:text-3xl font-bold text-brand-purple-deep mb-3">
Start Your Transformation
</h3>
<p className="text-brand-purple-deep/60 mb-8 max-w-xl mx-auto">
INFINITH와 함께 데이터 기반 마케팅 전환을 시작하세요. 90일 안에 측정 가능한 성과를 만들어 드립니다.
</p>
<div className="flex flex-col sm:flex-row items-center justify-center gap-4">
<Button
type="button"
onClick={() => navigate(`/plan/${id || 'live'}#branding-guide`)}
className="inline-flex items-center gap-2 bg-gradient-to-r from-brand-purple to-brand-purple-deep text-white font-semibold px-8 py-4 h-auto rounded-full hover:from-brand-purple hover:to-brand-purple-deep hover:shadow-xl"
>
마케팅 기획
<ArrowUpRight size={18} />
</Button>
<Button
type="button"
variant="outline"
onClick={() => exportPDF(`INFINITH_Marketing_Report_${clinicName || 'Report'}`)}
disabled={isExporting}
className="inline-flex items-center gap-2 bg-white border-slate-200 text-brand-purple-deep font-semibold px-8 py-4 h-auto rounded-full hover:bg-slate-50 shadow-sm hover:shadow-md disabled:opacity-60 disabled:cursor-not-allowed"
>
{isExporting ? (
<>
<Loader2 size={18} className="animate-spin" />
내보내는 중...
</>
) : (
<>
<Download size={18} />
리포트 다운로드
</>
)}
</Button>
</div>
</div>
</motion.div>
</SectionWrapper>
);
}
@@ -0,0 +1,157 @@
import { motion } from 'motion/react';
import { CheckCircle2, XCircle, HelpCircle, ExternalLink, AlertCircle, Globe, Shield } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import type { OtherChannel, WebsiteAudit } from '@/features/report/types/report';
interface OtherChannelsProps {
channels: OtherChannel[];
website: WebsiteAudit;
}
const statusConfig = {
active: { icon: CheckCircle2, color: 'text-[#9B8AD4]', label: '활성' },
inactive: { icon: XCircle, color: 'text-[#D4889A]', label: '비활성' },
unknown: { icon: HelpCircle, color: 'text-slate-400', label: '미확인' },
not_found: { icon: XCircle, color: 'text-[#D4889A]', label: '미발견' },
};
export default function OtherChannels({ channels, website }: OtherChannelsProps) {
return (
<SectionWrapper id="other-channels" title="Other Channels & Website" subtitle="기타 채널 및 웹사이트 기술 진단">
{/* Other Channels */}
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm overflow-hidden mb-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5 }}
>
<div className="px-6 py-4 border-b border-slate-100">
<h3 className="font-serif font-bold text-2xl text-[#0A1128]">기타 채널 현황</h3>
</div>
<div className="divide-y divide-slate-100">
{channels.map((ch, i) => {
const cfg = statusConfig[ch.status];
const StatusIcon = cfg.icon;
return (
<motion.div
key={ch.name}
className="flex items-center gap-4 px-6 py-4"
initial={{ opacity: 0, x: -10 }}
whileInView={{ opacity: 1, x: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.3, delay: i * 0.05 }}
>
<StatusIcon size={20} className={cfg.color} />
<div className="flex-1 min-w-0">
{ch.url ? (
<a
href={ch.url.startsWith('http') ? ch.url : `https://${ch.url}`}
target="_blank"
rel="noopener noreferrer"
className="text-sm font-semibold text-[#0A1128] hover:text-[#6C5CE7] inline-flex items-center gap-1"
>
{ch.name}
<ExternalLink size={12} className="text-[#6C5CE7] shrink-0" />
</a>
) : (
<p className="text-sm font-semibold text-[#0A1128]">{ch.name}</p>
)}
<p className="text-sm text-slate-500">{ch.details}</p>
</div>
<span className={`text-xs font-medium ${cfg.color}`}>{cfg.label}</span>
</motion.div>
);
})}
</div>
</motion.div>
{/* Website Tech Audit */}
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.2 }}
>
<div className="flex items-center gap-2 mb-6">
<Globe size={20} className="text-[#6C5CE7]" />
<h3 className="font-serif font-bold text-2xl text-[#0A1128]">웹사이트 기술 진단</h3>
</div>
{/* Domain info */}
<div className="rounded-xl bg-slate-50 p-4 mb-6">
<p className="text-sm font-semibold text-[#0A1128] mb-2">기본 도메인: {website.primaryDomain}</p>
{website.additionalDomains.length > 0 && (
<div className="mt-2 space-y-1">
{website.additionalDomains.map((d) => (
<p key={d.domain} className="text-sm text-slate-600">
{d.domain} — <span className="text-slate-400">{d.purpose}</span>
</p>
))}
</div>
)}
<p className="text-sm text-slate-500 mt-2">
주요 CTA: <span className="font-medium text-[#0A1128]">{website.mainCTA}</span>
</p>
</div>
{/* Tracking Pixels */}
<div className="mb-6">
<p className="text-sm font-semibold text-slate-700 mb-3">트래킹 픽셀 설치 현황</p>
<div className="grid grid-cols-2 md:grid-cols-3 gap-3">
{website.trackingPixels.map((pixel) => (
<div
key={pixel.name}
className={`flex items-center gap-2 rounded-xl p-3 ${
pixel.installed
? 'bg-[#F3F0FF] border border-[#D5CDF5]'
: 'bg-[#FFF0F0] border border-[#F5D5DC]'
}`}
>
{pixel.installed ? (
<CheckCircle2 size={16} className="text-[#9B8AD4] shrink-0" />
) : (
<XCircle size={16} className="text-[#D4889A] shrink-0" />
)}
<div className="min-w-0">
<p className={`text-sm font-medium ${pixel.installed ? 'text-[#4A3A7C]' : 'text-[#7C3A4B]'}`}>
{pixel.name}
</p>
{pixel.details && (
<p className="text-xs text-slate-500 truncate">{pixel.details}</p>
)}
</div>
</div>
))}
</div>
</div>
{/* SNS Links Status */}
{!website.snsLinksOnSite && (
<motion.div
className="rounded-xl bg-[#FFF0F0] border border-[#F5D5DC] p-4 flex items-start gap-3"
initial={{ opacity: 0, scale: 0.95 }}
whileInView={{ opacity: 1, scale: 1 }}
viewport={{ once: true }}
transition={{ duration: 0.4, delay: 0.3 }}
>
<AlertCircle size={20} className="text-[#7C3A4B] shrink-0 mt-1" />
<div>
<p className="text-sm font-bold text-[#7C3A4B]">홈페이지에 SNS 링크 없음</p>
<p className="text-sm text-[#7C3A4B] mt-1">
웹사이트에서 소셜 미디어 채널로의 연결이 없습니다. 방문자가 SNS를 통해 브랜드와 연결할 수 없습니다.
</p>
</div>
</motion.div>
)}
{website.snsLinksOnSite && (
<div className="rounded-xl bg-[#F3F0FF] border border-[#D5CDF5] p-4 flex items-center gap-3">
<CheckCircle2 size={20} className="text-[#9B8AD4]" />
<p className="text-sm font-medium text-[#4A3A7C]">홈페이지에 SNS 링크 연결됨</p>
</div>
)}
</motion.div>
</SectionWrapper>
);
}
@@ -0,0 +1,179 @@
import { motion } from 'motion/react';
import { SectionWrapper } from './ui/SectionWrapper';
import { ShieldFilled, FileTextFilled, LinkExternalFilled } from '@/shared/icons/FilledIcons';
import type { DiagnosisItem } from '@/features/report/types/report';
interface ProblemDiagnosisProps {
diagnosis: DiagnosisItem[];
}
/**
* 개별 진단 항목들을 3개의 핵심 문제 클러스터로 그룹화.
* AI가 세분화된 항목을 다수 생성할 수 있으므로, 레퍼런스 디자인이
* 보여주는 핵심 전략 버킷으로 묶어줌.
*/
function clusterDiagnosis(items: DiagnosisItem[]): {
icon: typeof ShieldFilled;
title: string;
detail: string;
}[] {
// 3개의 전략 버킷으로 항목 분류
const brandItems: string[] = [];
const contentItems: string[] = [];
const funnelItems: string[] = [];
for (const item of items) {
const cat = String(item.category ?? '').toLowerCase();
const det = String(item.detail ?? '').toLowerCase();
// 브랜드 아이덴티티 / 일관성 이슈
if (
cat.includes('brand') || cat.includes('로고') ||
det.includes('로고') || det.includes('프로필') || det.includes('아이덴티티') ||
det.includes('일관') || det.includes('통일') || det.includes('브랜드') ||
det.includes('비주얼') || det.includes('identity') || det.includes('brand')
) {
brandItems.push(item.detail);
}
// 콘텐츠 / 전략 이슈
else if (
det.includes('콘텐츠') || det.includes('업로드') || det.includes('포스팅') ||
det.includes('릴스') || det.includes('shorts') || det.includes('영상') ||
det.includes('게시물') || det.includes('전략') || det.includes('content') ||
det.includes('카드뉴스') || det.includes('크로스') || det.includes('캘린더') ||
cat.includes('youtube') || cat.includes('instagram') || cat.includes('콘텐츠')
) {
contentItems.push(item.detail);
}
// 퍼널 / 크로스 플랫폼 / 전환 이슈
else {
funnelItems.push(item.detail);
}
}
// 분배가 잘 안 됐을 경우 균형 맞추기
if (brandItems.length === 0 && items.length > 0) {
brandItems.push(items[0]?.detail || '채널 간 브랜드 비주얼이 통일되지 않았습니다.');
}
if (contentItems.length === 0 && items.length > 1) {
contentItems.push(items[1]?.detail || '콘텐츠 전략 수립이 필요합니다.');
}
if (funnelItems.length === 0 && items.length > 2) {
funnelItems.push(items[2]?.detail || '플랫폼 간 유입 전환이 단절되어 있습니다.');
}
return [
{
icon: ShieldFilled,
title: '브랜드 아이덴티티 파편화',
detail:
brandItems.length > 0
? brandItems.slice(0, 3).join(' — ')
: '공식 검증 로고/타이포+골드는 Facebook KR에 웹사이트에만 적용, YouTube/Instagram에서 각각 다른 로고 사용 — 채널별로 4종 이상 다른 시각 아이덴티티가 사용됩니다.',
},
{
icon: FileTextFilled,
title: '콘텐츠 전략 부재',
detail:
contentItems.length > 0
? contentItems.slice(0, 3).join(' — ')
: '콘텐츠 캘린더가 없음, 콘텐츠 기/가이드 없음, KR+EN 시장 타겟 전략 없음. YouTube→Instagram 크로스 포스팅 부재.',
},
{
icon: LinkExternalFilled,
title: '플랫폼 간 유입 단절',
detail:
funnelItems.length > 0
? funnelItems.slice(0, 3).join(' — ')
: 'YouTube 10만+ → Instagram 1.4K 전환 실패, 웹사이트에서 SNS 유입 3% 미만, 상담전환 동선 부재.',
},
];
}
export default function ProblemDiagnosis({ diagnosis }: ProblemDiagnosisProps) {
if (!diagnosis || !Array.isArray(diagnosis) || diagnosis.length === 0) {
return null;
}
const clusters = clusterDiagnosis(diagnosis);
return (
<SectionWrapper id="problem-diagnosis" title="Critical Issues" subtitle="핵심 문제 진단" dark>
{/* Core 3 problem cards — large, prominent */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
{clusters.map((cluster, i) => {
const Icon = cluster.icon;
// 항목이 3개일 때 첫 카드는 md 화면에서 전체 너비 사용
const isWide = i === 2;
return (
<motion.div
key={i}
className={`relative rounded-2xl border border-white/10 bg-white/[0.06] backdrop-blur-md p-7 overflow-hidden ${
isWide ? 'md:col-span-2' : ''
}`}
initial={{ opacity: 0, y: 24 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: i * 0.12 }}
>
{/* Glow accent */}
<div className="absolute -top-6 -right-6 w-24 h-24 bg-[#C084CF]/20 rounded-full blur-2xl pointer-events-none" />
<div className="flex items-start gap-4">
<div className="shrink-0 w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center">
<Icon size={20} className="text-[#E8B4C0]" />
</div>
<div className="min-w-0">
<h3 className="text-lg font-bold text-white mb-2 leading-snug">{cluster.title}</h3>
<p className="text-sm text-purple-200/80 leading-relaxed">{cluster.detail}</p>
</div>
</div>
{/* Severity indicator dot */}
<div className="absolute top-4 right-4">
<span className="block w-3 h-3 rounded-full bg-[#C084CF] shadow-[0_0_8px_rgba(192,132,207,0.6)]" />
</div>
</motion.div>
);
})}
</div>
{/* Detailed diagnosis items — compact list below */}
{diagnosis.length > 3 && (
<motion.div
className="rounded-2xl border border-white/10 bg-white/[0.04] backdrop-blur-sm overflow-hidden"
initial={{ opacity: 0, y: 16 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.4 }}
>
<div className="px-6 py-3 border-b border-white/10">
<h4 className="text-xs uppercase tracking-wider text-purple-300/60 font-semibold">
세부 진단 항목 ({diagnosis.length}건)
</h4>
</div>
<div className="divide-y divide-white/5">
{diagnosis.map((item, i) => (
<div key={i} className="flex items-start gap-3 px-6 py-3">
<span
className={`shrink-0 mt-2 block w-2 h-2 rounded-full ${
item.severity === 'critical'
? 'bg-[#E8B4C0]'
: item.severity === 'warning'
? 'bg-[#8B9CF7]'
: item.severity === 'good'
? 'bg-[#7C6DD8]'
: 'bg-slate-400'
}`}
/>
<div className="min-w-0">
<span className="text-xs font-medium text-purple-300/50 mr-2">{item.category}</span>
<span className="text-sm text-purple-100/80">{item.detail}</span>
</div>
</div>
))}
</div>
</motion.div>
)}
</SectionWrapper>
);
}
@@ -0,0 +1,155 @@
import { motion } from 'motion/react';
import { Calendar, Globe, MapPin } from 'lucide-react';
import { ScoreRing } from './ui/ScoreRing';
function formatDate(raw: string): string {
try {
return new Date(raw).toLocaleDateString('ko-KR', {
year: 'numeric',
month: 'long',
day: 'numeric',
});
} catch {
return raw;
}
}
interface ReportHeaderProps {
clinicName: string;
clinicNameEn: string;
overallScore: number;
date: string;
targetUrl: string;
location: string;
logoImage?: string;
brandColors?: { primary: string; accent: string; text: string };
}
export default function ReportHeader({
clinicName,
logoImage,
brandColors,
clinicNameEn,
overallScore,
date,
targetUrl,
location,
}: ReportHeaderProps) {
return (
<section className="relative overflow-hidden bg-[radial-gradient(ellipse_at_top_left,#e0e7ff,transparent_50%),radial-gradient(ellipse_at_bottom_right,#fce7f3,transparent_50%),radial-gradient(ellipse_at_center,#f5f3ff,transparent_60%)] py-20 px-6">
{/* Animated blobs */}
<motion.div
className="absolute top-10 left-10 w-72 h-72 rounded-full bg-indigo-200/30 blur-3xl"
animate={{ x: [0, 30, 0], y: [0, -20, 0] }}
transition={{ duration: 8, repeat: Infinity, ease: 'easeInOut' }}
/>
<motion.div
className="absolute bottom-10 right-10 w-96 h-96 rounded-full bg-pink-200/30 blur-3xl"
animate={{ x: [0, -20, 0], y: [0, 30, 0] }}
transition={{ duration: 10, repeat: Infinity, ease: 'easeInOut' }}
/>
<motion.div
className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-80 h-80 rounded-full bg-purple-200/20 blur-3xl"
animate={{ scale: [1, 1.1, 1] }}
transition={{ duration: 6, repeat: Infinity, ease: 'easeInOut' }}
/>
<div className="relative max-w-7xl mx-auto">
<div className="flex flex-col md:flex-row items-center md:items-start justify-between gap-10">
{/* Left: Text content */}
<motion.div
className="flex-1 text-center md:text-left"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5 }}
>
<motion.p
className="font-serif text-3xl md:text-4xl font-normal text-[#6C5CE7] mb-4 tracking-wide"
initial={{ opacity: 0, y: 10 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.1 }}
>
Marketing Intelligence Report
</motion.p>
{logoImage && (
<motion.div
className="mb-4"
initial={{ opacity: 0, scale: 0.9 }}
whileInView={{ opacity: 1, scale: 1 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.15 }}
>
<img
src={logoImage}
alt={clinicName}
className="h-16 md:h-20 w-auto object-contain md:mx-0 mx-auto"
onError={(e) => { (e.target as HTMLImageElement).style.display = 'none'; }}
/>
</motion.div>
)}
<motion.h1
className="font-serif text-4xl md:text-5xl font-bold text-[#0A1128] mb-3"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.2 }}
>
{clinicName}
</motion.h1>
<motion.p
className="text-lg text-slate-600 mb-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.3 }}
>
{clinicNameEn}
</motion.p>
<motion.div
className="flex flex-wrap gap-3 justify-center md:justify-start"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.4 }}
>
<span className="inline-flex items-center gap-2 rounded-full bg-white/60 backdrop-blur-sm border border-white/40 px-3 py-1 text-sm font-medium text-slate-700">
<Calendar size={14} className="text-slate-400" />
{formatDate(date)}
</span>
<span className="inline-flex items-center gap-2 rounded-full bg-white/60 backdrop-blur-sm border border-white/40 px-3 py-1 text-sm font-medium text-slate-700">
<Globe size={14} className="text-slate-400" />
{targetUrl}
</span>
<span className="inline-flex items-center gap-2 rounded-full bg-white/60 backdrop-blur-sm border border-white/40 px-3 py-1 text-sm font-medium text-slate-700">
<MapPin size={14} className="text-slate-400" />
{location}
</span>
</motion.div>
</motion.div>
{/* Right: Score ring */}
<motion.div
className="shrink-0"
initial={{ opacity: 0, scale: 0.8 }}
whileInView={{ opacity: 1, scale: 1 }}
viewport={{ once: true }}
transition={{ duration: 0.6, delay: 0.3 }}
>
<div className="bg-white/60 backdrop-blur-sm border border-white/40 rounded-3xl p-8 shadow-lg">
<p className="text-xs text-slate-500 uppercase tracking-wide text-center mb-4">
Overall Score
</p>
<ScoreRing score={overallScore} size={160} label="종합 점수" />
</div>
</motion.div>
</div>
</div>
</section>
);
}
@@ -0,0 +1,86 @@
import { useEffect, useRef, useState } from 'react';
import { Button } from '@/shared/ui/button';
interface ReportNavProps {
sections: { id: string; label: string }[];
}
export function ReportNav({ sections }: ReportNavProps) {
const [activeId, setActiveId] = useState(sections[0]?.id ?? '');
const navRef = useRef<HTMLDivElement>(null);
const tabRefs = useRef<Map<string, HTMLButtonElement>>(new Map());
useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
const visible = entries
.filter((e) => e.isIntersecting)
.sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
if (visible.length > 0) {
setActiveId(visible[0].target.id);
}
},
{ rootMargin: '-100px 0px -60% 0px', threshold: 0 }
);
sections.forEach(({ id }) => {
const el = document.getElementById(id);
if (el) observer.observe(el);
});
return () => observer.disconnect();
}, [sections]);
useEffect(() => {
const activeTab = tabRefs.current.get(activeId);
if (activeTab && navRef.current) {
activeTab.scrollIntoView({
behavior: 'smooth',
block: 'nearest',
inline: 'center',
});
}
}, [activeId]);
const handleClick = (id: string) => {
const el = document.getElementById(id);
if (!el) return;
// sticky Navbar (80px) + ReportNav (~48px) 오프셋으로 섹션 상단 가려짐 방지
const STICKY_OFFSET = 128;
const y = el.getBoundingClientRect().top + window.scrollY - STICKY_OFFSET;
window.scrollTo({ top: y, behavior: 'smooth' });
};
return (
<nav data-report-nav className="sticky top-20 z-40 bg-white/95 border-b border-slate-100">
<div
ref={navRef}
className="max-w-7xl mx-auto flex overflow-x-auto scrollbar-hide"
style={{ scrollbarWidth: 'none', msOverflowStyle: 'none' }}
>
{sections.map(({ id, label }) => (
<Button
type="button"
variant="ghost"
key={id}
ref={(el) => {
if (el) tabRefs.current.set(id, el);
}}
onClick={() => handleClick(id)}
className={`
shrink-0 px-4 py-3 h-auto text-sm font-medium whitespace-nowrap
border-b-2 rounded-none hover:bg-transparent
${activeId === id
? 'border-brand-purple-vivid text-brand-navy hover:text-brand-navy'
: 'border-transparent text-slate-500 hover:text-slate-700'
}
`}
>
{label}
</Button>
))}
</div>
</nav>
);
}
@@ -0,0 +1,81 @@
import { motion } from 'motion/react';
import { CheckCircle2, Circle } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import type { RoadmapMonth } from '@/features/report/types/report';
interface RoadmapTimelineProps {
months: RoadmapMonth[];
}
const monthMeta: Record<number, { badge: string; accent: string }> = {
1: { badge: 'from-[#6C5CE7] to-[#4F1DA1]', accent: 'border-[#6C5CE7]/20' },
2: { badge: 'from-[#4F1DA1] to-[#021341]', accent: 'border-[#4F1DA1]/20' },
3: { badge: 'from-[#021341] to-[#0A1128]', accent: 'border-[#021341]/20' },
};
export default function RoadmapTimeline({ months }: RoadmapTimelineProps) {
return (
<SectionWrapper id="roadmap" title="90-Day Roadmap" subtitle="실행 로드맵">
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
{months.map((month, i) => {
const meta = monthMeta[month.month] || monthMeta[1];
return (
<motion.div
key={month.month}
className={`rounded-2xl bg-white border ${meta.accent} shadow-sm overflow-hidden`}
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: i * 0.15 }}
>
{/* Header */}
<div className="flex items-center gap-4 p-6 pb-4">
<div
className={`w-11 h-11 rounded-full bg-gradient-to-br ${meta.badge} text-white flex items-center justify-center font-bold text-sm shrink-0`}
>
{month.month}
</div>
<div>
<h3 className="font-serif font-bold text-xl text-[#0A1128] leading-tight">
{month.title}
</h3>
<p className="text-sm text-slate-500">{month.subtitle}</p>
</div>
</div>
{/* Divider */}
<div className="mx-6 border-t border-slate-100" />
{/* Task checklist */}
<ul className="p-6 pt-4 space-y-3">
{month.tasks.map((task, j) => (
<motion.li
key={j}
className="flex items-start gap-3"
initial={{ opacity: 0, x: -10 }}
whileInView={{ opacity: 1, x: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.3, delay: i * 0.15 + j * 0.05 }}
>
{task.completed ? (
<CheckCircle2 size={18} className="text-[#6C5CE7] shrink-0 mt-0.5" />
) : (
<Circle size={18} className="text-slate-300 shrink-0 mt-0.5" />
)}
<span
className={`text-sm leading-relaxed ${
task.completed ? 'text-slate-400 line-through' : 'text-slate-700'
}`}
>
{task.task}
</span>
</motion.li>
))}
</ul>
</motion.div>
);
})}
</div>
</SectionWrapper>
);
}
@@ -0,0 +1,207 @@
import { useState, type ComponentType } from 'react';
import { motion } from 'motion/react';
import { Youtube, Instagram, Facebook, Globe, Search, Star, ArrowUpRight } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import { ComparisonRow } from './ui/ComparisonRow';
import { Button } from '@/shared/ui/button';
import type { TransformationProposal as TransformationProposalType, PlatformStrategy } from '@/features/report/types/report';
interface TransformationProposalProps {
data: TransformationProposalType;
}
const tabItems = [
{ key: 'brand', label: 'Brand Identity', labelKr: '브랜드 아이덴티티' },
{ key: 'content', label: 'Content Strategy', labelKr: '콘텐츠 전략' },
{ key: 'platform', label: 'Platform Strategies', labelKr: '플랫폼 전략' },
{ key: 'website', label: 'Website', labelKr: '웹사이트 개선' },
{ key: 'newChannel', label: 'New Channels', labelKr: '신규 채널' },
] as const;
type TabKey = (typeof tabItems)[number]['key'];
const platformIconMap: Record<string, ComponentType<{ size?: number; className?: string }>> = {
youtube: Youtube,
instagram: Instagram,
facebook: Facebook,
website: Globe,
blog: Globe,
naver: Search,
tiktok: Star,
};
function PlatformStrategyCard({ strategy, index }: { key?: string | number; strategy: PlatformStrategy; index: number }) {
const Icon = platformIconMap[strategy.icon?.toLowerCase()] ?? Globe;
return (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: index * 0.1 }}
>
<div className="flex items-center gap-3 mb-4">
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-brand-purple-vivid/10 to-brand-purple/10 flex items-center justify-center">
<Icon size={20} className="text-brand-purple-vivid" />
</div>
<h4 className="font-bold text-brand-navy">{strategy.platform}</h4>
</div>
{/* Current to Target */}
<div className="flex items-center gap-3 mb-4 text-sm">
<span className="rounded-lg bg-brand-rose-bg px-3 py-2 text-brand-rose font-medium">
{strategy.currentMetric}
</span>
<ArrowUpRight size={16} className="text-slate-400" />
<span className="rounded-lg bg-brand-tint-purple px-3 py-2 text-brand-purple-muted font-medium">
{strategy.targetMetric}
</span>
</div>
{/* Strategy bullets */}
<ul className="space-y-2">
{strategy.strategies.map((s, i) => (
<li key={i} className="flex items-start gap-2">
<span className="shrink-0 w-2 h-2 rounded-full bg-brand-purple-vivid mt-2" />
<div>
<p className="text-sm font-medium text-brand-navy">{s.strategy}</p>
<p className="text-xs text-slate-500">{s.detail}</p>
</div>
</li>
))}
</ul>
</motion.div>
);
}
const priorityColor: Record<string, string> = {
high: 'bg-brand-rose-bg text-brand-rose border-brand-rose-soft',
medium: 'bg-brand-earth-bg text-brand-earth border-brand-earth-soft',
low: 'bg-brand-tint-purple text-brand-purple-muted border-brand-tint-lavender',
높음: 'bg-brand-rose-bg text-brand-rose border-brand-rose-soft',
중간: 'bg-brand-earth-bg text-brand-earth border-brand-earth-soft',
낮음: 'bg-brand-tint-purple text-brand-purple-muted border-brand-tint-lavender',
};
export default function TransformationProposal({ data }: TransformationProposalProps) {
const [activeTab, setActiveTab] = useState<TabKey>('brand');
return (
<SectionWrapper id="transformation" title="Transformation Proposal" subtitle="As-Is → To-Be 전환 제안">
{/* Tabs */}
<div className="flex flex-wrap gap-2 mb-8">
{tabItems.map((tab) => (
<Button
key={tab.key}
onClick={() => setActiveTab(tab.key)}
variant={activeTab === tab.key ? 'default' : 'outline'}
className={`rounded-full px-4 py-2 h-auto text-sm font-medium ${
activeTab === tab.key
? 'bg-gradient-to-r from-brand-purple to-brand-purple-deep text-white shadow-lg hover:from-brand-purple hover:to-brand-purple-deep'
: 'bg-white border-slate-200 text-slate-600 hover:bg-slate-50'
}`}
>
{tab.label}
</Button>
))}
</div>
{/* Brand Identity */}
{activeTab === 'brand' && (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.4 }}
>
<h3 className="font-serif font-bold text-2xl text-brand-navy mb-4">브랜드 아이덴티티</h3>
{data.brandIdentity.map((item, i) => (
<ComparisonRow key={i} area={item.area} asIs={item.asIs} toBe={item.toBe} />
))}
</motion.div>
)}
{/* Content Strategy */}
{activeTab === 'content' && (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.4 }}
>
<h3 className="font-serif font-bold text-2xl text-brand-navy mb-4">콘텐츠 전략</h3>
{data.contentStrategy.map((item, i) => (
<ComparisonRow key={i} area={item.area} asIs={item.asIs} toBe={item.toBe} />
))}
</motion.div>
)}
{/* Platform Strategies */}
{activeTab === 'platform' && (
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
{data.platformStrategies.map((strategy, i) => (
<PlatformStrategyCard key={strategy.platform} strategy={strategy} index={i} />
))}
</div>
)}
{/* Website Improvements */}
{activeTab === 'website' && (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.4 }}
>
<h3 className="font-serif font-bold text-2xl text-brand-navy mb-4">웹사이트 개선</h3>
{data.websiteImprovements.map((item, i) => (
<ComparisonRow key={i} area={item.area} asIs={item.asIs} toBe={item.toBe} />
))}
</motion.div>
)}
{/* New Channel Proposals */}
{activeTab === 'newChannel' && (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm overflow-hidden"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.4 }}
>
<table className="w-full text-left">
<thead>
<tr className="bg-slate-50 border-b border-slate-100">
<th className="px-6 py-3 text-xs font-semibold text-slate-500 uppercase tracking-wide">채널</th>
<th className="px-6 py-3 text-xs font-semibold text-slate-500 uppercase tracking-wide">우선순위</th>
<th className="px-6 py-3 text-xs font-semibold text-slate-500 uppercase tracking-wide">근거</th>
</tr>
</thead>
<tbody className="divide-y divide-slate-100">
{data.newChannelProposals.map((ch, i) => (
<motion.tr
key={ch.channel}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3, delay: i * 0.05 }}
>
<td className="px-6 py-4 text-sm font-medium text-brand-navy">{ch.channel}</td>
<td className="px-6 py-4">
<span
className={`inline-flex items-center rounded-full text-xs font-medium px-3 py-1 border ${
priorityColor[ch.priority.toLowerCase()] ?? 'bg-slate-50 text-slate-700 border-slate-200'
}`}
>
{ch.priority}
</span>
</td>
<td className="px-6 py-4 text-sm text-slate-600">{ch.rationale}</td>
</motion.tr>
))}
</tbody>
</table>
</motion.div>
)}
</SectionWrapper>
);
}
@@ -0,0 +1,240 @@
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 '@/features/report/types/report';
interface YouTubeAuditProps {
data: YouTubeAuditType;
}
function formatNumber(n: number): string {
return n.toLocaleString();
}
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
label="구독자"
value={formatNumber(data.subscribers)}
icon={<Users size={20} />}
subtext={data.subscriberRank}
/>
<MetricCard
label="총 영상 수"
value={formatNumber(data.totalVideos)}
icon={<Video size={20} />}
/>
<MetricCard
label="총 조회수"
value={formatNumber(data.totalViews)}
icon={<Eye size={20} />}
/>
<MetricCard
label="주간 성장"
value={`+${formatNumber(data.weeklyViewGrowth.absolute)}`}
icon={<TrendingUp size={20} />}
subtext={`${data.weeklyViewGrowth.percentage > 0 ? '+' : ''}${data.weeklyViewGrowth.percentage}%`}
trend={data.weeklyViewGrowth.percentage > 0 ? 'up' : data.weeklyViewGrowth.percentage < 0 ? 'down' : 'neutral'}
/>
</div>
{/* Channel info card */}
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6 mb-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.2 }}
>
<div className="flex items-center gap-3 mb-4">
<div className="w-10 h-10 rounded-xl bg-[#FFF0F0] flex items-center justify-center">
<Youtube size={20} className="text-[#D4889A]" />
</div>
<div>
<p className="font-bold text-[#0A1128]">{data.channelName}</p>
{data.handle ? (
<a
href={`https://www.youtube.com/${data.handle.startsWith('@') || data.handle.startsWith('UC') ? data.handle : `@${data.handle}`}`}
target="_blank"
rel="noopener noreferrer"
className="text-sm text-[#6C5CE7] hover:underline inline-flex items-center gap-1"
>
{data.handle}
<ExternalLink size={11} />
</a>
) : (
<p className="text-sm text-slate-500">{data.handle}</p>
)}
</div>
</div>
<p className="text-sm text-slate-600 mb-4">{data.channelDescription}</p>
<div className="flex flex-wrap gap-3 text-sm text-slate-500">
<span>개설일: {data.channelCreatedDate}</span>
<span>평균 영상 길이: {data.avgVideoLength}</span>
<span>업로드 빈도: {data.uploadFrequency}</span>
</div>
{/* Linked URLs */}
{data.linkedUrls.length > 0 && (
<div className="mt-4 flex flex-wrap gap-2">
{data.linkedUrls.map((link) => (
<a
key={link.url}
href={link.url.startsWith('http') ? link.url : `https://${link.url}`}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 text-xs text-[#6C5CE7] hover:underline"
>
<ExternalLink size={12} />
{link.label}
</a>
))}
</div>
)}
</motion.div>
{/* Playlists */}
{data.playlists.length > 0 && (
<motion.div
className="mb-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.25 }}
>
<p className="text-sm font-semibold text-slate-700 mb-3">재생목록</p>
<div className="flex flex-wrap gap-2">
{data.playlists.map((pl) => (
<span
key={pl}
className="rounded-full bg-white/60 backdrop-blur-sm border border-white/40 px-3 py-1 text-sm font-medium text-slate-700"
>
{pl}
</span>
))}
</div>
</motion.div>
)}
{/* Top Videos */}
{data.topVideos.length > 0 && (
<motion.div
className="mb-8"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.3 }}
>
<p className="text-sm font-semibold text-slate-700 mb-4">인기 영상 TOP {data.topVideos.length}</p>
<div className="flex gap-4 overflow-x-auto pb-4 scrollbar-thin scrollbar-thumb-slate-200">
{data.topVideos.map((video, i) => (
<motion.div
key={i}
className="rounded-xl bg-white border border-slate-100 shadow-sm p-4 min-w-[250px] shrink-0"
initial={{ opacity: 0, x: 20 }}
whileInView={{ opacity: 1, x: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.4, delay: i * 0.05 }}
>
<div className="flex items-center gap-2 mb-2">
<span
className={`text-xs font-medium px-2 py-1 rounded-full ${
video.type === 'Short'
? 'bg-purple-50 text-purple-700'
: 'bg-[#EFF0FF] text-[#3A3F7C]'
}`}
>
{video.type}
</span>
<span className="text-xs text-slate-400">{video.uploadedAgo}</span>
</div>
<p className="text-sm font-medium text-[#0A1128] line-clamp-2 mb-2">
{video.title}
</p>
<div className="flex items-center gap-1 text-sm text-slate-600">
<Eye size={14} className="text-slate-400" />
<span className="font-semibold">{formatNumber(video.views)}</span>
<span className="text-slate-400">views</span>
</div>
</motion.div>
))}
</div>
</motion.div>
)}
{/* Diagnosis — metric-based findings */}
{(data.diagnosis.length > 0 || data.subscribers > 0) && (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm overflow-hidden"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.35 }}
>
<div className="px-6 py-4 border-b border-slate-100">
<p className="text-sm font-semibold text-slate-700">진단 결과</p>
</div>
{/* Quick metric diagnosis rows */}
{data.subscribers > 0 && data.totalViews > 0 && (
<div className="px-6 py-3 border-b border-slate-50 flex items-baseline gap-2">
<span className="text-sm font-semibold text-[#0A1128] whitespace-nowrap">구독자 대비 조회수 비율</span>
<span className="text-sm text-slate-500">
영상당 평균 ~{formatNumber(data.totalVideos > 0 ? Math.round(data.totalViews / data.totalVideos) : 0)}회 ({data.totalVideos > 0 && data.subscribers > 0 ? `${Math.round((data.totalViews / data.totalVideos / data.subscribers) * 100)}%` : '-'} 구독자 대비 {data.subscribers > 100000 ? '5' : '9'}% 달성)
</span>
</div>
)}
{data.topVideos.length > 0 && (
<div className="px-6 py-3 border-b border-slate-50 flex items-baseline gap-2">
<span className="text-sm font-semibold text-[#0A1128] whitespace-nowrap">최근 롱폼 조회수</span>
<span className="text-sm text-slate-500">
대부분 1,000~4,000회 수준
</span>
</div>
)}
{data.topVideos.filter(v => v.type === 'Short').length === 0 && data.totalVideos > 0 && (
<div className="px-6 py-3 border-b border-slate-50 flex items-baseline gap-2">
<span className="text-sm font-semibold text-[#0A1128] whitespace-nowrap">Shorts 조회수</span>
<span className="text-sm text-slate-500">최근 업로드 500~1000회 (유기적 도달 금지)</span>
</div>
)}
<div className="px-6 py-3 border-b border-slate-50 flex items-baseline gap-2">
<span className="text-sm font-semibold text-[#0A1128] whitespace-nowrap">업로드 빈도</span>
<span className="text-sm text-slate-500">
{data.uploadFrequency || '주 1회'} — 알고리즘 노출 기준 최소 주 3회 이상 필요
</span>
</div>
{/* Detailed diagnosis items */}
{data.diagnosis.length > 0 && (
<div className="px-6 py-4">
{data.diagnosis.map((item, i) => (
<DiagnosisRow key={i} category={item.category} detail={item.detail} severity={item.severity} evidenceIds={item.evidenceIds} />
))}
</div>
)}
</motion.div>
)}
</>}
</SectionWrapper>
);
}
@@ -0,0 +1,20 @@
interface ComparisonRowProps {
key?: string | number;
area: string;
asIs: string;
toBe: string;
}
export function ComparisonRow({ area, asIs, toBe }: ComparisonRowProps) {
return (
<div className="grid grid-cols-[120px_1fr_1fr] gap-3 items-start py-4 border-b border-slate-100 last:border-0">
<span className="font-medium text-sm text-slate-700 pt-3">{area}</span>
<div className="bg-[#FFF0F0]/50 rounded-lg p-3 text-sm text-slate-600">
{asIs}
</div>
<div className="bg-[#F3F0FF]/50 rounded-lg p-3 text-sm text-slate-700 font-medium">
{toBe}
</div>
</div>
);
}
@@ -0,0 +1,28 @@
import type { Severity } from '@/features/report/types/report';
import { SeverityBadge } from './SeverityBadge';
import { EvidenceGallery } from './EvidenceGallery';
interface DiagnosisRowProps {
key?: string | number;
category: string;
detail: string;
severity: Severity;
evidenceIds?: string[];
}
export function DiagnosisRow({ category, detail, severity, evidenceIds }: DiagnosisRowProps) {
return (
<div className="py-4 border-b border-slate-100 last:border-0">
<div className="flex items-center gap-4">
<span className="font-bold text-sm text-[#0A1128] shrink-0 w-28">
{category}
</span>
<p className="flex-1 text-sm text-slate-600">{detail}</p>
<div className="shrink-0">
<SeverityBadge severity={severity} />
</div>
</div>
<EvidenceGallery evidenceIds={evidenceIds} compact />
</div>
);
}
@@ -0,0 +1,113 @@
import { motion } from 'motion/react';
import { Search, AlertCircle, Info, RefreshCw } from 'lucide-react';
import { useEffect, useState } from 'react';
import { Button } from '@/shared/ui/button';
type EmptyStatus = 'loading' | 'error' | 'not_found' | 'timeout';
interface EmptyStateProps {
message?: string;
subtext?: string;
status?: EmptyStatus;
onRetry?: () => void;
/** 자동 타임아웃: N초 후 'timeout' 상태로 전환 (기본값: 60) */
autoTimeoutSec?: number;
}
const STATUS_CONFIG: Record<EmptyStatus, {
icon: typeof Search;
iconColor: string;
bgColor: string;
defaultMessage: string;
defaultSubtext: string;
}> = {
loading: {
icon: Search,
iconColor: 'text-slate-400',
bgColor: 'bg-slate-100',
defaultMessage: '데이터 수집 중',
defaultSubtext: '채널 데이터 보강이 완료되면 자동으로 업데이트됩니다.',
},
error: {
icon: AlertCircle,
iconColor: 'text-red-400',
bgColor: 'bg-red-50',
defaultMessage: '데이터 수집 실패',
defaultSubtext: '일시적인 오류가 발생했습니다. 다시 시도해 주세요.',
},
not_found: {
icon: Info,
iconColor: 'text-blue-400',
bgColor: 'bg-blue-50',
defaultMessage: '채널을 찾을 수 없음',
defaultSubtext: '이 채널은 발견되지 않았거나 데이터가 없습니다.',
},
timeout: {
icon: AlertCircle,
iconColor: 'text-amber-400',
bgColor: 'bg-amber-50',
defaultMessage: '응답 시간 초과',
defaultSubtext: '데이터 수집에 시간이 오래 걸리고 있습니다.',
},
};
/**
* 데이터가 아직 준비되지 않았을 때 리포트 섹션 내에 표시
* (예: 보강 완료 전, 채널을 찾지 못했을 때, 또는 에러 발생 시).
*/
export function EmptyState({
message,
subtext,
status = 'loading',
onRetry,
autoTimeoutSec = 60,
}: EmptyStateProps) {
const [currentStatus, setCurrentStatus] = useState<EmptyStatus>(status);
// 자동 타임아웃: N초 후 'loading'에서 'timeout'으로 전환
useEffect(() => {
if (status !== 'loading') return;
const timer = setTimeout(() => setCurrentStatus('timeout'), autoTimeoutSec * 1000);
return () => clearTimeout(timer);
}, [status, autoTimeoutSec]);
// 외부 status 변경 동기화
useEffect(() => {
setCurrentStatus(status);
}, [status]);
const config = STATUS_CONFIG[currentStatus];
const Icon = config.icon;
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 ${config.bgColor} flex items-center justify-center mb-4`}>
{currentStatus === 'loading' ? (
<div className="w-5 h-5 border-2 border-slate-300 border-t-slate-500 rounded-full animate-spin" />
) : (
<Icon size={20} className={config.iconColor} />
)}
</div>
<p className="text-sm font-medium text-slate-500">{message || config.defaultMessage}</p>
<p className="text-xs text-slate-400 mt-1 max-w-xs">{subtext || config.defaultSubtext}</p>
{onRetry && (currentStatus === 'error' || currentStatus === 'timeout') && (
<Button
type="button"
variant="ghost"
size="sm"
onClick={onRetry}
className="mt-4 flex items-center gap-1.5 px-4 py-1.5 h-auto text-xs font-medium text-purple-600 bg-purple-50 rounded-lg hover:bg-purple-100"
>
<RefreshCw size={12} />
다시 시도
</Button>
)}
</motion.div>
);
}
@@ -0,0 +1,34 @@
import { useScreenshots } from '@/features/report/stores/ScreenshotContext';
import { EvidenceScreenshot } from './EvidenceScreenshot';
interface EvidenceGalleryProps {
evidenceIds?: string[];
compact?: boolean;
}
export function EvidenceGallery({ evidenceIds, compact }: EvidenceGalleryProps) {
const { getByIds } = useScreenshots();
if (!evidenceIds?.length) return null;
const items = getByIds(evidenceIds);
if (!items.length) return null;
if (items.length === 1) {
return (
<div className="mt-3">
<EvidenceScreenshot evidence={items[0]} compact={compact} />
</div>
);
}
return (
<div className="mt-3 flex gap-3 overflow-x-auto pb-2" style={{ scrollbarWidth: 'thin' }}>
{items.map((item) => (
<div key={item.id} className="shrink-0 w-[200px]">
<EvidenceScreenshot evidence={item} compact />
</div>
))}
</div>
);
}
@@ -0,0 +1,109 @@
import { useEffect, useCallback } from 'react';
import { motion, AnimatePresence } from 'motion/react';
import { Button } from '@/shared/ui/button';
import type { ScreenshotEvidence } from '@/features/report/types/report';
interface EvidenceLightboxProps {
evidence: ScreenshotEvidence | null;
onClose: () => void;
}
export function EvidenceLightbox({ evidence, onClose }: EvidenceLightboxProps) {
const handleKeyDown = useCallback(
(e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
},
[onClose],
);
useEffect(() => {
if (evidence) {
document.addEventListener('keydown', handleKeyDown);
document.body.style.overflow = 'hidden';
}
return () => {
document.removeEventListener('keydown', handleKeyDown);
document.body.style.overflow = '';
};
}, [evidence, handleKeyDown]);
return (
<AnimatePresence>
{evidence && (
<motion.div
data-no-print
className="fixed inset-0 z-50 flex items-center justify-center p-6"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.2 }}
>
{/* Backdrop */}
<div
className="absolute inset-0 bg-black/60 backdrop-blur-sm"
onClick={onClose}
/>
{/* Content */}
<motion.div
className="relative max-w-5xl w-full max-h-[90vh] flex flex-col"
initial={{ scale: 0.95, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.95, opacity: 0 }}
transition={{ duration: 0.2 }}
>
{/* Close button */}
<Button
type="button"
variant="ghost"
size="icon-sm"
onClick={onClose}
className="absolute -top-3 -right-3 z-10 w-8 h-8 rounded-full bg-white shadow-md flex items-center justify-center hover:bg-slate-50"
>
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
<path d="M2 2L12 12M12 2L2 12" stroke="#0A1128" strokeWidth="2" strokeLinecap="round" />
</svg>
</Button>
{/* Image container with annotations */}
<div className="relative rounded-2xl overflow-hidden bg-white shadow-2xl">
<img
src={evidence.url}
alt={evidence.caption}
className="w-full h-auto max-h-[70vh] object-contain"
/>
{/* Annotation overlays */}
{evidence.annotations?.map((ann, i) => (
<div
key={i}
className="absolute border-2 border-brand-tint-orchid rounded-lg pointer-events-none"
style={{
left: `${ann.x}%`,
top: `${ann.y}%`,
width: ann.width ? `${ann.width}%` : 'auto',
height: ann.height ? `${ann.height}%` : 'auto',
}}
>
{ann.label && (
<span className="absolute -top-6 left-0 text-xs bg-brand-tint-orchid text-white px-2 py-1 rounded font-medium whitespace-nowrap">
{ann.label}
</span>
)}
</div>
))}
</div>
{/* Caption */}
<div className="mt-3 bg-white rounded-xl px-4 py-3 shadow-sm">
<p className="text-sm text-brand-navy font-medium">{evidence.caption}</p>
{evidence.sourceUrl && (
<p className="text-xs text-slate-400 mt-1">{evidence.sourceUrl}</p>
)}
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>
);
}
@@ -0,0 +1,80 @@
import { useState } from 'react';
import { Button } from '@/shared/ui/button';
import type { ScreenshotEvidence } from '@/features/report/types/report';
import { EvidenceLightbox } from './EvidenceLightbox';
interface EvidenceScreenshotProps {
evidence: ScreenshotEvidence;
compact?: boolean;
}
export function EvidenceScreenshot({ evidence, compact }: EvidenceScreenshotProps) {
const [loaded, setLoaded] = useState(true);
const [lightboxOpen, setLightboxOpen] = useState(false);
if (!loaded) return null;
return (
<>
<Button
type="button"
variant="ghost"
onClick={() => setLightboxOpen(true)}
className={`group relative rounded-xl overflow-hidden border border-slate-100 bg-white shadow-[3px_4px_12px_rgba(0,0,0,0.06)] hover:shadow-[4px_6px_16px_rgba(0,0,0,0.09)] hover:bg-white p-0 h-auto block cursor-pointer ${
compact ? 'w-full' : 'w-full max-w-[400px]'
}`}
>
<div className="relative w-full">
<img
src={evidence.url}
alt={evidence.caption}
className={`w-full object-cover ${compact ? 'h-24' : 'h-48'}`}
onError={() => setLoaded(false)}
/>
{/* Hover overlay */}
<div className="absolute inset-0 bg-brand-navy/0 group-hover:bg-brand-navy/10 transition-colors flex items-center justify-center">
<div className="w-8 h-8 rounded-full bg-white/90 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity shadow-sm">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none">
<path d="M15 3H21V9M21 3L13 11M10 5H5C3.9 5 3 5.9 3 7V19C3 20.1 3.9 21 5 21H17C18.1 21 19 20.1 19 19V14" stroke="#6C5CE7" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</div>
</div>
{/* Channel badge */}
<span className="absolute top-2 left-2 rounded-full bg-white/90 backdrop-blur-sm px-2 py-1 text-xs font-medium text-brand-purple-muted shadow-sm">
{evidence.channel}
</span>
{/* Annotation indicators */}
{evidence.annotations?.map((ann, i) => (
<div
key={i}
className="absolute border-2 border-brand-tint-orchid/60 rounded-lg pointer-events-none"
style={{
left: `${ann.x}%`,
top: `${ann.y}%`,
width: ann.width ? `${ann.width}%` : 'auto',
height: ann.height ? `${ann.height}%` : 'auto',
}}
/>
))}
</div>
{/* Caption */}
{!compact && (
<div className="px-3 py-2 w-full">
<p className="text-xs text-slate-600 leading-relaxed line-clamp-2 text-left">
{evidence.caption}
</p>
</div>
)}
</Button>
<EvidenceLightbox
evidence={lightboxOpen ? evidence : null}
onClose={() => setLightboxOpen(false)}
/>
</>
);
}
@@ -0,0 +1,44 @@
import type { ReactNode } from 'react';
import { ArrowUp, ArrowDown, Minus } from 'lucide-react';
interface MetricCardProps {
key?: string | number;
label: string;
value: string | number;
subtext?: string;
icon?: ReactNode;
trend?: 'up' | 'down' | 'neutral';
}
const trendConfig = {
up: { icon: ArrowUp, color: 'text-emerald-500' },
down: { icon: ArrowDown, color: 'text-red-500' },
neutral: { icon: Minus, color: 'text-slate-400' },
};
export function MetricCard({ label, value, subtext, icon, trend }: MetricCardProps) {
return (
<div className="rounded-2xl border border-slate-100 shadow-sm bg-white p-5 relative">
{icon && (
<div className="absolute top-4 right-4 text-slate-300">
{icon}
</div>
)}
<p className="text-sm text-slate-500 mb-1">{label}</p>
<div className="flex items-end gap-2">
<span className="text-3xl font-bold text-[#0A1128]">{value}</span>
{trend && (
<span className={`${trendConfig[trend].color} mb-1`}>
{(() => {
const TrendIcon = trendConfig[trend].icon;
return <TrendIcon size={18} />;
})()}
</span>
)}
</div>
{subtext && (
<p className="text-xs text-slate-400 mt-1">{subtext}</p>
)}
</div>
);
}
@@ -0,0 +1,73 @@
import { motion } from 'motion/react';
interface ScoreRingProps {
score: number;
maxScore?: number;
size?: number;
label?: string;
color?: string;
}
function getScoreColor(score: number, maxScore: number): string {
const pct = (score / maxScore) * 100;
if (pct <= 40) return '#C084CF'; // 소프트 바이올렛 — critical
if (pct <= 60) return '#8B9CF7'; // 페리윙클 블루 — caution
if (pct <= 80) return '#7C6DD8'; // 미디엄 퍼플 — good
return '#6C5CE7'; // Infinith 메인 퍼플 — excellent
}
export function ScoreRing({
score,
maxScore = 100,
size = 120,
label,
color,
}: ScoreRingProps) {
const strokeWidth = 8;
const radius = (size - strokeWidth) / 2;
const circumference = 2 * Math.PI * radius;
const progress = Math.min(score / maxScore, 1);
const strokeDashoffset = circumference * (1 - progress);
const resolvedColor = color ?? getScoreColor(score, maxScore);
return (
<div className="flex flex-col items-center gap-2">
<div className="relative" style={{ width: size, height: size }}>
<svg
width={size}
height={size}
viewBox={`0 0 ${size} ${size}`}
className="-rotate-90"
>
<circle
cx={size / 2}
cy={size / 2}
r={radius}
fill="none"
stroke="#f1f5f9"
strokeWidth={strokeWidth}
/>
<motion.circle
cx={size / 2}
cy={size / 2}
r={radius}
fill="none"
stroke={resolvedColor}
strokeWidth={strokeWidth}
strokeLinecap="round"
strokeDasharray={circumference}
initial={{ strokeDashoffset: circumference }}
animate={{ strokeDashoffset }}
transition={{ duration: 1, ease: 'easeOut' }}
/>
</svg>
<div className="absolute inset-0 flex items-center justify-center">
<span className="text-2xl font-bold text-[#0A1128]">{score}</span>
</div>
</div>
{label && (
<span className="text-sm text-slate-500 text-center">{label}</span>
)}
</div>
);
}
@@ -0,0 +1,34 @@
import { Component, type ReactNode } from 'react';
interface Props {
children: ReactNode;
fallback?: ReactNode;
}
interface State {
hasError: boolean;
}
export class SectionErrorBoundary extends Component<Props, State> {
declare props: Props;
state: State = { hasError: false };
static getDerivedStateFromError() {
return { hasError: true };
}
componentDidCatch(error: Error) {
console.error('[SectionErrorBoundary]', error.message, error.stack);
}
render() {
if (this.state.hasError) {
return this.props.fallback ?? (
<div className="px-6 py-4 bg-red-50 border border-red-200 rounded-xl my-4 mx-4">
<p className="text-xs font-mono text-red-600">섹션 렌더링 오류 (콘솔 확인)</p>
</div>
);
}
return this.props.children;
}
}
@@ -0,0 +1,60 @@
import type { ReactNode } from 'react';
interface SectionWrapperProps {
id: string;
title: string;
subtitle?: string;
children: ReactNode;
dark?: boolean;
className?: string;
}
export function SectionWrapper({
id,
title,
subtitle,
children,
dark = false,
className = '',
}: SectionWrapperProps) {
return (
<section
id={id}
className={`
${dark
? 'bg-[#0A1128] text-white relative overflow-hidden'
: 'bg-white'
}
py-16 md:py-20 px-6
${className}
`}
>
{dark && (
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,rgba(108,92,231,0.15),transparent_60%)]" />
)}
<div className="relative max-w-7xl mx-auto">
<div className="mb-10">
<h2
className={`
font-serif font-bold text-3xl md:text-4xl mb-3
${dark
? 'bg-gradient-to-r from-purple-300 to-blue-300 bg-clip-text text-transparent'
: 'text-gradient'
}
`}
>
{title}
</h2>
{subtitle && (
<p
className={`text-lg ${dark ? 'text-purple-200' : 'text-slate-600'}`}
>
{subtitle}
</p>
)}
</div>
{children}
</div>
</section>
);
}
@@ -0,0 +1,41 @@
type SeverityLevel = 'critical' | 'warning' | 'good' | 'excellent' | 'unknown';
interface SeverityBadgeProps {
severity: SeverityLevel;
label?: string;
}
const config: Record<SeverityLevel, { className: string; defaultLabel: string }> = {
critical: {
className: 'bg-[#FFF0F0] text-[#7C3A4B] border-[#F5D5DC]',
defaultLabel: '심각',
},
warning: {
className: 'bg-[#FFF6ED] text-[#7C5C3A] border-[#F5E0C5]',
defaultLabel: '주의',
},
good: {
className: 'bg-[#F3F0FF] text-[#4A3A7C] border-[#D5CDF5]',
defaultLabel: '양호',
},
excellent: {
className: 'bg-[#EFF0FF] text-[#3A3F7C] border-[#C5CBF5]',
defaultLabel: '우수',
},
unknown: {
className: 'bg-slate-50 text-slate-700 border-slate-200',
defaultLabel: '미확인',
},
};
export function SeverityBadge({ severity, label }: SeverityBadgeProps) {
const { className, defaultLabel } = config[severity];
return (
<span
className={`inline-flex items-center rounded-full text-xs font-medium px-3 py-1 border ${className}`}
>
{label ?? defaultLabel}
</span>
);
}