from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    ComplaintViewSet,
    CitizenComplaintCreateView,
    ComplaintCategoryListView,
    CitizenComplaintListView,
    ComplaintTrendsAPIView,
    UserComplaintStatisticsAPIView,
)
from django.conf import settings
from django.conf.urls.static import static

# Create a router and register our viewsets with it.
router = DefaultRouter()
router.register(r"ministry/complaints", ComplaintViewSet, basename="ministry-complaint")

urlpatterns = [
    # API endpoints for ministry officers
    path("", include(router.urls)),
    # API endpoint for citizens to submit a new complaint and list their complaints.
    # We will use this path for both POST and GET.
    path(
        "citizen-complaint/",
        CitizenComplaintCreateView.as_view(),
        name="citizen-complaint-create",
    ),
    # Citizen endpoint to list their complaints using the user_hash as a path parameter.
    path('citizen-complaint/list/', CitizenComplaintListView.as_view(), name='citizen-complaint-list'),
    
    # API endpoint to list complaint categories
    path(
        "categories/", ComplaintCategoryListView.as_view(), name="complaint-categories"
    ),
    path("trends/", ComplaintTrendsAPIView.as_view(), name="complaint_trends"),
    path(
        "user-stats/",
        UserComplaintStatisticsAPIView.as_view(),
        name="user-complaint-statistics",
    ),
]

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