"""
URL маршруты для пользователей и аутентификации.
"""
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from rest_framework_simplejwt.views import TokenRefreshView

from .views import (
    RegisterView,
    LoginView,
    LoginByTokenView,
    LogoutView,
    TelegramAuthView,
    TelegramBotInfoView,
    ChangePasswordView,
    PasswordResetRequestView,
    PasswordResetConfirmView,
    EmailVerificationView,
    ResendVerificationEmailView,
    UserViewSet,
    ClientViewSet,
    ParentViewSet,
    GroupViewSet,
)
from .dashboard_views import (
    MentorDashboardViewSet,
    ClientDashboardViewSet,
    ParentDashboardViewSet
)
from .profile_views import (
    ProfileViewSet,
    ClientManagementViewSet,
    ParentManagementViewSet,
    InvitationViewSet,
)
from .mentorship_views import MentorshipRequestViewSet
from .student_progress_views import StudentProgressViewSet
from .nav_badges_views import NavBadgesView

# Router для ViewSets
router = DefaultRouter()
router.register(r'users', UserViewSet, basename='user')
router.register(r'clients', ClientViewSet, basename='client')
router.register(r'parents', ParentViewSet, basename='parent')
router.register(r'groups', GroupViewSet, basename='group')

# Дашборды
router.register(r'mentor', MentorDashboardViewSet, basename='mentor')
router.register(r'client', ClientDashboardViewSet, basename='client-dashboard')
router.register(r'parent', ParentDashboardViewSet, basename='parent-dashboard')

# Профили
router.register(r'profile', ProfileViewSet, basename='profile')
router.register(r'manage/clients', ClientManagementViewSet, basename='manage-clients')
router.register(r'invitation', InvitationViewSet, basename='invitation')
router.register(r'mentorship-requests', MentorshipRequestViewSet, basename='mentorship-request')
router.register(r'manage/parents', ParentManagementViewSet, basename='manage-parents')

# Прогресс студентов
router.register(r'student-progress', StudentProgressViewSet, basename='student-progress')

# URL patterns
urlpatterns = [
    # Auth endpoints
    path('auth/register/', RegisterView.as_view(), name='register'),
    path('auth/login/', LoginView.as_view(), name='login'),
    path('auth/login-by-token/', LoginByTokenView.as_view(), name='login_by_token'),
    path('auth/telegram/', TelegramAuthView.as_view(), name='telegram_auth'),
    path('auth/telegram/bot-info/', TelegramBotInfoView.as_view(), name='telegram_bot_info'),
    path('auth/logout/', LogoutView.as_view(), name='logout'),
    path('auth/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    
    # Password management
    path('auth/change-password/', ChangePasswordView.as_view(), name='change_password'),
    path('auth/password-reset/', PasswordResetRequestView.as_view(), name='password_reset'),
    path('auth/password-reset-confirm/', PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
    
    # Email verification
    path('auth/verify-email/', EmailVerificationView.as_view(), name='verify_email'),
    path('auth/resend-verification/', ResendVerificationEmailView.as_view(), name='resend_verification'),
    
    # Бейджи нижнего меню (один запрос)
    path('nav-badges/', NavBadgesView.as_view(), name='nav-badges'),

    # User management
    path('', include(router.urls)),
]
