from django.urls import path
from . import views
from allauth.account import views as allauth_views


urlpatterns = [
    # main URLs
    path('', views.HomeView.as_view(), name='landing_page'),
    path('welcome/', views.WelcomeView.as_view(), name='welcome'),

    # Accounts URLs
    path('login/', allauth_views.LoginView.as_view(template_name='accounts/login.html'), name='login'),
    path('logout/', allauth_views.LogoutView.as_view(template_name='accounts/logout.html'), name='logout'),
    path('signup/', allauth_views.SignupView.as_view(template_name='accounts/signup.html'), name='signup'),
    path('change-password/',
         allauth_views.PasswordChangeView.as_view(template_name='accounts/password_change.html'),
         name='change_password'),
    path('reset-password/',
         allauth_views.PasswordResetView.as_view(template_name='accounts/password_reset.html'),
         name='reset_password'),
    path('password-reset-done/',
         allauth_views.PasswordResetDoneView.as_view(template_name='accounts/password_reset_done.html'),
         name='password_reset_done'),

    # Dealer URLs
    path('dealers/', views.DealerListView.as_view(), name='dealer_list'),
    path('dealers/<int:pk>/', views.DealerDetailView.as_view(), name='dealer_detail'),
    path('dealers/create/', views.DealerCreateView.as_view(), name='dealer_create'),
    path('dealers/<int:pk>/update/', views.DealerUpdateView.as_view(), name='dealer_update'),
    path('dealers/<int:pk>/delete/', views.DealerDeleteView.as_view(), name='dealer_delete'),

    # Customer URLs
    path('customers/', views.CustomerListView.as_view(), name='customer_list'),
    path('customers/<int:pk>/', views.CustomerDetailView.as_view(), name='customer_detail'),
    path('customers/create/', views.CustomerCreateView.as_view(), name='customer_create'),
    path('customers/<int:pk>/update/', views.CustomerUpdateView.as_view(), name='customer_update'),
    path('customers/<int:pk>/delete/', views.delete_customer, name='customer_delete'),
    # Vendor URLs
    path('vendors', views.VendorListView.as_view(), name='vendor_list'),
    path('vendors/<int:pk>/', views.VendorDetailView.as_view(), name='vendor_detail'),
    path('vendors/create/', views.VendorCreateView.as_view(), name='vendor_create'),
    path('vendors/<int:pk>/update/', views.VendorUpdateView.as_view(), name='vendor_update'),
    path('vendors/<int:pk>/delete/', views.delete_vendor, name='vendor_delete'),


    # Car URLs
    path('cars/inventory/<int:make_id>/<int:model_id>/<int:trim_id>/',
         views.CarInventory.as_view(),
         name='car_inventory'),
    path('cars/inventory/stats', views.inventory_stats_view, name='inventory_stats'),
    path('cars/<int:pk>/', views.CarDetailView.as_view(), name='car_detail'),
    path('cars/<int:pk>/update/', views.CarUpdateView.as_view(), name='car_update'),
    path('cars/<int:pk>/delete/', views.CarDeleteView.as_view(), name='car_delete'),
    path('cars/<int:car_pk>/finance/create/', views.CarFinanceCreateView.as_view(), name='car_finance_create'),
    path('cars/finance/update/<int:pk>/', views.CarFinanceUpdateView.as_view(), name='car_finance_update'),
    path('cars/add/', views.CarCreateView.as_view(), name='car_add'),
    path('ajax/', views.AjaxHandlerView.as_view(), name='ajax_handler'),
    path('cars/<int:car_pk>/add-color/', views.CarColorCreate.as_view(), name='add_color'),
    # path('cars/<int:car_pk>/colors/<int:pk>/update/',views.CarColorUpdateView.as_view(),name='color_update'),

    path('cars/reserve/<int:car_id>/', views.reserve_car_view, name='reserve_car'),
    path('reservations/<int:reservation_id>/', views.manage_reservation, name='reservations'),
    path('cars/<int:car_pk>/add-custom-card/', views.CustomCardCreateView.as_view(), name='add_custom_card'),

    # Sales URLs
    path('sales/quotations/create/', views.QuotationCreateView.as_view(), name='quotation_create'),
    path('sales/quotations/<int:pk>/', views.QuotationDetailView.as_view(), name='quotation_detail'),
    path('sales/quotations/', views.QuotationListView.as_view(), name='quotation_list'),
    path('sales/quotations/<int:pk>/confirm/', views.confirm_quotation, name='confirm_quotation'),
    path('sales/orders/detail/<int:order_id>/', views.SalesOrderDetailView.as_view(), name='order_detail'),

]


