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

from api_validations.validations_request import (
    InsertEmployees,
    UnBindEmployees2People,
    BindEmployees2People,
    PatchRecord,
    ListOptions,
)

from api_services.redis.auth_actions.token import parse_token_object_to_dict


employee_route = APIRouter(prefix="/employee", tags=["Employee"])
employee_route.include_router(employee_route, include_in_schema=True)


@employee_route.post(path="/list", summary="List Active/Delete/Confirm Staff")
def company_employee_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)


@employee_route.post(path="/create", summary="Create Employee with given auth levels")
def company_employee_create(request: Request, data: InsertEmployees):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)


@employee_route.post(
    path="/update/{employee_uu_id}", summary="Update Employee with given auth levels"
)
def company_employee_update(request: Request, employee_uu_id: str, data: PatchRecord):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(
        data=data, employee_uu_id=employee_uu_id, token_dict=token_dict
    )


@employee_route.patch(
    path="/patch/{employee_uu_id}", summary="Update Active/Delete/Confirm"
)
def company_employee_patch(request: Request, employee_uu_id: str, data: PatchRecord):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(
        data=data, employee_uu_id=employee_uu_id, token_dict=token_dict
    )


@employee_route.post(path="/employ", summary="Employ Employee with given auth levels")
def company_employee_employ(request: Request, data: BindEmployees2People):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)


@employee_route.post(path="/fire", summary="UnEmploy Employee with given auth levels")
def company_employee_fire(request: Request, data: UnBindEmployees2People):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)
