from fastapi import APIRouter
from api.v1.common.tenant_crud_routes import TenantCRUDRoutes
from .dto import (
    EquivalencyCreate, EquivalencyResponse, EquivalencyUpdate,
    EquivalencyItemCreate, EquivalencyItemResponse, EquivalencyItemUpdate
)
from .service import EquivalencyService, EquivalencyItemService

router = APIRouter(prefix="/equivalencies",
                   tags=["a76.general_catalogs.equivalencies"])

# Pool global de EquivalencyItems
item_crud = TenantCRUDRoutes(
    service=EquivalencyItemService,
    create_schema=EquivalencyItemCreate,
    update_schema=EquivalencyItemUpdate,
    response_schema=EquivalencyItemResponse,
    prefix="/items",
    tags=["Equivalency Items"],
    resource_name="EquivalencyItem",
    enable_list=True,
    enable_filters=True,
)

# Catálogo de equivalencias (referencia item_id)
equivalency_crud = TenantCRUDRoutes(
    service=EquivalencyService,
    create_schema=EquivalencyCreate,
    update_schema=EquivalencyUpdate,
    response_schema=EquivalencyResponse,
    prefix="",
    tags=["Equivalencies"],
    resource_name="Equivalency",
    enable_list=True,
    enable_filters=True,
)

router.include_router(item_crud.router)
router.include_router(equivalency_crud.router)
