All files / features/events/hooks useEvents.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20        1x         4x     2x 1x       4x    
import { useQuery } from '@tanstack/react-query'
import { api } from '@core/lib/api'
import type { EventResponseDto } from '@fundraising/types'
 
export const useEvents = () => {
    const {
        data: events,
        isLoading,
        error,
    } = useQuery({
        queryKey: ['events'],
        queryFn: async () => {
            const response = await api.get<EventResponseDto[]>('/events')
            return response.data
        },
    })
 
    return { events: events || [], isLoading, error }
}