30 lines
863 B
TypeScript
30 lines
863 B
TypeScript
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 минут
|
|
});
|
|
};
|