'use client';
import Link from 'next/link';
import { useMemo } from 'react';
import { useMediaCatalog, getSceneStageBackgroundStyle } from '@/entities/media';
import { usePlanTier } from '@/entities/plan';
import { getSceneById, SCENE_THEMES } from '@/entities/scene';
import { useFocusStats } from '@/features/stats';
import { copy } from '@/shared/i18n';
import { cn } from '@/shared/lib/cn';
const DEFAULT_STATS_SCENE_ID = getSceneById('forest')?.id ?? SCENE_THEMES[0].id;
const reviewStageSceneByPreset = (presetId: string) => {
if (presetId.startsWith('forest')) {
return getSceneById('forest') ?? SCENE_THEMES[0];
}
return getSceneById(DEFAULT_STATS_SCENE_ID) ?? SCENE_THEMES[0];
};
export const StatsOverviewWidget = () => {
const { stats } = copy;
const { isPro } = usePlanTier();
const { sceneAssetMap } = useMediaCatalog();
const { review, isLoading, error, source, refetch } = useFocusStats();
const activeScene = useMemo(
() => reviewStageSceneByPreset(review.carryForward.presetId),
[review.carryForward.presetId],
);
const sourceLabel = source === 'api' ? stats.sourceApi : stats.sourceMock;
const syncLabel = error ? error : isLoading ? stats.loading : stats.synced;
const carryForwardCtaLabel = isPro ? stats.reviewCarryCtaPro : review.carryForward.ctaLabel;
return (
{/* Immersive Background */}
{/* Premium Cinematic Overlays */}
{/* Header */}
{/* Main Flow */}
{/* 1. Hero Summary (Cinematic Entry) */}
{review.periodLabel}
{sourceLabel}
{review.snapshotSummary}
{syncLabel}
{/* Inline Snapshot Metrics */}
{review.snapshotMetrics.map((metric) => (
{metric.label}
{metric.value}
{metric.hint}
))}
{/* 2. Insight Pillars (Start, Recovery, Completion) */}
{[
{
data: review.startQuality,
accent: 'bg-[radial-gradient(circle_at_top,rgba(96,165,250,0.15),transparent_70%)]'
},
{
data: review.recoveryQuality,
accent: 'bg-[radial-gradient(circle_at_top,rgba(20,184,166,0.15),transparent_70%)]'
},
{
data: review.completionQuality,
accent: 'bg-[radial-gradient(circle_at_top,rgba(245,158,11,0.15),transparent_70%)]'
}
].map((column, idx) => (
{column.data.title}
{column.data.summary}
{column.data.metrics.map((metric, mIdx) => (
0 && "pt-6 border-t border-white/5")}>
{metric.label}
{metric.value}
{metric.hint}
))}
{column.data.metrics.length === 0 && (
지표 데이터가 부족합니다.
)}
{column.data.note && (
)}
{column.data.availability === 'limited' && (
Limited Data
)}
))}
{/* 3. Carry Forward Climax */}
Carry Forward
다음 세션에 가져갈 흐름
"{review.carryForward.keepDoing}"
작은 변화 시도하기
{review.carryForward.tryNext}
추천 Atmosphere
{isPro && PRO}
{review.carryForward.presetLabel}
가장 무리 없이 들어갈 수 있는 흐름.
{carryForwardCtaLabel}
Review는 끝이 아니라, 더 가벼운 시작을 위한 출발점입니다.
);
};