source: src/api/service.ts@ 057453c

main
Last change on this file since 057453c was 057453c, checked in by Naum Shapkarovski <naumshapkarovski@…>, 5 weeks ago

feat: implement employees

  • Property mode set to 100644
File size: 705 bytes
Line 
1import { useMemo } from 'react';
2// types
3import { Service } from 'src/schemas';
4// swr
5import useSWR from 'swr';
6import { endpoints, fetcher } from 'src/utils/axios';
7
8export function useGetServices() {
9 const { data, isLoading, error, isValidating } = useSWR<Service[]>(
10 endpoints.service,
11 () => fetcher<Service[]>(endpoints.service),
12 {
13 revalidateOnFocus: false,
14 }
15 );
16
17 const memoizedValue = useMemo(
18 () => ({
19 services: data || [],
20 servicesLoading: isLoading,
21 servicesError: error,
22 servicesValidating: isValidating,
23 servicesEmpty: !isLoading && !data?.length,
24 }),
25 [data, error, isLoading, isValidating]
26 );
27
28 return memoizedValue;
29}
Note: See TracBrowser for help on using the repository browser.