feat(frontend): add react spa with wishlist flows and public profile

This commit is contained in:
Anton
2026-04-23 16:05:27 +03:00
parent 5f6a551b6c
commit 00f01611ed
44 changed files with 2166 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import type {
CreateWishInput,
UpdateWishInput,
Wish,
WishStatus,
} from '@family-wishlist/shared';
import { api } from '@/lib/api';
export type WishWithOwnerBadge = Wish & { isNewForOwner?: boolean };
export type OwnerStatus = 'active' | 'archived' | 'completed' | 'deleted';
export const wishesApi = {
list: (status: OwnerStatus) =>
api.get<WishWithOwnerBadge[]>(`/api/wishes?status=${status}`),
get: (id: string) => api.get<Wish>(`/api/wishes/${id}`),
create: (input: CreateWishInput) => api.post<Wish, CreateWishInput>('/api/wishes', input),
update: (id: string, input: UpdateWishInput) =>
api.patch<Wish, UpdateWishInput>(`/api/wishes/${id}`, input),
remove: (id: string) => api.delete<Wish>(`/api/wishes/${id}`),
archive: (id: string) => api.post<Wish>(`/api/wishes/${id}/archive`),
complete: (id: string) => api.post<Wish>(`/api/wishes/${id}/complete`),
restore: (id: string) => api.post<Wish>(`/api/wishes/${id}/restore`),
duplicate: (id: string) => api.post<Wish>(`/api/wishes/${id}/duplicate`),
uploadImage: (id: string, file: File) => {
const fd = new FormData();
fd.append('file', file, file.name);
return api.upload<Wish>(`/api/wishes/${id}/image`, fd);
},
refreshOg: (id: string) => api.post<Wish>(`/api/wishes/${id}/image/refresh-og`),
deleteImage: (id: string) => api.delete<Wish>(`/api/wishes/${id}/image`),
};
export function statusToQuery(s: WishStatus): OwnerStatus {
return s.toLowerCase() as OwnerStatus;
}