mirror of
https://gitlab.com/foxixus/neomovies.git
synced 2025-10-29 10:28:49 +05:00
Release 2.3.1
This commit is contained in:
@@ -12,5 +12,8 @@ export const authAPI = {
|
||||
},
|
||||
login(email: string, password: string) {
|
||||
return api.post('/auth/login', { email, password });
|
||||
},
|
||||
deleteAccount() {
|
||||
return api.delete('/auth/profile');
|
||||
}
|
||||
};
|
||||
|
||||
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 });
|
||||
},
|
||||
};
|
||||
@@ -53,3 +53,13 @@ export const formatDate = (dateString: string | Date | undefined | null) => {
|
||||
return 'Нет даты';
|
||||
}
|
||||
};
|
||||
|
||||
export function formatNumber(num: number): string {
|
||||
if (num >= 1000000) {
|
||||
return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
|
||||
}
|
||||
if (num >= 1000) {
|
||||
return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
|
||||
}
|
||||
return num.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user