diff --git a/barkmanui/src/features/jobs/hooks/useJobList.tsx b/barkmanui/src/features/jobs/hooks/useJobList.tsx new file mode 100644 index 0000000..10bb331 --- /dev/null +++ b/barkmanui/src/features/jobs/hooks/useJobList.tsx @@ -0,0 +1,17 @@ +import {useQuery} from "@tanstack/react-query"; +import {Job} from "../types.ts"; + + const useJobList = () => useQuery({ + queryKey: ['job'], + queryFn: async (): Promise => { + const response = await fetch( + import.meta.env.VITE_API_URL + '/jobs', + ) + + if (!response.ok) throw new Error('Failed to fetch jobs ' + response.statusText) + + return await response.json() + }, + }); + +export default useJobList; \ No newline at end of file