/** * Секция «Динамика доходов» для дашборда ментора (iOS 26). * Использует переиспользуемые Panel, SectionHeader, SegmentedControl. */ 'use client'; import React from 'react'; import { MentorIncomeResponse } from '@/api/dashboard'; import { Panel, SectionHeader, SegmentedControl } from '../ui'; import { RevenueChart } from '../RevenueChart'; import { LoadingSpinner } from '@/components/common/LoadingSpinner'; export type IncomePeriod = 'day' | 'week' | 'month'; export interface IncomeSectionProps { data: MentorIncomeResponse | null; period: IncomePeriod; onPeriodChange: (p: IncomePeriod) => void; loading: boolean; } const PERIOD_OPTIONS = [ { value: 'day' as const, label: 'День' }, { value: 'week' as const, label: 'Неделя' }, { value: 'month' as const, label: 'Месяц' }, ]; export const IncomeSection: React.FC = ({ data, period, onPeriodChange, loading, }) => { const totalIncome = Number(data?.summary?.total_income ?? 0); const totalLessons = Number(data?.summary?.total_lessons ?? 0); const averageLessonPrice = Number(data?.summary?.average_lesson_price ?? 0); return ( } /> {loading && !data ? ( ) : ( <>

Всего доход

{data?.summary ? `${Math.round(totalIncome).toLocaleString('ru-RU')} ₽` : '—'}

Занятий

{data?.summary ? totalLessons : '—'}

Средняя цена

{data?.summary ? `${Math.round(averageLessonPrice).toLocaleString('ru-RU')} ₽` : '—'}

)}
); };