from django.urls import path
from . import views
from django.urls import path, include
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
router.register(r'users', views.UserView, basename='user')

urlpatterns = [
    # Auth endpoints
    path('login/', views.CookieTokenObtainPairView.as_view(), name='login'),
    path('token/refresh/', views.CookieTokenRefreshView.as_view(), name='token-refresh'),
    path('logout/', views.LogoutView.as_view(), name='logout'),
    path('user/me/', views.CurrentUserView.as_view(), name='user-detail'),

    # Registration & email endpoints
    path('register/', views.UserRegistrationViewSet.as_view({'post': 'create'}), name='register'),
    path('verify-email/<uidb64>/<token>/', views.EmailVerificationView.as_view(), name='verify-email'),
    path('resend-verification/', views.ResendEmailVerificationView.as_view(), name='resend-email-verification'),

    # Account deletion
    path('delete/', views.DeleteAccountView.as_view(), name='delete-account'),

    # Email & username change
    path('change-email/', views.ChangeEmailView.as_view(), name='change-email'),
    path('confirm-email-change/<uidb64>/<token>/', views.ConfirmEmailChangeView.as_view(), name='confirm-email-change'),
    path('change-username/', views.ChangeUsernameView.as_view(), name='change-username'),

    # Password reset endpoints
    path('password-reset/', views.PasswordResetRequestView.as_view(), name='password-reset-request'),
    path('password-reset-confirm/<uidb64>/<token>/', views.PasswordResetConfirmView.as_view(), name='password-reset-confirm'),
    path('password-change/', views.ChangePasswordView.as_view(), name='password-change'),

    # User CRUD (list, retrieve, update, delete)
    path('', include(router.urls)), #/users/
]
