Skip to content

Commit

Permalink
feat: add enabled state for the events query
Browse files Browse the repository at this point in the history
  • Loading branch information
HRemonen committed Oct 3, 2024
1 parent 1960ea7 commit aae556b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/client/hooks/useEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ interface UseEventsParams {
thesisId: string
}

const useEvents = (params: UseEventsParams) => {
const queryKey = ['event-log', params.thesisId]
const useEvents = ({ thesisId }: UseEventsParams) => {
const queryKey = ['event-log', thesisId]

const queryFn = async (): Promise<EventLog> => {
const { data } = await apiClient.get(`/event-log/${params.thesisId}`)
const { data } = await apiClient.get(`/event-log/${thesisId}`)

return data
}

const { data: events, ...rest } = useQuery({ queryKey, queryFn })
const { data: events, ...rest } = useQuery({
queryKey,
queryFn,
enabled: !!thesisId,
})

return { events, ...rest }
}
Expand Down

0 comments on commit aae556b

Please sign in to comment.