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

from apps.accounts import views as account_views_main
from apps.accounts.views import user_settings, CustomTokenObtainPairView

from .ui_views import (
    acknowledgement_category_list,
    acknowledgement_checklist_list,
    acknowledgement_content_list,
    acknowledgement_dashboard,
    bulk_deactivate_users,
    bulk_invite_users,
    bulk_resend_invitations,
    change_password_view,
    CustomPasswordResetConfirmView,
    export_provisional_users,
    login_view,
    logout_view,
    onboarding_activate,
    onboarding_complete,
    onboarding_step_activation,
    onboarding_step_checklist,
    onboarding_step_content,
    onboarding_welcome,
    password_reset_view,
    password_reset_token_view,
    preview_wizard_as_role,
    provisional_user_list,
    provisional_user_progress,
    staff_activity_log,
)

app_name = "accounts"

router = DefaultRouter()
router.register(r"users", account_views_main.UserViewSet, basename="user")
router.register(r"roles", account_views_main.RoleViewSet, basename="role")
router.register(
    r"api/checklist-items",
    account_views_main.AcknowledgementChecklistItemViewSet,
    basename="checklist-items",
)
router.register(
    r"api/content-items",
    account_views_main.AcknowledgementContentViewSet,
    basename="content-items",
)
router.register(
    r"api/category-items",
    account_views_main.AcknowledgementCategoryViewSet,
    basename="category-items",
)

urlpatterns = [
    path("acknowledgements/", include("apps.accounts.simple_acknowledgement_urls")),
    path("login/", login_view, name="login"),
    path("logout/", logout_view, name="logout"),
    path("settings/", user_settings, name="settings"),
    path("password/reset/", password_reset_view, name="password_reset"),
    path("password/reset/<str:token>/", password_reset_token_view, name="password_reset_token"),
    path(
        "password/reset/confirm/<uidb64>/<token>/",
        CustomPasswordResetConfirmView.as_view(),
        name="password_reset_confirm",
    ),
    path("password/change/", change_password_view, name="password_change"),
    path("token/", CustomTokenObtainPairView.as_view(), name="token_obtain_pair"),
    path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
    path("", include(router.urls)),
    path("onboarding/activate/<str:token>/", onboarding_activate, name="onboarding-activate"),
    path("onboarding/welcome/", onboarding_welcome, name="onboarding-welcome"),
    path("onboarding/wizard/step/<int:step>/", onboarding_step_content, name="onboarding-step-content"),
    path("onboarding/wizard/checklist/", onboarding_step_checklist, name="onboarding-step-checklist"),
    path("onboarding/wizard/activation/", onboarding_step_activation, name="onboarding-step-activation"),
    path("onboarding/complete/", onboarding_complete, name="onboarding-complete"),
    path("onboarding/provisional/", provisional_user_list, name="provisional-user-list"),
    path(
        "onboarding/provisional/<uuid:user_id>/progress/", provisional_user_progress, name="provisional-user-progress"
    ),
    path("onboarding/bulk-invite/", bulk_invite_users, name="bulk-invite-users"),
    path("onboarding/bulk-resend/", bulk_resend_invitations, name="bulk-resend-invitations"),
    path("onboarding/bulk-deactivate/", bulk_deactivate_users, name="bulk-deactivate-users"),
    path("onboarding/export/users/", export_provisional_users, name="export-provisional-users"),
    path("onboarding/preview/", preview_wizard_as_role, name="preview-wizard"),
    path("onboarding/preview/<str:role>/", preview_wizard_as_role, name="preview-wizard-role"),
    path("onboarding/dashboard/", acknowledgement_dashboard, name="onboarding-dashboard"),
    path("onboarding/categories/", acknowledgement_category_list, name="onboarding-category-list"),
    path("onboarding/content/", acknowledgement_content_list, name="onboarding-content-list"),
    path("onboarding/checklist/", acknowledgement_checklist_list, name="onboarding-checklist-list"),
    path("activity/", staff_activity_log, name="staff-activity-log"),
]
