Implemented the new react version of the frontend

This commit is contained in:
Mohammed Abad committed 2026-03-31 01:56:38 +01:00
1 parent 236e6e06fb
commit ffe7e52527
65 files changed
+5228 -177

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
import { api } from '@/lib/api';
import { normalizeCollection } from '@/lib/normalizers';
import type { Collection } from '@/types';
export const collectionsApi = {
getAll: () =>
api
.get<Collection[]>('/collections')
.then((r) => r.data.map(normalizeCollection)),
getById: (id: number) =>
api
.get<Collection>(`/collections/${id}`)
.then((r) => normalizeCollection(r.data)),
create: (data: Partial<Collection>) =>
api.post<Collection>('/collections', data).then((r) => r.data),
update: (id: number, data: Partial<Collection>) =>
api.put<Collection>(`/collections/${id}`, data).then((r) => normalizeCollection(r.data)),
updateWithMedia: (id: number, formData: FormData) =>
api
.put<Collection>(`/collections/${id}`, formData, {
headers: { 'Content-Type': 'multipart/form-data' },
})
.then((r) => normalizeCollection(r.data)),
delete: (id: number) =>
api.delete(`/collections/${id}`).then((r) => r.data),
addEntry: (collectionId: number, entryId: number) =>
api
.post(`/collections/${collectionId}/entries`, { entry_id: entryId })
.then((r) => r.data),
removeEntry: (collectionId: number, entryId: number) =>
api
.delete(`/collections/${collectionId}/entries/${entryId}`)
.then((r) => r.data),
};