@turtleclub/hooks 0.5.0-beta.93 → 0.5.0-beta.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turtleclub/hooks",
3
3
  "type": "module",
4
- "version": "0.5.0-beta.93",
4
+ "version": "0.5.0-beta.94",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "a604839c3af96eb5977f2ac41515e7a0e7c32bee"
57
+ "gitHead": "f7b206b904156b60fad200f803741d81d00cf71b"
58
58
  }
@@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query";
2
2
  import type { UseQueryResult } from "@tanstack/react-query";
3
3
  import { geocheckQueries } from "./queries";
4
4
  import { queryDefaults } from "../lib/query-config";
5
+ import { apiClient } from "../lib/api-client";
5
6
  import type { GeoCheckResponse } from "./schema";
6
7
 
7
8
  export interface UseGeocheckOptions {
@@ -21,15 +22,15 @@ export interface UseGeocheckOptions {
21
22
  * if (!geocheck?.canInteract) return <div>Service not available in your region</div>;
22
23
  * ```
23
24
  */
24
- export function useGeocheck(
25
- options: UseGeocheckOptions = {}
26
- ): UseQueryResult<GeoCheckResponse> {
25
+ export function useGeocheck(options: UseGeocheckOptions = {}): UseQueryResult<GeoCheckResponse> {
27
26
  const { enabled = true, staleTime, gcTime } = options;
27
+ const { disableGeocheck } = apiClient.getConfig();
28
28
 
29
29
  return useQuery({
30
30
  ...geocheckQueries.check,
31
31
  ...queryDefaults,
32
- enabled,
32
+ enabled: enabled && !disableGeocheck,
33
+ ...(disableGeocheck && { initialData: { canInteract: true } }),
33
34
  staleTime: staleTime ?? 5 * 60 * 1000, // 5 minutes
34
35
  gcTime: gcTime ?? 10 * 60 * 1000, // 10 minutes
35
36
  });
@@ -9,6 +9,7 @@ export interface ApiClientConfig {
9
9
  getToken?: () => string | null;
10
10
  earnApiKey?: string;
11
11
  debug?: boolean;
12
+ disableGeocheck?: boolean;
12
13
  }
13
14
 
14
15
  export interface ApiClientOptions extends Omit<RequestInit, "body"> {
@@ -36,8 +36,9 @@ export function TurtleHooksProvider({
36
36
  getToken,
37
37
  earnApiKey,
38
38
  debug,
39
+ disableGeocheck,
39
40
  }: TurtleHooksProviderProps) {
40
- apiClient.configure({ apiUrl, earnUrl, getToken, earnApiKey, debug });
41
+ apiClient.configure({ apiUrl, earnUrl, getToken, earnApiKey, debug, disableGeocheck });
41
42
 
42
43
  return <>{children}</>;
43
44
  }