"""
Endpoints API para gestión de partes (SCAII)
"""

from fastapi import APIRouter

from api.v1.common.tenant_crud_routes import TenantCRUDRoutes

from .dto import PartCreateDTO, PartResponseDTO, PartUpdateDTO
from .service import PartService
from api.v1.modules.a76.layouts_csv.parts.routes import router as imports_router

router = APIRouter()

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

# CRUD
router.include_router(
    TenantCRUDRoutes(
        service=PartService,
        create_schema=PartCreateDTO,
        update_schema=PartUpdateDTO,
        response_schema=PartResponseDTO,
        prefix="/parts",
        tags=["a76 / parts"],
        resource_name="Part",
        id_name="part_id",
        enable_list=True,
        enable_filters=True,
        max_page_size=1000,
        list_permissions=["goods_parts.view"],
        get_permissions=["goods_parts.view"],
        create_permissions=["goods_parts.create"],
        update_permissions=["goods_parts.edit"],
        delete_permissions=["goods_parts.delete"],
    ).router
)