from fastapi.routing import APIRouter
from fastapi.requests import Request

from api_validations.validations_request import (
    InsertBuildDecisionBookProjectItems,
    UpdateBuildDecisionBookProjectItems,
    ListOptions,
)
from api_services.redis.auth_actions.token import parse_token_object_to_dict


build_decision_book_project_items_route = APIRouter(
    prefix="/build/decision_book/project/items",
    tags=["Decision Project Book Project Items"],
)
build_decision_book_project_items_route.include_router(
    build_decision_book_project_items_route, include_in_schema=True
)


@build_decision_book_project_items_route.post(
    path="/list",
    summary="List Active/Delete/Confirm Decision Project Book Project Items",
)
def build_decision_book_project_people_items_list(
    request: Request, list_options: ListOptions
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(list_options=list_options, token_dict=token_dict)


@build_decision_book_project_items_route.post(
    path="/create",
    summary="Create Build Decision Book Project People with given auth levels",
)
def build_decision_book_project_people_items_create(
    request: Request, data: InsertBuildDecisionBookProjectItems
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)


@build_decision_book_project_items_route.post(
    path="/update/{build_decision_book_project_item_uu_id}",
    summary="Add people to Decision Project Book Project Items with given auth levels",
)
def build_decision_book_project_people_items_update(
    request: Request,
    build_decision_book_project_item_uu_id: str,
    data: UpdateBuildDecisionBookProjectItems,
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(
        data=data,
        build_decision_book_project_item_uu_id=build_decision_book_project_item_uu_id,
        token_dict=token_dict,
    )


@build_decision_book_project_items_route.post(
    path="/patch/{build_decision_book_project_item_uu_id}",
    summary="Patch people from Decision Project Book Project Items with given auth levels",
)
def build_decision_book_project_people_items_patch(
    request: Request, build_decision_book_project_item_uu_id: str, data
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(
        data=data,
        build_decision_book_project_item_uu_id=build_decision_book_project_item_uu_id,
        token_dict=token_dict,
    )
