from django.urls import path
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from rest_framework_simplejwt.views import TokenRefreshView
from users.views import RegisterView, LoginView, LogoutView, ChangePasswordView
from subscriptions.views import ContactView, ProfileView
from ecommerce.views import (
    ProductViewSet,
    ProductFeatureViewSet,
    ProductDescriptionViewSet,
    ProductImageViewSet,
    ProductCategoryView,
)

from django.contrib import admin

admin.site.site_header = "Lucetech administration"      # replaces 'Django administration'
admin.site.site_title = "Lucetech admin"               # browser tab title
admin.site.index_title = "Lucetech admin dashboard"    # index page title


urlpatterns = [
    path('api/auth/admin', admin.site.urls),
    path("api/auth/register/", RegisterView.as_view(), name="auth-register"),
    path("api/auth/login/",    LoginView.as_view(),    name="auth-login"),
    path("api/auth/logout/",   LogoutView.as_view(),   name="auth-logout"),
    path("api/auth/password/change/", ChangePasswordView.as_view(), name="auth-password-change"),
    path("api/auth/token/refresh/", TokenRefreshView.as_view(), name="token-refresh"),

    # Subscriptions
    path("api/lucetech/profile/create", ProfileView.as_view(), name="create-profile"),
    path("api/lucetech/profile/get", ProfileView.as_view(), name="get-profile"),
    path("api/lucetech/contact/create", ContactView.as_view(), name="create-contact"),
    path("api/lucetech/contact/get", ContactView.as_view(), name="get-contact"),

    # E-commerce Products
    path("api/ecommerce/products/list", ProductViewSet.as_view({'get': 'list'}), name="product-list"),
    path("api/ecommerce/products/create", ProductViewSet.as_view({'post': 'create'}), name="product-create"),
    path("api/ecommerce/products/<int:pk>/get", ProductViewSet.as_view({'get': 'retrieve'}), name="product-detail"),
    path("api/ecommerce/products/<int:pk>/update", ProductViewSet.as_view({'put': 'update', 'patch': 'partial_update'}), name="product-update"),
    path("api/ecommerce/products/<int:pk>/delete", ProductViewSet.as_view({'delete': 'destroy'}), name="product-delete"),

    # Product Features
    path("api/ecommerce/product-features/list", ProductFeatureViewSet.as_view({'get': 'list'}), name="product-feature-list"),
    path("api/ecommerce/product-features/create", ProductFeatureViewSet.as_view({'post': 'create'}), name="product-feature-create"),
    path("api/ecommerce/product-features/<int:pk>/get", ProductFeatureViewSet.as_view({'get': 'retrieve'}), name="product-feature-detail"),
    path("api/ecommerce/product-features/<int:pk>/update", ProductFeatureViewSet.as_view({'put': 'update', 'patch': 'partial_update'}), name="product-feature-update"),
    path("api/ecommerce/product-features/<int:pk>/delete", ProductFeatureViewSet.as_view({'delete': 'destroy'}), name="product-feature-delete"),

    # Product Descriptions
    path("api/ecommerce/product-descriptions/list", ProductDescriptionViewSet.as_view({'get': 'list'}), name="product-description-list"),
    path("api/ecommerce/product-descriptions/create", ProductDescriptionViewSet.as_view({'post': 'create'}), name="product-description-create"),
    path("api/ecommerce/product-descriptions/<int:pk>/get", ProductDescriptionViewSet.as_view({'get': 'retrieve'}), name="product-description-detail"),
    path("api/ecommerce/product-descriptions/<int:pk>/update", ProductDescriptionViewSet.as_view({'put': 'update', 'patch': 'partial_update'}), name="product-description-update"),
    path("api/ecommerce/product-descriptions/<int:pk>/delete", ProductDescriptionViewSet.as_view({'delete': 'destroy'}), name="product-description-delete"),

    # Product Images
    path("api/ecommerce/product-images/list", ProductImageViewSet.as_view({'get': 'list'}), name="product-image-list"),
    path("api/ecommerce/product-images/create", ProductImageViewSet.as_view({'post': 'create'}), name="product-image-create"),
    path("api/ecommerce/product-images/<int:pk>/get", ProductImageViewSet.as_view({'get': 'retrieve'}), name="product-image-detail"),
    path("api/ecommerce/product-images/<int:pk>/update", ProductImageViewSet.as_view({'put': 'update', 'patch': 'partial_update'}), name="product-image-update"),
    path("api/ecommerce/product-images/<int:pk>/delete", ProductImageViewSet.as_view({'delete': 'destroy'}), name="product-image-delete"),

    # ProductCategory
    path("api/ecommerce/product-category/list", ProductCategoryView.as_view({'get': 'list'}), name="product-category-list"),
    path("api/ecommerce/product-category/create", ProductCategoryView.as_view({'post': 'create'}), name="product-category-create"),
    path("api/ecommerce/product-category/<int:pk>/get", ProductCategoryView.as_view({'get': 'retrieve'}), name="product-category-detail"),
    path("api/ecommerce/product-category/<int:pk>/update", ProductCategoryView.as_view({'put': 'update', 'patch': 'partial_update'}), name="product-category-update"),
    path("api/ecommerce/product-category/<int:pk>/delete", ProductCategoryView.as_view({'delete': 'destroy'}), name="product-category-delete"),

]



if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)