from django.contrib import admin
from django.urls import include, path
from django.views.decorators.csrf import csrf_exempt

from engine.core.graphene.schema import schema
from engine.core.views import (
    CustomGraphQLView,
    CustomRedocView,
    CustomSpectacularAPIView,
    CustomSwaggerView,
    favicon_view,
    index,
)
from evibes.i18n import set_language

urlpatterns = [
    ### COMMON URLS ###
    path(
        r"",
        index,
    ),
    path(
        r"health/",
        include(
            "health_check.urls",
        ),
    ),
    path(
        r"prometheus/",
        include(
            "django_prometheus.urls",
        ),
    ),
    path(
        "summernote/",
        include("django_summernote.urls"),
    ),
    path(
        r"i18n/setlang/",
        set_language,
        name="set_language",
    ),
    path(
        r"i18n/",
        include("django.conf.urls.i18n"),
    ),
    path(
        r"favicon.ico",
        favicon_view,
        name="favicon",
    ),
    path(
        r"graphql/",
        csrf_exempt(CustomGraphQLView.as_view(graphiql=True, schema=schema)),
        name="graphql-platform",
    ),
    ### DOCUMENTATION URLS ###
    path(
        r"docs/",
        CustomSpectacularAPIView.as_view(urlconf="evibes.urls"),
        name="schema-platform",
    ),
    path(
        r"docs/swagger/",
        CustomSwaggerView.as_view(url_name="schema-platform"),
        name="swagger-ui-platform",
    ),
    path(
        r"docs/redoc/",
        CustomRedocView.as_view(url_name="schema-platform"),
        name="redoc-ui-platform",
    ),
    ### ENGINE APPS URLS ###
    path(
        r"b2b/",
        include("engine.core.b2b_urls", namespace="core_b2b"),
    ),
    path(
        r"",
        include("engine.core.urls", namespace="core"),
    ),
    path(
        r"authv/",
        include("engine.vibes_auth.urls", namespace="vibes_auth"),
    ),
    path(
        r"payments/",
        include("engine.payments.urls", namespace="payments"),
    ),
    path(
        r"blog/",
        include("engine.blog.urls", namespace="blog"),
    ),
    ### ADMIN URLS ###
    path(
        "admin/doc/",
        include("django.contrib.admindocs.urls"),
    ),
    path(
        "admin/",
        admin.site.urls,
    ),
]
