Release 2.3.1

This commit is contained in:
2025-07-08 16:46:00 +03:00
parent bf3e231f67
commit eaf5e21ea1
11 changed files with 267 additions and 5 deletions

View File

@@ -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
View 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 });
},
};

View File

@@ -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();
}