from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    PollSurveyViewSet,
    ActivePollSurveyListView,
    PollSurveyDetailView,
    ResponseCreateView,
    PollSurveyResponsesListView,
)

router = DefaultRouter()
router.register(r"polls", PollSurveyViewSet, basename="poll-survey")

urlpatterns = [
    # Ministry Officer Endpoints
    path(
        "polls/<uuid:pk>/responses/",
        PollSurveyResponsesListView.as_view(),
        name="poll-responses",
    ),
    path(
        "polls/drafts/",
        PollSurveyViewSet.as_view({"get": "drafts"}),
        name="poll-drafts",
    ),
    path(
        "polls/summary/",
        PollSurveyViewSet.as_view({"get": "summary"}),
        name="poll-summary",
    ),
    path(
        "polls/trends/",
        PollSurveyViewSet.as_view({"get": "trends"}),
        name="poll-trends",
    ),
    path("", include(router.urls)),
    # Citizen Endpoints
    path("active/", ActivePollSurveyListView.as_view(), name="active-polls"),
    path("active/<uuid:id>/", PollSurveyDetailView.as_view(), name="poll-detail"),
    path("respond/", ResponseCreateView.as_view(), name="submit-response"),
]
