from django.urls import path, include
from rest_framework.routers import DefaultRouter
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from rest_framework.permissions import AllowAny
from .views import (
    ProductViewSet, EmployeeViewSet, PositionViewSet,
    StorageLocationViewSet, ContractorViewSet, SupplyContractViewSet, TruckViewSet
)
from .views import conduct_inventory

# Create the router for inventory-related views
router_inventory = DefaultRouter()
router_inventory.register(r'products', ProductViewSet)
router_inventory.register(r'employees', EmployeeViewSet)
router_inventory.register(r'positions', PositionViewSet)
router_inventory.register(r'storage-locations', StorageLocationViewSet)
router_inventory.register(r'contractors', ContractorViewSet)
router_inventory.register(r'supply-contracts', SupplyContractViewSet)
router_inventory.register(r'trucks', TruckViewSet)

# Swagger schema view for inventory
schema_view_inventory = get_schema_view(
    openapi.Info(
        title="Store Management API - Inventory",
        default_version='v1',
        description="API for managing inventory in the franchise store",
        terms_of_service="https://www.example.com/terms/",
        contact=openapi.Contact(email="support@example.com"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=(AllowAny,),
)

urlpatterns = [
    path('', include(router_inventory.urls)),
    path('swagger/', schema_view_inventory.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui-inventory'),
    path('redoc/', schema_view_inventory.with_ui('redoc', cache_timeout=0), name='schema-redoc-inventory'),
    path('inventory/<int:warehouse_id>/', conduct_inventory, name='conduct_inventory'),
]
