from fastapi import APIRouter

from api.v1.common.tenant_crud_routes import TenantCRUDRoutes

from .dto import VehicleCreateDTO, VehicleResponseDTO, VehicleUpdateDTO
from .services import VehicleService
from api.v1.modules.a76.layouts_csv.vehicles.routes import router as imports_router

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

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

# CRUD routes
crud_router = TenantCRUDRoutes(
    service=VehicleService,
    create_schema=VehicleCreateDTO,
    update_schema=VehicleUpdateDTO,
    response_schema=VehicleResponseDTO,
    prefix="/vehicles",
    tags=[],
    resource_name="Vehicle",
    id_name="vehicle_key",
    id_type=str,
    enable_list=True,
    enable_filters=True,
    default_page_size=50,
    max_page_size=100,
    list_permissions=["vehicles.view"],
    get_permissions=["vehicles.view"],
    create_permissions=["vehicles.create"],
    update_permissions=["vehicles.edit"],
    delete_permissions=["vehicles.delete"],
).router
router.include_router(crud_router)
