Skip to content

Commit aebd54a

Browse files
finished combine of event hook
1 parent 1e6e60f commit aebd54a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

client/src/hooks/events.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,18 @@ export const useEvents = (
4040
queryFn: () => api.get("/events/").then((res) => res.data),
4141
});
4242
};
43+
44+
// hook to fetch single event by id
45+
export const useEvent = (
46+
id: number,
47+
args?: Omit<UseQueryOptions<Event>, "queryKey" | "queryFn">,
48+
) => {
49+
return useQuery<Event>({
50+
queryKey: ["event", id],
51+
queryFn: () => {
52+
return api.get(`/events/${id}/`).then((res) => res.data);
53+
},
54+
enabled: !!id,
55+
...args,
56+
});
57+
};

0 commit comments

Comments
 (0)