'use client'; import { useState, useEffect } from 'react'; import { usePathname, useRouter } from 'next/navigation'; import { useOnboarding } from '@/contexts/OnboardingContext'; import { useAuth } from '@/contexts/AuthContext'; import { getOnboardingKey } from '@/lib/onboarding-steps'; const PAGE_LABELS: Record = { dashboard: 'Главная', schedule: 'Расписание', students: 'Студенты', materials: 'Материалы', homework: 'Домашние задания', feedback: 'Обратная связь', analytics: 'Аналитика', payment: 'Тарифы', referrals: 'Рефералы', profile: 'Профиль', chat: 'Чат', 'my-progress': 'Прогресс', 'request-mentor': 'Мои менторы', }; const MENTOR_PAGES = ['dashboard', 'schedule', 'students', 'materials', 'homework', 'feedback', 'analytics', 'payment', 'referrals', 'profile']; const CLIENT_PAGES = ['dashboard', 'schedule', 'chat', 'materials', 'homework', 'my-progress', 'request-mentor', 'profile']; export function OnboardingTipsSection() { const onboarding = useOnboarding(); const { user } = useAuth(); const pathname = usePathname(); const router = useRouter(); const [progress, setProgress] = useState({ seen: 0, total: 0 }); const [expanded, setExpanded] = useState(false); const role = user?.role === 'mentor' ? 'mentor' : user?.role === 'client' ? 'client' : user?.role === 'parent' ? 'parent' : null; const pages = role === 'mentor' ? MENTOR_PAGES : role === 'client' ? CLIENT_PAGES : MENTOR_PAGES; useEffect(() => { if (!onboarding) return; onboarding.refreshProgress().then(() => { setProgress(onboarding.getProgress()); }); }, [onboarding, pathname]); if (!onboarding || !role) return null; const currentKey = getOnboardingKey(pathname || '', role as 'mentor' | 'client' | 'parent'); const handleShowAgain = () => { if (currentKey) onboarding.runTourManually(currentKey, { force: true }); }; const handleShowOnPage = (pageKey: string) => { setExpanded(false); const path = pageKey === 'dashboard' ? '/dashboard' : `/${pageKey}`; router.push(path); setTimeout(() => onboarding.runTourManually(pageKey, { force: true }), 800); }; if (progress.total === 0) return null; return (

Подсказки по платформе

Пройдено {progress.seen} из {progress.total} страниц

{currentKey && ( )}
{expanded && (
{pages.map((key) => ( ))}
)}
); }