from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView


urlpatterns = [
    path("admin/", admin.site.urls),
    path("schema/", SpectacularAPIView.as_view(), name="schema"),
    path(
        "docs/",
        SpectacularSwaggerView.as_view(url_name="schema"),
        name="swagger-ui",
    ),
    path("auth/token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
    path("auth/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
    path("catalogos/", include("apps.catalogos.urls")),
    path("usuarios/", include("apps.usuarios.urls")),
    path("boletas/", include("apps.boletas.urls")),
    path("recepciones/", include("apps.recepciones.urls")),
    path("muestreo-laboratorio/", include("apps.muestreo_laboratorio.urls")),
    path("expediente/", include("apps.expediente.urls")),
    path("traspasos/", include("apps.traspasos.urls")),
    path("movimientos/", include("apps.movimientos.urls")),
]

if settings.DEBUG:
    if getattr(settings, "SERVE_MEDIA_PUBLIC", False):
        urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
