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

from api_validations.validations_request import (
    InsertDecisionBook,
    UpdateDecisionBook,
    DecisionBookDecisionBookInvitationsAttend,
    ListOptions,
)
from api_services.redis.auth_actions.token import parse_token_object_to_dict


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


@build_decision_book_people_route.post(
    path="/list", summary="List Active/Delete/Confirm Build Decision Book People"
)
def build_decision_book_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_people_route.post(
    path="/add",
    summary="Add people to Build Decision People Book with given auth levels",
)
def build_decision_book_people_add(request: Request, data: InsertDecisionBook):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)


@build_decision_book_people_route.post(
    path="/remove",
    summary="Remove people from Build Decision Book People with given auth levels",
)
def build_decision_book_people_remove(request: Request, data: UpdateDecisionBook):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)


@build_decision_book_people_route.post(
    path="/attend",
    summary="Attend to Build Decision Book Invitations with given auth levels",
)
def build_decision_book_invite_attend(
    request: Request, data: DecisionBookDecisionBookInvitationsAttend
):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)
