From e6b41c287e4b145e96a9fa281634aed63c26832b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=20Keskim=C3=A4ki?= Date: Fri, 24 Feb 2023 12:53:51 +0200 Subject: [PATCH] Add missing file --- src/client/hooks/useUserFaculties.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/client/hooks/useUserFaculties.ts diff --git a/src/client/hooks/useUserFaculties.ts b/src/client/hooks/useUserFaculties.ts new file mode 100644 index 00000000..2807d9a5 --- /dev/null +++ b/src/client/hooks/useUserFaculties.ts @@ -0,0 +1,20 @@ +import { useQuery } from 'react-query' + +import apiClient from '../util/apiClient' +import { Faculty } from '../types' + +const useUserFaculties = () => { + const queryKey = 'userFaculties' + + const query = async (): Promise => { + const { data } = await apiClient.get('/faculties/user') + + return data + } + + const { data: userFaculties, ...rest } = useQuery(queryKey, query) + + return { userFaculties, ...rest } +} + +export default useUserFaculties