/** * UserPlanPage — `/clinics/:clinicId/plan/:id` * * 계약된 병원 유저가 워크스페이스에서 운영하는 마케팅 기획 화면. * GuestPlanPage 의 본문 + 워크스페이스 액션바 + 인터랙티브 섹션 * (MyAssetUpload / StrategyAdjustmentSection / WorkflowTracker). */ import { useEffect } from 'react'; import { Link, useParams, useLocation } from 'react-router'; import { ArrowLeft, FileSearch } from 'lucide-react'; import { useMarketingPlan } from '../hooks/useMarketingPlan'; import { ReportNav } from '@/features/report/components/ReportNav'; import { PdfDownloadButton } from '@/features/report/components/PdfDownloadButton'; import { PLAN_SECTIONS } from '@/shared/constants/planSections'; import PlanBody from '../components/PlanBody'; import MyAssetUpload from '../components/MyAssetUpload'; import StrategyAdjustmentSection from '../components/StrategyAdjustmentSection'; import WorkflowTracker from '../components/WorkflowTracker'; export default function UserPlanPage() { const { clinicId, id } = useParams<{ clinicId: string; id: string }>(); const location = useLocation(); const stateClinicId = (location.state as { clinicId?: string } | undefined)?.clinicId || null; const { data, isLoading, error } = useMarketingPlan(id); useEffect(() => { if (isLoading || !location.hash) return; const sectionId = location.hash.slice(1); const timer = setTimeout(() => { const el = document.getElementById(sectionId); if (!el) return; const STICKY_OFFSET = 128; const y = el.getBoundingClientRect().top + window.scrollY - STICKY_OFFSET; window.scrollTo({ top: y, behavior: 'smooth' }); }, 300); return () => clearTimeout(timer); }, [isLoading, location.hash]); if (isLoading) { return (

마케팅 기획을 불러오는 중...

); } if (error || !data) { return (

오류가 발생했습니다

{error ?? '마케팅 기획을 찾을 수 없습니다.'}

); } // baseRunId(이 플랜의 베이스 리포트) — 데이터 모델에 정식 필드 있으면 그걸 우선 const baseRunId = (data as unknown as { baseReportId?: string }).baseReportId || (data as unknown as { reportId?: string }).reportId || null; // 데모 환경: baseRunId 가 없으면 같은 plan id 로 리포트도 존재 (1:1 매핑) const reportTargetId = baseRunId ?? id; return (
워크스페이스로 } rightSlot={
{reportTargetId && ( 기반 리포트 )}
} /> {/* 유저 전용 인터랙티브 섹션 */} {data.workflow && (
)}
); }