mirror of
https://gitlab.com/foxixus/neomovies.git
synced 2025-12-15 20:06:11 +05:00
Release 2.3.1
This commit is contained in:
28
src/lib/reactionsApi.ts
Normal file
28
src/lib/reactionsApi.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { api } from './api';
|
||||
|
||||
export interface Reaction {
|
||||
_id: string;
|
||||
userId: string;
|
||||
mediaId: string;
|
||||
mediaType: 'movie' | 'tv';
|
||||
type: 'fire' | 'nice' | 'think' | 'bore' | 'shit';
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export const reactionsAPI = {
|
||||
// [PUBLIC] Получить счетчики для всех типов реакций
|
||||
getReactionCounts(mediaType: string, mediaId: string): Promise<{ data: Record<string, number> }> {
|
||||
return api.get(`/reactions/${mediaType}/${mediaId}/counts`);
|
||||
},
|
||||
|
||||
// [AUTH] Получить реакцию пользователя для медиа
|
||||
getMyReaction(mediaType: string, mediaId: string): Promise<{ data: Reaction | null }> {
|
||||
return api.get(`/reactions/${mediaType}/${mediaId}/my-reaction`);
|
||||
},
|
||||
|
||||
// [AUTH] Установить/обновить/удалить реакцию
|
||||
setReaction(mediaType: string, mediaId: string, type: Reaction['type']): Promise<{ data: Reaction }> {
|
||||
const fullMediaId = `${mediaType}_${mediaId}`;
|
||||
return api.post('/reactions', { mediaId: fullMediaId, type });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user