feat: 클리닉 전용 페이지 추가, PageContainer 도입, 불필요한 ui 주석처리

This commit is contained in:
minaChoi committed 2026-05-14 11:53:29 +09:00
1 parent e66b208318
commit 49367756ea
77 files changed
+3498 -924

No files matched your search

@@ -171,8 +171,9 @@ export default function ClinicSnapshot({ data }: ClinicSnapshotProps) {
{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"
className="inline-flex items-center gap-1.5 rounded-full bg-brand-tint-purple border border-brand-tint-lavender px-3 py-1 text-sm font-medium text-brand-purple-muted"
>
<Award size={12} className="text-brand-purple" />
{cert}
</span>
))}
@@ -0,0 +1,65 @@
/**
* DownloadMenuButton — 리포트 다운로드 단일 진입점.
* 클릭하면 PDF / CSV 선택 메뉴가 드롭다운으로 열림.
*
* PDF: 브라우저 네이티브 인쇄(window.print) → "PDF로 저장"
* CSV: 리포트의 표 데이터를 다중 섹션 CSV 단일 파일로 다운로드
*/
import { Download, FileText, FileSpreadsheet, ChevronDown, Loader2 } from 'lucide-react';
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
} from '@/shared/ui/dropdown-menu';
import { useExportPDF } from '@/features/report/hooks/useExportPDF';
import { useExportCSV } from '@/features/report/hooks/useExportCSV';
import type { MarketingReport } from '@/features/report/types/report';
interface DownloadMenuButtonProps {
/** 파일명 베이스. 자동으로 .pdf / .csv 확장자 붙음 */
filename: string;
/** 서버에서 받아온 리포트 전체 (CSV 생성에 사용) */
report: MarketingReport;
className?: string;
}
export function DownloadMenuButton({ filename, report, className }: DownloadMenuButtonProps) {
const { exportPDF, isExporting } = useExportPDF();
const { exportReportCSV } = useExportCSV();
return (
<DropdownMenu>
<DropdownMenuTrigger
disabled={isExporting}
className={
className ??
'inline-flex items-center gap-1.5 px-3.5 py-2 rounded-full text-xs font-medium text-slate-600 bg-slate-50 border border-slate-200 hover:bg-white hover:border-slate-300 transition-all disabled:opacity-60 disabled:cursor-wait'
}
>
{isExporting ? (
<>
<Loader2 size={12} className="animate-spin" />
생성 중...
</>
) : (
<>
<Download size={12} />
다운로드
<ChevronDown size={12} className="opacity-70" />
</>
)}
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem onSelect={() => exportPDF(filename)}>
<FileText size={14} className="text-slate-500" />
<span>PDF로 저장</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => exportReportCSV(filename, report)}>
<FileSpreadsheet size={14} className="text-slate-500" />
<span>CSV로 저장</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
}
@@ -118,9 +118,6 @@ export default function OtherChannels({ channels, website }: OtherChannelsProps)
<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>
))}
@@ -0,0 +1,51 @@
/**
* PdfDownloadButton — 리포트/플랜 PDF 다운로드 버튼.
*
* 브라우저 네이티브 인쇄 다이얼로그를 띄워 "PDF로 저장" 흐름을 사용합니다.
* `@media print` 규칙(`src/styles/custom.css`)이 레이아웃·색상·페이지 분할을 담당하며,
* `data-no-print`/`data-report-nav`/`data-plan-nav`/`data-cta-card`/`nav` 요소는
* 인쇄에서 자동 제외됩니다.
*/
import { Download, Loader2 } from 'lucide-react';
import { useExportPDF } from '@/features/report/hooks/useExportPDF';
interface PdfDownloadButtonProps {
/** PDF 파일명. 자동으로 .pdf 확장자 붙음. 'Plan' 포함 시 푸터 라벨도 변경 */
filename: string;
/** 버튼 표시 라벨. 기본: PDF */
label?: string;
className?: string;
}
export function PdfDownloadButton({
filename,
label = 'PDF',
className,
}: PdfDownloadButtonProps) {
const { exportPDF, isExporting } = useExportPDF();
return (
<button
type="button"
onClick={() => exportPDF(filename)}
disabled={isExporting}
className={
className ??
'inline-flex items-center gap-1.5 px-3.5 py-2 rounded-full text-xs font-medium text-slate-600 bg-slate-50 border border-slate-200 hover:bg-white hover:border-slate-300 transition-all disabled:opacity-60 disabled:cursor-wait'
}
title="PDF로 다운로드"
>
{isExporting ? (
<>
<Loader2 size={12} className="animate-spin" />
생성 중...
</>
) : (
<>
<Download size={12} />
{label}
</>
)}
</button>
);
}
@@ -0,0 +1,139 @@
/**
* ReportBody — 리포트 본문(헤더 + 모든 섹션) 순수 렌더링.
*
* 각 섹션은 데이터가 비어있으면 `EmptySection` 으로 fallback 되어
* "데이터가 없습니다" 안내가 표시됩니다. Guest / User 두 페이지 모두
* 동일한 동작.
*/
import type { MarketingReport } from '@/features/report/types/report';
import { SectionErrorBoundary } from '@/features/report/components/ui/SectionErrorBoundary';
import { EmptySection } from '@/features/report/components/ui/EmptySection';
import ReportHeader from '@/features/report/components/ReportHeader';
import ClinicSnapshot from '@/features/report/components/ClinicSnapshot';
import ChannelOverview from '@/features/report/components/ChannelOverview';
import YouTubeAudit from '@/features/report/components/YouTubeAudit';
import InstagramAudit from '@/features/report/components/InstagramAudit';
import FacebookAudit from '@/features/report/components/FacebookAudit';
import OtherChannels from '@/features/report/components/OtherChannels';
import ProblemDiagnosis from '@/features/report/components/ProblemDiagnosis';
import TransformationProposal from '@/features/report/components/TransformationProposal';
import RoadmapTimeline from '@/features/report/components/RoadmapTimeline';
import KPIDashboard from '@/features/report/components/KPIDashboard';
interface ReportBodyProps {
data: MarketingReport;
}
function hasValue<T>(v: T | null | undefined): v is T {
return v != null;
}
function nonEmpty<T>(arr: T[] | null | undefined): arr is T[] {
return Array.isArray(arr) && arr.length > 0;
}
export default function ReportBody({ data }: ReportBodyProps) {
// 각 audit에서 핸들 끌어와 헤더의 바로가기 버튼에 전달
const socialHandles = {
website: data.targetUrl || data.clinicSnapshot.domain || null,
youtube: data.youtubeAudit?.handle || null,
instagram: data.instagramAudit?.accounts?.[0]?.handle || null,
facebook: data.facebookAudit?.pages?.[0]?.url || data.facebookAudit?.pages?.[0]?.pageName || null,
};
return (
<div data-report-content>
<ReportHeader
overallScore={data.overallScore}
clinicName={data.clinicSnapshot.name}
clinicNameEn={data.clinicSnapshot.nameEn}
targetUrl={data.targetUrl}
date={data.createdAt}
location={data.clinicSnapshot.location}
logoImage={data.clinicSnapshot.logoImages?.horizontal}
brandColors={data.clinicSnapshot.brandColors}
socialHandles={socialHandles}
/>
<SectionErrorBoundary>
{hasValue(data.clinicSnapshot) && data.clinicSnapshot.name ? (
<ClinicSnapshot data={data.clinicSnapshot} />
) : (
<EmptySection id="clinic-snapshot" title="Clinic Overview" subtitle="병원 기본 정보" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{nonEmpty(data.channelScores) ? (
<ChannelOverview channels={data.channelScores} />
) : (
<EmptySection id="channel-overview" title="Channel Overview" subtitle="채널 종합 진단" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{hasValue(data.youtubeAudit) && data.youtubeAudit.handle ? (
<YouTubeAudit data={data.youtubeAudit} />
) : (
<EmptySection id="youtube-audit" title="YouTube Analysis" subtitle="유튜브 채널 분석" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{hasValue(data.instagramAudit) && data.instagramAudit.handle ? (
<InstagramAudit data={data.instagramAudit} />
) : (
<EmptySection id="instagram-audit" title="Instagram Analysis" subtitle="인스타그램 분석" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{hasValue(data.facebookAudit) && (data.facebookAudit.handle || data.facebookAudit.followers > 0) ? (
<FacebookAudit data={data.facebookAudit} />
) : (
<EmptySection id="facebook-audit" title="Facebook Analysis" subtitle="페이스북 페이지 분석" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{nonEmpty(data.otherChannels) || hasValue(data.websiteAudit) ? (
<OtherChannels channels={data.otherChannels ?? []} website={data.websiteAudit} />
) : (
<EmptySection id="other-channels" title="Other Channels" subtitle="기타 채널 및 웹사이트" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{nonEmpty(data.problemDiagnosis) ? (
<ProblemDiagnosis diagnosis={data.problemDiagnosis} />
) : (
<EmptySection id="problem-diagnosis" title="Problem Diagnosis" subtitle="문제 진단" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{hasValue(data.transformation) ? (
<TransformationProposal data={data.transformation} />
) : (
<EmptySection id="transformation" title="Transformation" subtitle="개선 제안" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{nonEmpty(data.roadmap) ? (
<RoadmapTimeline months={data.roadmap} />
) : (
<EmptySection id="roadmap" title="Roadmap" subtitle="실행 로드맵" />
)}
</SectionErrorBoundary>
<SectionErrorBoundary>
{nonEmpty(data.kpiDashboard) ? (
<KPIDashboard metrics={data.kpiDashboard} clinicName={data.clinicSnapshot.name} />
) : (
<EmptySection id="kpi-dashboard" title="KPI Dashboard" subtitle="핵심 지표" />
)}
</SectionErrorBoundary>
</div>
);
}
@@ -1,6 +1,8 @@
import { motion } from 'motion/react';
import { Calendar, Globe, MapPin } from 'lucide-react';
import { ScoreRing } from './ui/ScoreRing';
import { ChannelLinkButtons, type ChannelHandles } from '@/shared/ui/channel-link-buttons';
import { PageContainer } from '@/shared/ui/page-container';
function formatDate(raw: string): string {
try {
@@ -23,6 +25,8 @@ interface ReportHeaderProps {
location: string;
logoImage?: string;
brandColors?: { primary: string; accent: string; text: string };
/** 등록된 채널 핸들/URL — 외부 새 탭으로 이동 버튼 묶음을 렌더링 */
socialHandles?: ChannelHandles;
}
export default function ReportHeader({
@@ -34,6 +38,7 @@ export default function ReportHeader({
date,
targetUrl,
location,
socialHandles,
}: 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">
@@ -54,7 +59,7 @@ export default function ReportHeader({
transition={{ duration: 6, repeat: Infinity, ease: 'easeInOut' }}
/>
<div className="relative max-w-7xl mx-auto">
<PageContainer className="relative px-0">
<div className="flex flex-col md:flex-row items-center md:items-start justify-between gap-10">
{/* Left: Text content */}
<motion.div
@@ -131,6 +136,23 @@ export default function ReportHeader({
{location}
</span>
</motion.div>
{/* 등록된 채널 바로가기 */}
{socialHandles && (
<motion.div
className="mt-4"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.5 }}
>
<ChannelLinkButtons
handles={socialHandles}
variant="light"
className="justify-center md:justify-start"
/>
</motion.div>
)}
</motion.div>
{/* Right: Score ring */}
@@ -149,7 +171,7 @@ export default function ReportHeader({
</div>
</motion.div>
</div>
</div>
</PageContainer>
</section>
);
}
+46 -29
View File
@@ -1,11 +1,16 @@
import { useEffect, useRef, useState } from 'react';
import { useEffect, useRef, useState, type ReactNode } from 'react';
import { Button } from '@/shared/ui/button';
import { PageContainer } from '@/shared/ui/page-container';
interface ReportNavProps {
sections: { id: string; label: string }[];
/** 좌측 슬롯 — 보통 "워크스페이스로" 같은 뒤로가기 링크 */
leftSlot?: ReactNode;
/** 우측 슬롯 — 보통 리포트↔플랜 점프 버튼 등 보조 액션 */
rightSlot?: ReactNode;
}
export function ReportNav({ sections }: ReportNavProps) {
export function ReportNav({ sections, leftSlot, rightSlot }: ReportNavProps) {
const [activeId, setActiveId] = useState(sections[0]?.id ?? '');
const navRef = useRef<HTMLDivElement>(null);
const tabRefs = useRef<Map<string, HTMLButtonElement>>(new Map());
@@ -54,33 +59,45 @@ export function ReportNav({ sections }: ReportNavProps) {
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>
<PageContainer className="px-0 flex items-center gap-3">
{leftSlot && (
<div className="shrink-0 pl-4 md:pl-6" data-no-print>
{leftSlot}
</div>
)}
<div
ref={navRef}
className="flex-1 min-w-0 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>
{rightSlot && (
<div className="shrink-0 pr-4 md:pr-6" data-no-print>
{rightSlot}
</div>
)}
</PageContainer>
</nav>
);
}
@@ -1,5 +1,5 @@
import { motion } from 'motion/react';
import { Youtube, Users, Video, Eye, TrendingUp, ExternalLink } from 'lucide-react';
import { Youtube, Users, Video, Eye, TrendingUp, ExternalLink, ListVideo } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import { EmptyState } from './ui/EmptyState';
import { MetricCard } from './ui/MetricCard';
@@ -123,8 +123,9 @@ export default function YouTubeAudit({ data }: YouTubeAuditProps) {
{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"
className="inline-flex items-center gap-1.5 rounded-full bg-rose-50 border border-rose-200 px-3 py-1 text-sm font-medium text-rose-700"
>
<ListVideo size={12} className="text-rose-500" />
{pl}
</span>
))}
@@ -0,0 +1,21 @@
/**
* EmptySection — SectionWrapper + EmptyState 조합.
* 섹션 전체가 비었을 때 사용. 서브섹션은 `EmptyState` 단독 사용.
*/
import { SectionWrapper } from './SectionWrapper';
import { EmptyState } from '@/shared/ui/empty-state';
interface EmptySectionProps {
id: string;
title: string;
subtitle?: string;
hint?: string;
}
export function EmptySection({ id, title, subtitle, hint }: EmptySectionProps) {
return (
<SectionWrapper id={id} title={title} subtitle={subtitle}>
<EmptyState size="lg" hint={hint} />
</SectionWrapper>
);
}
@@ -57,8 +57,9 @@ export function ScoreRing({
strokeLinecap="round"
strokeDasharray={circumference}
initial={{ strokeDashoffset: circumference }}
animate={{ strokeDashoffset }}
transition={{ duration: 1, ease: 'easeOut' }}
whileInView={{ strokeDashoffset }}
viewport={{ once: true, margin: '-50px' }}
transition={{ duration: 1.2, ease: 'easeOut' }}
/>
</svg>
<div className="absolute inset-0 flex items-center justify-center">
@@ -1,4 +1,5 @@
import type { ReactNode } from 'react';
import { PageContainer } from '@/shared/ui/page-container';
interface SectionWrapperProps {
id: string;
@@ -32,7 +33,7 @@ export function SectionWrapper({
{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">
<PageContainer className="relative px-0">
<div className="mb-10">
<h2
className={`
@@ -54,7 +55,7 @@ export function SectionWrapper({
)}
</div>
{children}
</div>
</PageContainer>
</section>
);
}