import { http } from "./http"; import type { AuthUser, UserSearchItem } from "../chat/types"; export async function searchUsers(query: string, limit = 20): Promise { const { data } = await http.get("/users/search", { params: { query, limit } }); return data; } interface UserProfileUpdatePayload { name?: string; username?: string; bio?: string | null; avatar_url?: string | null; allow_private_messages?: boolean; } export async function updateMyProfile(payload: UserProfileUpdatePayload): Promise { const { data } = await http.put("/users/profile", payload); return data; } export async function getUserById(userId: number): Promise { const { data } = await http.get(`/users/${userId}`); return data; } export async function listBlockedUsers(): Promise { const { data } = await http.get("/users/blocked"); return data; } export async function blockUser(userId: number): Promise { await http.post(`/users/${userId}/block`); } export async function unblockUser(userId: number): Promise { await http.delete(`/users/${userId}/block`); } export async function listContacts(): Promise { const { data } = await http.get("/users/contacts"); return data; } export async function addContact(userId: number): Promise { await http.post(`/users/${userId}/contacts`); } export async function removeContact(userId: number): Promise { await http.delete(`/users/${userId}/contacts`); }