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

from apps.account.views import (
    account_views,
    user_vehicle_views,
    admin_account_views,
    contact_us_views,
    subscribe_newsletter_views,
)

router = routers.DefaultRouter(trailing_slash=False)


router.register(
    r"profile",
    account_views.ProfileModelViewSet,
    basename="profile",
)
router.register(
    r"vehicle/(?P<user_vehicle_id>\d+)/media",
    user_vehicle_views.UserVehicleAssetsModelViewSet,
    basename="user-vehicle-media",
)
router.register(
    r"vehicle",
    user_vehicle_views.UserVehicleModelViewSet,
    basename="user-vehicle",
)

router.register(
    r"contact-us",
    contact_us_views.ContactUsModelViewSet,
    basename="contact-us",
)

router.register(
    r"subscribe-newsletters",
    subscribe_newsletter_views.AccountSubscriberModelViewSet,
    basename="account-subscribe-newsletters",
)

urlpatterns = [
    path("", include(router.urls)),
    path("create", account_views.LoginOrRegistrationView.as_view(), name="login"),
    path(
        "verify/otp",
        account_views.VerifyLoginOrRegistrationOtpView.as_view(),
        name="verify_otp",
    ),
    path(
        "resend/otp",
        account_views.ResendOtpView.as_view(),
        name="resend-otp",
    ),
    path(
        "admin/login",
        admin_account_views.AdminLoginView.as_view(),
        name="admin-login",
    ),
    path(
        "admin/change/password",
        admin_account_views.AdminChangePasswordView.as_view(),
        name="admin-change-password",
    ),
    path(
        "admin/forgot-password",
        admin_account_views.ForgotPasswordView.as_view(),
        name="admin-forgot-password",
    ),
    path(
        "admin/reset-password/<str:uidb64>/<str:token>",
        admin_account_views.ResetPasswordView.as_view(),
        name="reset-password",
    ),
    path("login/refresh", TokenRefreshView.as_view(), name="token_refresh"),
    path(
        "logout",
        account_views.UserLogoutView.as_view(),
        name="logout",
    ),
]
