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

from api_validations.validations_request import (
    InsertBuildDecisionBookProjectPerson,
    UpdateBuildDecisionBookProjectPerson,
    ListOptions,
)
from api_services.redis.auth_actions.token import parse_token_object_to_dict


build_decision_book_project_people_route = APIRouter(
    prefix="/build/decision_book/project/people", tags=["Decision Book Project People"]
)
build_decision_book_project_people_route.include_router(
    build_decision_book_project_people_route, include_in_schema=True
)


@build_decision_book_project_people_route.post(
    path="/list", summary="List Active/Delete/Confirm Build Decision Book People"
)
def build_decision_book_project_people_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_people_route.post(
    path="/create",
    summary="Create Build Decision Book Project People with given auth levels",
)
def build_decision_book_project_people_create(
    request: Request, data: InsertBuildDecisionBookProjectPerson
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)


@build_decision_book_project_people_route.post(
    path="/update/{build_decision_book_project_person_uu_id}",
    summary="Add people to Build Decision People Book with given auth levels",
)
def build_decision_book_project_people_update(
    request: Request,
    build_decision_book_project_person_uu_id: str,
    data: UpdateBuildDecisionBookProjectPerson,
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(
        data=data,
        build_decision_book_project_person_uu_id=build_decision_book_project_person_uu_id,
        token_dict=token_dict,
    )


@build_decision_book_project_people_route.post(
    path="/patch/{build_decision_book_project_person_uu_id}",
    summary="Patch people from Build Decision Book Project People with given auth levels",
)
def build_decision_book_project_people_patch(
    request: Request,
    build_decision_book_project_person_uu_id: str,
    data: UpdateBuildDecisionBookProjectPerson,
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(
        data=data,
        build_decision_book_project_person_uu_id=build_decision_book_project_person_uu_id,
        token_dict=token_dict,
    )
