
from shop import views
from django.urls import path
from nexusmart import settings
from django.conf.urls.static import static
from shop import order_views
from shop.admin_views import admin_orders, update_order_status, admin_offer_requests, update_offer_status
from shop.cart_views import add_to_cart, cart_view, checkout, remove_from_cart, undo_remove, update_cart, select_installment_plan
from shop.category_views import add_category_ajax, category_create, category_detail, category_list
from shop.image_views import product_image_add, product_image_delete, product_image_list, product_images_api
from shop.inventory_views import inventory_dashboard, inventory_report, stock_adjustment
from shop.order_views import cancel_order, flutterwave_initialize, order_detail, download_invoice, email_invoice, order_list, order_tracking_partial, user_dashboard
from shop.discount_views import apply_discount_code, remove_discount_code
from shop.language_views import set_language, set_currency, get_available_languages_json

app_name = 'shop'
urlpatterns = [

    path('', views.home, name='home'),
    path('about/', views.about, name='about'),
    path('contact/', views.contact, name='contact'),
    path('customers/faq/', views.faq, name='faq'),
    path('live-visitors-count/', views.live_visitors_count, name='live_visitors_count'),
    path('help/', views.help, name='help'),
    path('products/', views.product_list, name='product_list'),
    path('products/create/', views.create_product, name='create_product'),
    path('product/<slug:slug>/', views.product_detail, name='product_detail'),
    path('product/<slug:slug>/offer/', views.make_offer, name='make_offer'),
    path('product/<slug:slug>/update/', views.product_update, name='product_update'),

    path('cart/', cart_view, name='cart'),
    path('cart/add/<int:product_id>/', add_to_cart, name='add_to_cart'),
    path('cart/update/<int:product_id>/', update_cart, name='update_cart'),
    path('cart/remove/<int:product_id>/', remove_from_cart, name='remove_from_cart'),
    path('cart/undo-remove/', undo_remove, name='undo_remove'),
    path('checkout/', checkout, name='checkout'),
    path('checkout/select-plan/<int:order_id>/', select_installment_plan, name='select_installment_plan'),
    
    # ====================== DISCOUNT MANAGEMENT ======================
    path('discount/apply/', apply_discount_code, name='apply_discount_code'),
    path('discount/remove/', remove_discount_code, name='remove_discount_code'),
    
    path('orders/', order_list, name='order_list'),
    path('client/dashboard/', user_dashboard, name='user_dashboard'),

    path('order/<int:order_id>/', order_detail, name='order_detail'),
    path('order/<int:order_id>/cancel/', cancel_order, name='cancel_order'),
    path('order/<int:order_id>/invoice/', download_invoice, name='download_invoice'),
    path('order/<int:order_id>/email-invoice/', email_invoice, name='email_invoice'),
    
    path('manage/dashboard/', views.manage_dashboard, name='manage_dashboard'),
    path('manage/admin/orders/', admin_orders, name='admin_orders'),
    path('manage/admin/orders/<int:order_id>/update/', update_order_status, name='update_order_status'),
    path('manage/admin/offers/', admin_offer_requests, name='admin_offer_requests'),
    path('manage/admin/offers/<int:offer_id>/update/', update_offer_status, name='update_offer_status'),
    
    path('wishlist/', views.wishlist_view, name='wishlist'),
    path('wishlist/toggle/<int:product_id>/', views.toggle_wishlist, name='toggle_wishlist'),
    path('review/add/<slug:product_slug>/', views.add_review, name='add_review'),
    
    path('ai-chat/', views.ai_chat_stream, name='ai_chat'),
    path('ai-chat/clear/', views.clear_chat, name='clear_chat'),
    path('escalate/', views.escalate_to_human, name='escalate_to_human'),

    path('my-tickets/', views.my_tickets, name='my_tickets'),
    path('admin-reply/<int:ticket_id>/', views.admin_reply_to_ticket, name='admin_reply_to_ticket'),
    
    path('staff/tickets/', views.all_tickets_dashboard, name='all_tickets_dashboard'),
    path('ticket/<int:ticket_id>/reply/', views.ticket_reply_customer, name='ticket_reply_customer'),
    
    # ====================== PRODUCT IMAGE MANAGEMENT ======================
    path('product/<int:product_id>/images/', product_image_list, name='product_image_list'),
    path('product/<int:product_id>/images/add/', product_image_add, name='product_image_add'),
    path('product/image/<int:image_id>/delete/', product_image_delete, name='product_image_delete'),
    path('product/<int:product_id>/images/', product_images_api, name='product_images_api'),
    path('product-images/<int:product_id>/', product_images_api, name='product_images_api'),
    
    path('inventory/', inventory_dashboard, name='inventory_dashboard'),
    path('inventory/report/<str:format_type>/', inventory_report, name='inventory_report'),
    path('product/<int:product_id>/adjust-stock/', stock_adjustment, name='stock_adjustment'),
    
    path('add-category-ajax/', add_category_ajax, name='add_category_ajax'),
    path('categories/', category_list, name='category_list'),
    path('categories/create/', category_create, name='category_create'),
    path('category/<slug:slug>/', category_detail, name='category_detail'),
    
    path('product/<int:product_id>/like/', views.toggle_like, name='toggle_like'),
    path('product/<int:product_id>/wishlist/', views.toggle_wishlist, name='toggle_wishlist'),
    
    
    path('set-currency/', set_currency, name='set_currency'),
    path('set-currency/<str:currency>/', set_currency, name='set_currency_with_code'),
    path('set-language/', set_language, name='set_language'),
    path('set-language/<str:language>/', set_language, name='set_language_with_code'),
    path('api/languages/', get_available_languages_json, name='get_available_languages_json'),
    
    path('order/<int:order_id>/tracking/', order_tracking_partial, name='order_tracking_partial'),
    path('order/<int:order_id>/payment/', flutterwave_initialize, name='flutterwave_initialize'),
    
    path('pay/flutterwave/<int:order_id>/', flutterwave_initialize, name='flutterwave_initialize'),
    
    path('flutterwave/callback/', order_views.flutterwave_callback, name='flutterwave_callback'), 
    
    path('privacy-policy/', views.privacy_policy, name='privacy_policy'),
    path('terms-of-service/', views.terms_of_service, name='terms_of_service'),
    path('cookie-policy/', views.cookie_policy, name='cookie_policy'),
    
]
