From b680799b5fa575ec7cf0a9b581600c29ed66ddb1 Mon Sep 17 00:00:00 2001 From: Igor <114025058+igaryakqwe@users.noreply.github.com> Date: Thu, 4 Jan 2024 02:54:08 +0200 Subject: [PATCH] feature: added cathedra endpoint --- .../teachers-admin-search/TeachersAdminSearch.tsx | 10 +++++++++- src/lib/api/cathedras/CathedraAPI.ts | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/lib/api/cathedras/CathedraAPI.ts diff --git a/src/components/pages/admin/teachers-admin-page/components/teachers-admin-search/TeachersAdminSearch.tsx b/src/components/pages/admin/teachers-admin-page/components/teachers-admin-search/TeachersAdminSearch.tsx index c065d37f9..32eacdd61 100644 --- a/src/components/pages/admin/teachers-admin-page/components/teachers-admin-search/TeachersAdminSearch.tsx +++ b/src/components/pages/admin/teachers-admin-page/components/teachers-admin-search/TeachersAdminSearch.tsx @@ -16,6 +16,7 @@ import IconButton from '@/components/common/ui/icon-button-mui'; import { IconButtonSize } from '@/components/common/ui/icon-button-mui/types'; import { initialValues } from '@/components/pages/admin/teachers-admin-page/components/teachers-admin-search/constants'; import { AdminSearchFormFields } from '@/components/pages/admin/teachers-admin-page/components/teachers-admin-search/types'; +import CathedraAPI from '@/lib/api/cathedras/CathedraAPI'; import * as styles from './TeachersAdminSearch.styles'; @@ -37,7 +38,14 @@ const TeachersAdminSearch: FC = ({ onSubmit }) => { handleFormSubmit(values); }; - const { data: cathedras } = useQuery('cathedras'); + const { data: cathedras } = useQuery('cathedras', CathedraAPI.getAll, { + staleTime: Infinity, + onError: err => { + console.log(err); + }, + }); + + console.log(cathedras); return ( diff --git a/src/lib/api/cathedras/CathedraAPI.ts b/src/lib/api/cathedras/CathedraAPI.ts new file mode 100644 index 000000000..411b1f38d --- /dev/null +++ b/src/lib/api/cathedras/CathedraAPI.ts @@ -0,0 +1,11 @@ +import { client } from '@/lib/api/instance'; +import { getAuthorizationHeader } from '@/lib/api/utils'; + +class CathedraAPI { + async getAll() { + const { data } = await client.get('/cathedras', getAuthorizationHeader()); + return data; + } +} + +export default new CathedraAPI();