import { api } from "@/lib/api"; import type { WatchBuddy } from "@/types"; export const watchBuddyApi = { search: (q?: string) => api .get("/watch-buddies/search", { params: { q } }) .then((r) => r.data), getById: (id: number) => api.get(`/watch-buddies/${id}`).then((r) => r.data), getHistory: (id: number) => api.get(`/watch-buddies/${id}/history`).then((r) => r.data), create: (data: Partial) => api.post("/watch-buddies", data).then((r) => r.data), update: (id: number, data: Partial) => api.put(`/watch-buddies/${id}`, data).then((r) => r.data), remove: (id: number) => api.delete(`/watch-buddies/${id}`).then((r) => r.data), uploadProfilePicture: (id: number, file: File) => { const formData = new FormData(); formData.append("file", file); return api .post(`/watch-buddies/${id}/profile-picture`, formData, { headers: { "Content-Type": "multipart/form-data" }, }) .then((r) => r.data); }, };