from fastapi import APIRouter

from api.v1.common.tenant_crud_routes import TenantCRUDRoutes

from .dto import TrailerCreateDTO, TrailerResponseDTO, TrailerUpdateDTO
from .services import TrailerService
from api.v1.modules.a76.layouts_csv.trailers.routes import router as imports_router

# Main router: trailers CRUD + CSV imports
router = APIRouter()

# CSV import (upload → scan → status → commit)
router.include_router(imports_router, prefix="/trailers/imports", tags=["a76 / trailers / csv_import"])

# CRUD routes
crud_router = TenantCRUDRoutes(
    service=TrailerService,
    create_schema=TrailerCreateDTO,
    update_schema=TrailerUpdateDTO,
    response_schema=TrailerResponseDTO,
    prefix="/trailers",
    tags=[],
    resource_name="Trailer",
    id_name="trailer_number",
    id_type=str,
    enable_list=True,
    enable_filters=True,
    default_page_size=50,
    max_page_size=100,
    list_permissions=["trailers.view"],
    get_permissions=["trailers.view"],
    create_permissions=["trailers.create"],
    update_permissions=["trailers.edit"],
    delete_permissions=["trailers.delete"],
).router
router.include_router(crud_router)
