"""
URL configuration for caracole_ph_api project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path, include, re_path
from django.conf import settings
from django.conf.urls.static import static
from rest_framework.routers import DefaultRouter

# PUBLIC APIs
from products.views_public import ProductsExternalViewset

router = DefaultRouter()
router.register(
    r"api/public/products", ProductsExternalViewset, basename="public/products"
)

# ---------------------------------

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/users/", include("users.urls"), name="users"),
    path("api/inquiry/", include("inquiry.urls"), name="inquiry"),
    path("api/products/", include("products.urls"), name="products"),
    path("api/appointment/", include("appointment.urls"), name="appointment"),
    path("api/blogs/", include("blogs.urls"), name="blogs"),
    path("api/projects/", include("projects.urls"), name="projects"),
    path("api/hero-banners/", include("hero_banners.urls"), name="hero_banners"),
    path("api/contact-us/", include("contact_us.urls"), name="contact_us"),
    path("api/newsletter/", include("newsletter.urls"), name="newsletter"),
    path("api/integration/", include("integration.urls"), name="integration"),
    path("api/reports/", include("reports.urls"), name="reports"),
    path("api/activity-logs/", include("activity_logs.urls"), name="activity_logs"),
    path("", include(router.urls)),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(
    settings.STATIC_URL, document_root=settings.STATIC_ROOT
)

if settings.DEBUG:
    from django.views import defaults as default_views
    import debug_toolbar
    from drf_spectacular.views import (
        SpectacularAPIView,
        SpectacularRedocView,
        SpectacularSwaggerView,
    )

    # This allows the error pages to be debugged during development, just visit
    # these url in browser to see how these error pages look like.
    urlpatterns += [
        path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
        path(
            "api/schema/swagger-ui/",
            SpectacularSwaggerView.as_view(),
            name="swagger-ui",
        ),
        path("api/schema/redoc/", SpectacularRedocView.as_view(), name="redoc"),
        path("__debug__/", include(debug_toolbar.urls)),
        path(
            "400/",
            default_views.bad_request,
            kwargs={"exception": Exception("Bad Request!")},
        ),
        path(
            "403/",
            default_views.permission_denied,
            kwargs={"exception": Exception("Permission Denied")},
        ),
        path(
            "404/",
            default_views.page_not_found,
            kwargs={"exception": Exception("Page not Found")},
        ),
        path("500/", default_views.server_error),
    ]
