Переписаны модули, тесты, обработка ошибок
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { api } from './axios';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
export interface PublicProfile {
|
||||
id: string;
|
||||
fullName: string | null;
|
||||
avatarUrl: string | null;
|
||||
primaryRole: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение публичной информации о пользователе
|
||||
*/
|
||||
export const getPublicProfile = async (userId: string): Promise<PublicProfile> => {
|
||||
const response = await api.get<PublicProfile>(`/profile/public/${userId}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Хук для получения публичного профиля
|
||||
*/
|
||||
export const usePublicProfile = (userId: string | undefined) => {
|
||||
return useQuery({
|
||||
queryKey: ['publicProfile', userId],
|
||||
queryFn: () => getPublicProfile(userId!),
|
||||
enabled: !!userId,
|
||||
staleTime: 10 * 60 * 1000, // 10 минут
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user