/** * Секция карточек метрик для дашборда ментора (iOS 26). */ 'use client'; import React from 'react'; import { MentorDashboardResponse } from '@/api/dashboard'; import { StatsGrid, type StatsGridItem } from '../ui'; const IconUsers = ( ); const IconCalendar = ( ); const IconRevenue = ( ); const IconClipboard = ( ); export interface StatsSectionProps { stats: MentorDashboardResponse | null; loading: boolean; } function buildGridItems(stats: MentorDashboardResponse | null, loading: boolean): StatsGridItem[] { const s = stats?.summary; return [ { title: 'Всего учеников', value: loading ? '—' : (s?.total_clients ?? 0), icon: IconUsers, loading, }, { title: 'Завершённых занятий (месяц / всего)', value: loading ? '—' : `${s?.lessons_this_month ?? 0}/${s?.completed_lessons ?? 0}`, icon: IconCalendar, loading, }, { title: 'Доход (месяц / всё время)', value: loading ? '—' : `${s?.revenue_this_month != null ? `${Math.round(s.revenue_this_month).toLocaleString('ru-RU')} ₽` : '0 ₽'} / ${ s?.total_revenue != null ? `${Math.round(s.total_revenue).toLocaleString('ru-RU')} ₽` : '0 ₽' }`, icon: IconRevenue, loading, }, { title: 'Заданий на проверке / всего', value: loading ? '—' : `${s?.pending_submissions ?? 0}/${s?.total_homeworks ?? 0}`, icon: IconClipboard, loading, }, ]; } export const StatsSection: React.FC = ({ stats, loading }) => { const gridItems = buildGridItems(stats, loading); return (
); };