from django.urls import path, include
from . import views

urlpatterns = [
    path(
        '',
        views.DashboardHomeView.as_view(),
        name='home'
    ),
    path(
        'config/',
        views.DashboardConfigView.as_view(),
        name='config'
    ),
    path(
        'settings/<int:pk>/update/',
        views.SiteSettingsUpdateView.as_view(),
        name='settings-update'
    ),
    path(
        'catalog/',
        views.CatalogView.as_view(),
        name='catalog'
    ),
    path(
        'stock/',
        views.StockView.as_view(),
        name='stock'
    ),

    path(
        'shipping-rates/new/',
        views.ShippingRateCreateView.as_view(),
        name='rate-create'
    ),
    path('shipping-rates/<int:pk>/', include([
        path(
            '',
            views.ShippingRateDetailView.as_view(),
            name='rate-detail'
        ),
        path(
            'update/',
            views.ShippingRateUpdateView.as_view(),
            name='rate-update'
        ),
        path(
            'delete/',
            views.ShippingRateDeleteView.as_view(),
            name='rate-delete'
        ),
    ])),

    path(
        'coupons/',
        views.CouponListView.as_view(),
        name='coupon-list'
    ),
    path(
        'coupons/new/',
        views.CouponCreateView.as_view(),
        name='coupon-create'
    ),
    path('coupons/<int:pk>/', include([
        path(
            '',
            views.CouponDetailView.as_view(),
            name='coupon-detail'
        ),
        path(
            'update/',
            views.CouponUpdateView.as_view(),
            name='coupon-update'
        ),
        path(
            'delete/',
            views.CouponDeleteView.as_view(),
            name='coupon-delete'
        ),
    ])),

    path(
        'orders/',
        views.OrderListView.as_view(),
        name='order-list'
    ),
    path('orders/<int:pk>/', include([
        path(
            '',
            views.OrderDetailView.as_view(),
            name='order-detail'
        ),
        path(
            'fulfill/',
            views.OrderFulfillView.as_view(),
            name='order-fulfill'
        ),
        path(
            'cancel/',
            views.OrderCancelView.as_view(),
            name='order-cancel'
        ),
        path(
            'ship/',
            views.OrderTrackingView.as_view(),
            name='order-ship'
        ),
    ])),

    # Categories
    path('categories/', include([
        path(
            '',
            views.CategoryListView.as_view(),
            name='category-list'
        ),
        path(
            'new/',
            views.CategoryCreateView.as_view(),
            name='category-create'
        ),
        path('<int:pk>/', include([
            path(
                '',
                views.CategoryDetailView.as_view(),
                name='category-detail'
            ),
            path(
                'update/',
                views.CategoryUpdateView.as_view(),
                name='category-update'
            ),
            path(
                'delete/',
                views.CategoryDeleteView.as_view(),
                name='category-delete'
            ),
        ])),
    ])),

    path(
        'products/',
        views.ProductListView.as_view(),
        name='product-list'
    ),
    path(
        'products/new/',
        views.ProductCreateView.as_view(),
        name='product-create'
    ),
    path('products/<int:pk>/', include([
        path(
            '',
            views.ProductDetailView.as_view(),
            name='product-detail'
        ),
        path(
            'update/',
            views.ProductUpdateView.as_view(),
            name='product-update'
        ),
        path(
            'delete/',
            views.ProductDeleteView.as_view(),
            name='product-delete'
        ),

        path(
            'photos/new/',
            views.ProductPhotoCreateView.as_view(),
            name='prodphoto-create'
        ),
        path('photos/<int:photo_pk>/', include([
            path(
                'delete/',
                views.ProductPhotoDeleteView.as_view(),
                name='prodphoto-delete'
            ),
        ])),

        # ProductVariants
        path('variants/', include([
            path(
                'new/',
                views.ProductVariantCreateView.as_view(),
                name='variant-create'
            ),
            path('<int:variant_pk>/', include([
                path(
                    'update/',
                    views.ProductVariantUpdateView.as_view(),
                    name='variant-update'
                ),
                path(
                    'delete/',
                    views.ProductVariantDeleteView.as_view(),
                    name='variant-delete'
                ),
                path(
                    'restock/',
                    views.ProductVariantStockUpdateView.as_view(),
                    name='variant-restock'
                ),
            ])),
        ])),
    ])),

    # ProductOptions
    path('options/', include([
        path(
            'new/',
            views.ProductOptionCreateView.as_view(),
            name='option-create'
        ),
        path('<int:pk>/', include([
            path(
                '',
                views.ProductOptionDetailView.as_view(),
                name='option-detail'
            ),
            path(
                'update/',
                views.ProductOptionUpdateView.as_view(),
                name='option-update'
            ),
            path(
                'delete/',
                views.ProductOptionDeleteView.as_view(),
                name='option-delete'
            ),
        ])),
    ])),

    path(
        'update-sorting/',
        views.update_sorting,
        name='update-sorting'
    ),

    path(
        'customers/',
        views.CustomerListView.as_view(),
        name='customer-list'
    ),
    path('customers/<int:pk>/', include([
        path(
            '',
            views.CustomerDetailView.as_view(),
            name='customer-detail'
        ),
        path(
            'update/',
            views.CustomerUpdateView.as_view(),
            name='customer-update'
        ),
    ])),
]
