import { BarChart3 } from 'lucide-react'; import EmptyState from '@/components/ui/EmptyState'; import SegmentedControl from '@/components/ui/SegmentedControl'; import Surface from '@/components/ui/Surface'; import { DashboardRange, DashboardTrafficPoint } from '@/types'; interface AdminDashboardTrafficChartProps { points: DashboardTrafficPoint[]; range: DashboardRange; onRangeChange: (range: DashboardRange) => void; isFallback: boolean; } const rangeOptions = [ { label: '7일', value: '7d' }, { label: '30일', value: '30d' }, { label: '90일', value: '90d' }, ] satisfies { label: string; value: DashboardRange }[]; const formatDay = (value: string) => { const date = new Date(value); if (Number.isNaN(date.getTime())) return value; return new Intl.DateTimeFormat('ko-KR', { month: 'numeric', day: 'numeric', }).format(date); }; export default function AdminDashboardTrafficChart({ points, range, onRangeChange, isFallback, }: AdminDashboardTrafficChartProps) { const maxViews = Math.max(...points.map((point) => point.views), 1); const hasTraffic = points.some((point) => point.views > 0); return (

트래픽 흐름

{isFallback ? '대시보드 집계 전에는 게시글 누적 조회수로 임시 흐름을 표시합니다.' : '최근 기간별 조회수 흐름을 확인합니다.'}

{points.length > 0 ? ( <>
{points.map((point) => { const height = Math.max((point.views / maxViews) * 100, 4); return (
{formatDay(point.date)}
); })}
{isFallback && (

{hasTraffic ? '임시 그래프는 글 발행일과 누적 조회수를 기준으로 계산됩니다.' : '집계 API가 연결되면 실제 일별 조회수로 대체됩니다.'}

)} ) : ( )} ); }