- Created WatchBuddy model - M:N junctions to EntrySeen/EpisodeSeen and Media relation for profile pictures - Full CRUD + search + profile picture upload - WatchBuddySelect multi-select with search and inline create, replaced all seen_with text inputs - WatchBuddiesPage (grid) and WatchBuddyProfilePage (edit form, icon-based contacts, poster-grid watch history, monthly timeline)
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { api } from "@/lib/api";
|
|
import type { WatchBuddy } from "@/types";
|
|
|
|
export const watchBuddyApi = {
|
|
search: (q?: string) =>
|
|
api
|
|
.get<WatchBuddy[]>("/watch-buddies/search", { params: { q } })
|
|
.then((r) => r.data),
|
|
|
|
getById: (id: number) =>
|
|
api.get<WatchBuddy>(`/watch-buddies/${id}`).then((r) => r.data),
|
|
|
|
getHistory: (id: number) =>
|
|
api.get<any>(`/watch-buddies/${id}/history`).then((r) => r.data),
|
|
|
|
create: (data: Partial<WatchBuddy>) =>
|
|
api.post<WatchBuddy>("/watch-buddies", data).then((r) => r.data),
|
|
|
|
update: (id: number, data: Partial<WatchBuddy>) =>
|
|
api.put<WatchBuddy>(`/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);
|
|
},
|
|
};
|