35 lines
970 B
TypeScript
35 lines
970 B
TypeScript
import axios from '../utils/api';
|
|
import { GalleryImage } from '../types';
|
|
|
|
export const galleryService = {
|
|
createImage: async (articleId: string, imageData: {
|
|
url: string;
|
|
caption: string;
|
|
alt: string;
|
|
width: number;
|
|
height: number;
|
|
size: number;
|
|
format: string
|
|
}) => {
|
|
const { data } = await axios.post(`/gallery/article/${articleId}`, imageData);
|
|
return data;
|
|
},
|
|
|
|
updateImage: async (id: string, updates: Partial<GalleryImage>) => {
|
|
const { data } = await axios.put(`/gallery/${id}`, updates);
|
|
return data;
|
|
},
|
|
|
|
deleteImage: async (id: string) => {
|
|
await axios.delete(`/gallery/${id}`);
|
|
},
|
|
|
|
reorderImages: async (articleId: string, imageIds: string[]) => {
|
|
await axios.post(`/gallery/article/${articleId}/reorder`, { imageIds });
|
|
},
|
|
|
|
getArticleGallery: async (articleId: string) => {
|
|
const { data } = await axios.get(`/gallery/article/${articleId}`);
|
|
return data as GalleryImage[];
|
|
}
|
|
}; |