@umituz/react-native-subscription 2.14.32 → 2.14.34
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.34",
|
|
4
4
|
"description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -274,6 +274,7 @@ export {
|
|
|
274
274
|
getCreditsRepository,
|
|
275
275
|
getCreditsConfig,
|
|
276
276
|
resetCreditsRepository,
|
|
277
|
+
isCreditsRepositoryConfigured,
|
|
277
278
|
} from "./infrastructure/repositories/CreditsRepositoryProvider";
|
|
278
279
|
|
|
279
280
|
// =============================================================================
|
|
@@ -24,6 +24,13 @@ export function configureCreditsRepository(config: Partial<CreditsConfig>): void
|
|
|
24
24
|
globalRepository = createCreditsRepository(globalConfig);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Check if credits repository is configured
|
|
29
|
+
*/
|
|
30
|
+
export function isCreditsRepositoryConfigured(): boolean {
|
|
31
|
+
return globalRepository !== null;
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
/**
|
|
28
35
|
* Get the configured credits repository
|
|
29
36
|
* Throws if repository not configured
|
|
@@ -12,6 +12,7 @@ declare const __DEV__: boolean;
|
|
|
12
12
|
import {
|
|
13
13
|
getCreditsRepository,
|
|
14
14
|
getCreditsConfig,
|
|
15
|
+
isCreditsRepositoryConfigured,
|
|
15
16
|
} from "../../infrastructure/repositories/CreditsRepositoryProvider";
|
|
16
17
|
|
|
17
18
|
const CACHE_CONFIG = {
|
|
@@ -46,20 +47,21 @@ export const useCredits = ({
|
|
|
46
47
|
userId,
|
|
47
48
|
enabled = true,
|
|
48
49
|
}: UseCreditsParams): UseCreditsResult => {
|
|
49
|
-
const
|
|
50
|
+
const isConfigured = isCreditsRepositoryConfigured();
|
|
50
51
|
const config = getCreditsConfig();
|
|
51
52
|
|
|
52
53
|
const { data, isLoading, error, refetch } = useQuery({
|
|
53
54
|
queryKey: creditsQueryKeys.user(userId ?? ""),
|
|
54
55
|
queryFn: async () => {
|
|
55
|
-
if (!userId) return null;
|
|
56
|
+
if (!userId || !isConfigured) return null;
|
|
57
|
+
const repository = getCreditsRepository();
|
|
56
58
|
const result = await repository.getCredits(userId);
|
|
57
59
|
if (!result.success) {
|
|
58
60
|
throw new Error(result.error?.message || "Failed to fetch credits");
|
|
59
61
|
}
|
|
60
62
|
return result.data || null;
|
|
61
63
|
},
|
|
62
|
-
enabled: enabled && !!userId,
|
|
64
|
+
enabled: enabled && !!userId && isConfigured,
|
|
63
65
|
staleTime: CACHE_CONFIG.staleTime,
|
|
64
66
|
gcTime: CACHE_CONFIG.gcTime,
|
|
65
67
|
});
|