feat: 백엔드 신스키마 (PlanOutput / 신규 analysis 라우트) 반영 + 화면·환경 적응

- orval SDK 재생성: generated/analyses → generated/analysis, planResponse* → planOutput 외 신규 모델 40여 개
- transformReport / useAnalysisPipeline 신스키마 적응
- plan/report 페이지·컴포넌트(다운로드 메뉴, ChannelOverview, ChannelStrategy, GuestPlanPage, UserPlanPage, GuestReportPage, UserReportPage, ReportBody, MultiChannelInput) 적응
- /dev/clinics 페이지 갱신
- orval.config / api.ts / package.json 환경설정 갱신
- .env.example: API 키 값 placeholder 로 비움 (이전에 실제 키가 들어있었음)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 4.7 committed 2026-05-18 15:19:48 +09:00
1 parent 93674e4856
commit a294637644
65 files changed
+890 -213

No files matched your search

@@ -1,4 +1,4 @@
import type { ComponentType } from 'react';
import type { ComponentType, CSSProperties } from 'react';
import { motion } from 'motion/react';
import { Youtube, Instagram, Globe, Star, Facebook, Search } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
@@ -10,7 +10,7 @@ interface ChannelOverviewProps {
channels: ChannelScore[];
}
const iconMap: Record<string, ComponentType<{ size?: number; className?: string }>> = {
const iconMap: Record<string, ComponentType<{ size?: number; className?: string; style?: CSSProperties }>> = {
youtube: Youtube,
instagram: Instagram,
facebook: Facebook,
@@ -5,7 +5,7 @@
* PDF: 브라우저 네이티브 인쇄(window.print) → "PDF로 저장"
* CSV: 리포트의 표 데이터를 다중 섹션 CSV 단일 파일로 다운로드
*/
import { Download, FileText, FileSpreadsheet, ChevronDown, Loader2 } from 'lucide-react';
import { FileText, FileSpreadsheet, ChevronDown, Loader2 } from 'lucide-react';
import {
DropdownMenu,
DropdownMenuTrigger,
@@ -44,7 +44,6 @@ export function DownloadMenuButton({ filename, report, className }: DownloadMenu
</>
) : (
<>
<Download size={12} />
다운로드
<ChevronDown size={12} className="opacity-70" />
</>
@@ -80,7 +80,7 @@ export default function ReportBody({ data }: ReportBodyProps) {
</SectionErrorBoundary>
<SectionErrorBoundary>
{hasValue(data.instagramAudit) && data.instagramAudit.handle ? (
{hasValue(data.instagramAudit) && nonEmpty(data.instagramAudit.accounts) ? (
<InstagramAudit data={data.instagramAudit} />
) : (
<EmptySection id="instagram-audit" title="Instagram Analysis" subtitle="인스타그램 분석" />
@@ -88,7 +88,7 @@ export default function ReportBody({ data }: ReportBodyProps) {
</SectionErrorBoundary>
<SectionErrorBoundary>
{hasValue(data.facebookAudit) && (data.facebookAudit.handle || data.facebookAudit.followers > 0) ? (
{hasValue(data.facebookAudit) && nonEmpty(data.facebookAudit.pages) ? (
<FacebookAudit data={data.facebookAudit} />
) : (
<EmptySection id="facebook-audit" title="Facebook Analysis" subtitle="페이스북 페이지 분석" />
@@ -1,7 +1,7 @@
import { useState, useEffect, useRef, useCallback } from 'react';
import { useNavigate, useLocation, useParams } from 'react-router';
import { useCreateClinic } from '@/shared/api/generated/clinics/clinics';
import { useStartAnalysis, getAnalysisStatus } from '@/shared/api/generated/analyses/analyses';
import { useStartAnalysis, getAnalysisStatus } from '@/shared/api/generated/analysis/analysis';
import { AnalysisStatus } from '@/shared/api/model/analysisStatus';
import { sleep } from '@/shared/lib/utils';
+203
View File
@@ -1,4 +1,6 @@
import type { MarketingReport, Severity, ChannelScore, DiagnosisItem, TopVideo } from '@/features/report/types/report';
import type { ReportOutput } from '@/shared/api/model/reportOutput';
import type { ChannelScore as SdkChannelScore } from '@/shared/api/model/channelScore';
/**
* generate-report Edge Function의 API 응답.
@@ -1266,3 +1268,204 @@ export function mergeEnrichment(
return merged;
}
// ════════════════════════════════════════════════════════════════════════════
// SDK ReportOutput → MarketingReport 변환
// 백엔드 OpenAPI 스펙(ReportOutput)을 그대로 받아 프론트엔드 컴포넌트가 기대하는
// MarketingReport 형태로 매핑. ReportOutput에 없는 풍부한 메타(clinicSnapshot,
// topVideos 등)는 빈 값으로 둠.
// ════════════════════════════════════════════════════════════════════════════
interface ReportMetadata {
url: string;
generatedAt?: string;
clinicName?: string;
}
function channelScoreToScoreCard(
channel: string,
icon: string,
ch: SdkChannelScore,
): ChannelScore {
return {
channel,
icon,
score: ch.score,
maxScore: 100,
status: scoreToSeverity(ch.score),
headline: ch.summary,
};
}
function channelScoreToDiagnosis(
category: string,
ch: SdkChannelScore | null | undefined,
): DiagnosisItem[] {
if (!ch) return [];
const items: DiagnosisItem[] = [];
for (const weakness of ch.weaknesses) {
items.push({ category, detail: weakness, severity: scoreToSeverity(ch.score) });
}
return items;
}
/** "1주차: 채널 역할 정의" → { month: 1, title: '1주차', subtitle: '채널 역할 정의' } */
function parseRoadmapLine(line: string, index: number): import('../types/report').RoadmapMonth {
const colonIdx = line.indexOf(':');
if (colonIdx === -1) {
return { month: index + 1, title: `Week ${index + 1}`, subtitle: line.trim(), tasks: [] };
}
return {
month: index + 1,
title: line.slice(0, colonIdx).trim(),
subtitle: line.slice(colonIdx + 1).trim(),
tasks: [],
};
}
/**
* 백엔드 SDK의 ReportOutput을 그대로 받아 MarketingReport로 변환.
* - ReportOutput에 있는 필드: overall_score, {youtube,instagram,facebook,naver_blog,gangnam_unni}, conversion_strategy, roadmap, kpis
* - 그 외 풍부한 메타(clinicSnapshot, topVideos, followers 등)는 SDK에 없으므로 빈/기본값
*/
export function transformReportOutput(
reportId: string,
output: ReportOutput,
metadata: ReportMetadata,
): MarketingReport {
const domain = (() => {
try { return new URL(metadata.url).hostname; } catch { return metadata.url || ''; }
})();
// 채널별 score card — SDK에 값이 있는 채널만
const channelScores: ChannelScore[] = [];
if (output.youtube) channelScores.push(channelScoreToScoreCard('YouTube', 'youtube', output.youtube));
if (output.instagram) channelScores.push(channelScoreToScoreCard('Instagram', 'instagram', output.instagram));
if (output.facebook) channelScores.push(channelScoreToScoreCard('Facebook', 'facebook', output.facebook));
if (output.naver_blog) channelScores.push(channelScoreToScoreCard('네이버 블로그', 'blog', output.naver_blog));
if (output.gangnam_unni) channelScores.push(channelScoreToScoreCard('강남언니', 'star', output.gangnam_unni));
// 전체 약점을 problemDiagnosis로 모음
const problemDiagnosis: DiagnosisItem[] = [
...channelScoreToDiagnosis('YouTube', output.youtube),
...channelScoreToDiagnosis('Instagram', output.instagram),
...channelScoreToDiagnosis('Facebook', output.facebook),
...channelScoreToDiagnosis('네이버 블로그', output.naver_blog),
...channelScoreToDiagnosis('강남언니', output.gangnam_unni),
];
return {
id: reportId,
createdAt: metadata.generatedAt || new Date().toISOString(),
targetUrl: metadata.url,
overallScore: output.overall_score,
clinicSnapshot: {
name: metadata.clinicName || '',
nameEn: '',
established: '',
yearsInBusiness: 0,
staffCount: 0,
leadDoctor: { name: '', credentials: '', rating: 0, reviewCount: 0 },
overallRating: 0,
totalReviews: 0,
priceRange: { min: '-', max: '-', currency: '₩' },
certifications: [],
mediaAppearances: [],
medicalTourism: [],
location: '',
nearestStation: '',
phone: '',
domain,
},
channelScores,
youtubeAudit: {
channelName: '',
handle: '',
subscribers: 0,
totalVideos: 0,
totalViews: 0,
weeklyViewGrowth: { absolute: 0, percentage: 0 },
estimatedMonthlyRevenue: { min: 0, max: 0 },
avgVideoLength: '-',
uploadFrequency: '-',
channelCreatedDate: '',
subscriberRank: '-',
channelDescription: output.youtube?.summary || '',
linkedUrls: [],
playlists: [],
topVideos: [],
diagnosis: channelScoreToDiagnosis('YouTube', output.youtube),
},
instagramAudit: {
accounts: output.instagram ? [{
handle: '',
language: 'KR',
label: '메인',
posts: 0,
followers: 0,
following: 0,
category: '의료/건강',
profileLink: '',
highlights: [],
reelsCount: 0,
contentFormat: '',
profilePhoto: '',
bio: output.instagram.summary,
}] : [],
diagnosis: channelScoreToDiagnosis('Instagram', output.instagram),
},
facebookAudit: {
pages: [],
diagnosis: channelScoreToDiagnosis('Facebook', output.facebook),
brandInconsistencies: [],
consolidationRecommendation: '',
},
otherChannels: [
...(output.naver_blog ? [{
name: '네이버 블로그',
status: 'active' as const,
details: output.naver_blog.summary,
}] : []),
...(output.gangnam_unni ? [{
name: '강남언니',
status: 'active' as const,
details: output.gangnam_unni.summary,
}] : []),
],
websiteAudit: {
primaryDomain: domain,
additionalDomains: [],
snsLinksOnSite: false,
trackingPixels: [],
mainCTA: '',
},
problemDiagnosis,
transformation: {
brandIdentity: [],
contentStrategy: [],
platformStrategies: [],
websiteImprovements: [],
newChannelProposals: [],
},
roadmap: output.roadmap.map(parseRoadmapLine),
kpiDashboard: output.kpis.map((kpi) => ({
metric: kpi,
current: '-',
target3Month: '-',
target12Month: '-',
})),
screenshots: [],
};
}
@@ -7,7 +7,6 @@
*/
import { Link, useParams } from 'react-router';
import { ArrowRight, ArrowLeft } from 'lucide-react';
import { AppIcon } from '@/shared/icons/AppIcon';
import { useReportPageData } from '../hooks/useReportPageData';
import { ReportNav } from '../components/ReportNav';
import { ScreenshotProvider } from '../stores/ScreenshotContext';
@@ -62,14 +61,6 @@ export default function GuestReportPage() {
filename={`${data.clinicSnapshot.name}_Marketing_Intelligence_Report`}
report={data}
/>
<Link
to={`/plan/${id}`}
className="inline-flex items-center gap-1.5 px-4 py-2 rounded-full text-xs font-semibold text-brand-purple bg-brand-tint-purple/60 border border-brand-tint-lavender hover:bg-brand-tint-purple transition-colors"
>
<AppIcon kind="plan" size={12} />
마케팅 기획 보기
<ArrowRight size={11} className="opacity-80" />
</Link>
</div>
}
/>
@@ -8,7 +8,6 @@
*/
import { Link, useParams } from 'react-router';
import { ArrowLeft, RefreshCw } from 'lucide-react';
import { AppIcon } from '@/shared/icons/AppIcon';
import { useReportPageData } from '../hooks/useReportPageData';
import { ReportNav } from '../components/ReportNav';
import { ScreenshotProvider } from '../stores/ScreenshotContext';
@@ -69,13 +68,6 @@ export default function UserReportPage() {
<RefreshCw size={12} />
다시 분석
</Link>
<Link
to={`/clinics/${clinicId}/plan/${id}`}
className="inline-flex items-center gap-1.5 px-4 py-2 rounded-full text-xs font-semibold text-white bg-gradient-to-r from-[#4F1DA1] to-[#021341] shadow-sm hover:opacity-90 transition-all"
>
<AppIcon kind="plan" size={12} />
마케팅 기획 보기
</Link>
</div>
}
/>