use-post-is-notification-active.tsx 700 B

123456789101112131415161718192021
  1. import { friendsQueryKeys } from '../friends-query-keys';
  2. import { type PostGetFriendsNotificationReturn, friendsApi } from '../friends-api';
  3. import { queryClient } from 'src/utils/queryClient';
  4. export const fetchFriendsNotification = async (token: string) => {
  5. try {
  6. const data: PostGetFriendsNotificationReturn = await queryClient.fetchQuery({
  7. queryKey: friendsQueryKeys.getNotification(token),
  8. queryFn: async () => {
  9. const response = await friendsApi.getNotification(token);
  10. return response.data;
  11. },
  12. gcTime: 0,
  13. staleTime: 0
  14. });
  15. return data;
  16. } catch (error) {
  17. console.error('Failed to fetch friends notification:', error);
  18. }
  19. };