from __future__ import annotations

from typing import Annotated

from fastapi import APIRouter, Depends

from v1.users.dependencies import get_user_service
from v1.users.schemas import UserResponse, UserSearchRequest, UserUpdateRequest
from v1.users.service import UserService


router = APIRouter(prefix="/users", tags=["users"])


@router.get("/me", response_model=UserResponse)
async def get_me(
    service: Annotated[UserService, Depends(get_user_service)],
) -> UserResponse:
    return await service.get_me()


@router.patch("/me", response_model=UserResponse)
async def update_me(
    payload: UserUpdateRequest,
    service: Annotated[UserService, Depends(get_user_service)],
) -> UserResponse:
    return await service.update_me(payload)


@router.post("/search", response_model=list[UserResponse])
async def search_users(
    payload: UserSearchRequest,
    service: Annotated[UserService, Depends(get_user_service)],
) -> list[UserResponse]:
    return await service.search_users(payload)
