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"])

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,
    list_permissions=["cat_equivalencies.view"],
    get_permissions=["cat_equivalencies.view"],
    create_permissions=["cat_equivalencies.create"],
    update_permissions=["cat_equivalencies.edit"],
    delete_permissions=["cat_equivalencies.delete"],
)

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,
    list_permissions=["cat_equivalencies.view"],
    get_permissions=["cat_equivalencies.view"],
    create_permissions=["cat_equivalencies.create"],
    update_permissions=["cat_equivalencies.edit"],
    delete_permissions=["cat_equivalencies.delete"],
)

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