from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from rest_framework_simplejwt import views as jwt_views
from django.contrib.auth import views as auth_views
from rest_framework import routers 
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
)

from .views import (
    UserViewSet, UserRetrieveUpdateAPIView, LoginAPIView, RegistrationAPIView,
)

userSignup=UserViewSet.as_view({
    'get':'list',
    'post':'create'
})

userLogin=UserViewSet.as_view({
    'get':'list',
    'post':'list'
})

userDetail=UserViewSet.as_view({
    'get':'retrieve' 
})


urlpatterns = [
    path('', include('djoser.urls')),
    path('', include('djoser.urls.authtoken')),
    path('token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('signup/', userSignup, name='user_signup'),
    path('users/<int:pk>/', userDetail, name='user-detail'),
    path('user/', UserRetrieveUpdateAPIView.as_view()),
    # path('users/', RegistrationAPIView.as_view(), name = 'register'),
    # path('users/login/', LoginAPIView.as_view(), name = 'login'),
]

if settings.DEBUG:
    urlpatterns+= static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
