from django.urls import path
from . import views

app_name = 'campaigns'

urlpatterns = [
    # Dashboard
    path('', views.dashboard, name='dashboard'),
    
    # Campaign URLs
    path('campaigns/', views.campaign_list, name='campaign_list'),
    path('campaigns/<int:campaign_id>/', views.campaign_detail, name='campaign_detail'),
    path('campaigns/create/', views.campaign_create, name='campaign_create'),
    path('campaigns/<int:campaign_id>/edit/', views.campaign_edit, name='campaign_edit'),
    path('campaigns/<int:campaign_id>/approve/', views.campaign_approve, name='campaign_approve'),
    
    # Brand URLs
    path('brands/', views.BrandListView.as_view(), name='brand_list'),
    path('brands/<int:pk>/', views.BrandDetailView.as_view(), name='brand_detail'),
    path('brands/create/', views.BrandCreateView.as_view(), name='brand_create'),
    path('brands/<int:pk>/edit/', views.BrandUpdateView.as_view(), name='brand_edit'),
    path('brands/<int:pk>/delete/', views.BrandDeleteView.as_view(), name='brand_delete'),
    
    # Agency URLs
    path('agencies/', views.AgencyListView.as_view(), name='agency_list'),
    path('agencies/<int:pk>/', views.AgencyDetailView.as_view(), name='agency_detail'),
    path('agencies/create/', views.AgencyCreateView.as_view(), name='agency_create'),
    path('agencies/<int:pk>/edit/', views.AgencyUpdateView.as_view(), name='agency_edit'),
    path('agencies/<int:pk>/delete/', views.AgencyDeleteView.as_view(), name='agency_delete'),
    
    # Creative URLs
    path('creatives/', views.creative_list, name='creative_list'),
    path('creatives/<int:pk>/', views.CreativeDetailView.as_view(), name='creative_detail'),
    path('creatives/upload/', views.creative_upload, name='creative_upload'),
    path('creatives/<int:creative_id>/approve/', views.creative_approve, name='creative_approve'),
    path('creatives/<int:creative_id>/reject/', views.creative_reject, name='creative_reject'),
    
    # AdSpot URLs
    path('adspots/', views.adspot_list, name='adspot_list'),
    path('adspots/<int:adspot_id>/', views.adspot_detail, name='adspot_detail'),
    path('adspots/create/', views.adspot_create, name='adspot_create'),
    path('adspots/<int:adspot_id>/edit/', views.adspot_edit, name='adspot_edit'),
    
    # Report URLs
    path('reports/', views.report_list, name='report_list'),
    path('reports/<int:report_id>/', views.report_detail, name='report_detail'),
    path('campaigns/<int:campaign_id>/generate-report/', views.generate_report, name='generate_report'),
    
    # AJAX URLs
    path('ajax/campaigns/search/', views.campaign_search_ajax, name='campaign_search_ajax'),
    path('ajax/brands/search/', views.brand_search_ajax, name='brand_search_ajax'),
    path('ajax/agencies/search/', views.agency_search_ajax, name='agency_search_ajax'),
    path('ajax/campaigns/<int:campaign_id>/performance/', views.campaign_performance_ajax, name='campaign_performance_ajax'),
    
    # API URLs
    path('api/<int:campaign_id>/stats/', views.campaign_stats_api, name='campaign_stats_api'),
    
    # Legacy URLs for backward compatibility
    path('list/', views.campaign_list, name='list'),
    path('<int:campaign_id>/', views.campaign_detail, name='detail'),
    path('create/', views.campaign_create, name='create'),
    path('<int:campaign_id>/edit/', views.campaign_edit, name='edit'),
    path('<int:campaign_id>/approve/', views.campaign_approve, name='approve'),
]