"""
URL configuration for RPS_project project.
"""

from django.contrib import admin
from django.urls import path, include
from users.serializers import CustomTokenObtainPairSerializer

from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
)

# Add these two lines
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/", include("tenants.urls")),
    path("api/complaints/", include("complaints.urls")),
    path("api/polls_surveys/", include("polls_surveys.urls")),
    path("api/feedback/", include("feedback.urls")),
    # Users app API
    path("api/", include("users.urls")),
    # Use our new custom serializer here
    path(
        "api/token/",
        TokenObtainPairView.as_view(serializer_class=CustomTokenObtainPairSerializer),
        name="token_obtain_pair",
    ),
    path("api/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
]

# Add this block for serving media files in development
if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
