()
| 6 | import { CHECK_LOCATION_QUERY } from '../graphql/users'; |
| 7 | |
| 8 | export const useCheckLocation = (): void => { |
| 9 | const { user, isFetched, updateUser } = useAuthContext(); |
| 10 | const { requestMethod } = useRequestProtocol(); |
| 11 | |
| 12 | useQuery({ |
| 13 | queryKey: generateQueryKey(RequestKey.CheckLocation, user), |
| 14 | queryFn: async () => { |
| 15 | const result = await requestMethod<{ |
| 16 | location: Pick<LoggedUser, 'hasLocationSet'>; |
| 17 | }>(CHECK_LOCATION_QUERY); |
| 18 | await updateUser({ |
| 19 | ...user!, |
| 20 | hasLocationSet: !!result, |
| 21 | }); |
| 22 | }, |
| 23 | staleTime: Infinity, |
| 24 | gcTime: Infinity, |
| 25 | enabled: !!user && isFetched && !user.hasLocationSet, |
| 26 | }); |
| 27 | }; |
no test coverage detected