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

from api_validations.validations_request import (
    InsertBuildDecisionBookProjects,
    UpdateBuildDecisionBookProjects,
    ApprovalsBuildDecisionBookProjects,
    ListOptions,
)
from api_services.redis.auth_actions.token import parse_token_object_to_dict


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


@build_decision_book_project_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_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: InsertBuildDecisionBookProjects
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)


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


@build_decision_book_project_route.post(
    path="/approval",
    summary="Approval people from Build Decision Book Project People with given auth levels",
)
def build_decision_book_project_invite_approval(
    request: Request, data: ApprovalsBuildDecisionBookProjects
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)
