from django.urls import include, path
from rest_framework.routers import DefaultRouter

from .views import PXSourceViewSet
from . import ui_views

app_name = 'px_sources'

router = DefaultRouter()
router.register(r'api/sources', PXSourceViewSet, basename='pxsource-api')

urlpatterns = [
    # Source User Dashboard & Lists
    path('dashboard/', ui_views.source_user_dashboard, name='source_user_dashboard'),
    path('complaints/', ui_views.source_user_complaint_list, name='source_user_complaint_list'),
    path('inquiries/', ui_views.source_user_inquiry_list, name='source_user_inquiry_list'),
    
    # PX Sources Management Views
    path('<uuid:pk>/users/create/', ui_views.source_user_create, name='source_user_create'),
    path('<uuid:pk>/users/<uuid:user_pk>/edit/', ui_views.source_user_edit, name='source_user_edit'),
    path('<uuid:pk>/users/<uuid:user_pk>/delete/', ui_views.source_user_delete, name='source_user_delete'),
    path('<uuid:pk>/users/<uuid:user_pk>/toggle/', ui_views.source_user_toggle_status, name='source_user_toggle_status'),
    path('', ui_views.source_list, name='source_list'),
    path('new/', ui_views.source_create, name='source_create'),
    path('<uuid:pk>/', ui_views.source_detail, name='source_detail'),
    path('<uuid:pk>/edit/', ui_views.source_edit, name='source_edit'),
    path('<uuid:pk>/delete/', ui_views.source_delete, name='source_delete'),
    path('<uuid:pk>/toggle/', ui_views.source_toggle_status, name='source_toggle_status'),
    
    # AJAX Helpers
    path('ajax/search/', ui_views.ajax_search_sources, name='ajax_search_sources'),
    path('ajax/choices/', ui_views.ajax_source_choices, name='ajax_source_choices'),
    
    # API Routes
    path('', include(router.urls)),
]