import uuid
from typing import Any

from fastapi import Depends

from app.api.controllers.workspace_member_controller import WorkspaceMemberController
from app.api.models.query import PaginationQuery, QueryResult
from app.api.models.workspace_member import (
    WorkspaceMemberInvite,
    WorkspaceMemberInvitePublic,
    WorkspaceMemberPublic,
    WorkspaceMemberPublicDetails,
)
from app.api.router import ApiRouter

router = ApiRouter(prefix="/workspace/member", tags=["WorkspaceMember"])


@router.api_get("/invite", response_model=WorkspaceMemberInvitePublic)
async def get_invite(controller: WorkspaceMemberController = Depends()) -> Any:
    return controller.get_invite()


@router.api_post("/invite", response_model=WorkspaceMemberPublic)
async def invite(item_in: WorkspaceMemberInvite, controller: WorkspaceMemberController = Depends()) -> Any:
    return controller.invite(item_in)


@router.api_post("/accept", response_model=WorkspaceMemberPublic)
async def accept(id: uuid.UUID, controller: WorkspaceMemberController = Depends()) -> Any:
    return controller.accept(id)


@router.api_post("/role", response_model=WorkspaceMemberPublic)
async def assign_role(id: uuid.UUID, role: str, controller: WorkspaceMemberController = Depends()) -> Any:
    return controller.assign_role(id, role)


@router.api_post("/enable", response_model=WorkspaceMemberPublic)
async def enable(id: uuid.UUID, controller: WorkspaceMemberController = Depends()) -> Any:
    return await controller.enable(id)


@router.api_post("/disable", response_model=WorkspaceMemberPublic)
async def disable(id: uuid.UUID, controller: WorkspaceMemberController = Depends()) -> Any:
    return await controller.disable(id)


@router.api_get("/details", response_model=WorkspaceMemberPublicDetails)
async def get_details(id: uuid.UUID, controller: WorkspaceMemberController = Depends()) -> Any:
    return controller.get_details(id)


@router.api_post("/query/details", response_model=QueryResult[WorkspaceMemberPublicDetails])
async def query_details(query: PaginationQuery, controller: WorkspaceMemberController = Depends()) -> Any:
    return controller.query_details(query)
