@umituz/react-native-subscription 2.37.82 → 2.37.83
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 +1 -1
- package/src/domains/subscription/infrastructure/hooks/useRestorePurchase.ts +1 -3
- package/src/domains/subscription/presentation/useSubscriptionStatus.ts +0 -1
- package/src/domains/subscription/utils/authGuards.ts +0 -4
- package/src/domains/wallet/presentation/hooks/useTransactionHistory.ts +4 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.37.
|
|
3
|
+
"version": "2.37.83",
|
|
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",
|
|
@@ -3,7 +3,6 @@ import { useAlert } from "@umituz/react-native-design-system/molecules";
|
|
|
3
3
|
import {
|
|
4
4
|
useAuthStore,
|
|
5
5
|
selectUserId,
|
|
6
|
-
selectIsAnonymous,
|
|
7
6
|
} from "@umituz/react-native-auth";
|
|
8
7
|
import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
|
|
9
8
|
import { SUBSCRIPTION_QUERY_KEYS } from "./subscriptionQueryKeys";
|
|
@@ -18,13 +17,12 @@ interface RestoreResult {
|
|
|
18
17
|
|
|
19
18
|
export const useRestorePurchase = () => {
|
|
20
19
|
const userId = useAuthStore(selectUserId);
|
|
21
|
-
const isAnonymous = useAuthStore(selectIsAnonymous);
|
|
22
20
|
const queryClient = useQueryClient();
|
|
23
21
|
const { showSuccess, showInfo, showError } = useAlert();
|
|
24
22
|
|
|
25
23
|
return useMutation({
|
|
26
24
|
mutationFn: async (): Promise<RestoreResult> => {
|
|
27
|
-
if (!userId
|
|
25
|
+
if (!userId) {
|
|
28
26
|
throw new Error("User not authenticated");
|
|
29
27
|
}
|
|
30
28
|
|
|
@@ -19,7 +19,6 @@ export const useSubscriptionStatus = (): SubscriptionStatusResult => {
|
|
|
19
19
|
const userId = useAuthStore(selectUserId);
|
|
20
20
|
const queryClient = useQueryClient();
|
|
21
21
|
const isConfigured = SubscriptionManager.isConfigured();
|
|
22
|
-
// Anonymous users can also be premium — use isAuthenticated (not isRegisteredUser)
|
|
23
22
|
const hasUser = isAuthenticated(userId);
|
|
24
23
|
|
|
25
24
|
const initState = useSyncExternalStore(
|
|
@@ -3,7 +3,3 @@ import { isDefined } from "../../../shared/utils/validators";
|
|
|
3
3
|
export function isAuthenticated(userId: string | null | undefined): userId is string {
|
|
4
4
|
return isDefined(userId) && userId.length > 0;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
export function isRegisteredUser(userId: string | null | undefined, isAnonymous: boolean): userId is string {
|
|
8
|
-
return isAuthenticated(userId) && !isAnonymous;
|
|
9
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery } from "@umituz/react-native-design-system/tanstack";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { useAuthStore, selectUserId
|
|
3
|
+
import { useAuthStore, selectUserId } from "@umituz/react-native-auth";
|
|
4
4
|
import { NO_CACHE_QUERY_CONFIG } from "../../../../shared/infrastructure/react-query/queryConfig";
|
|
5
5
|
import type {
|
|
6
6
|
CreditLog,
|
|
@@ -31,19 +31,18 @@ export function useTransactionHistory({
|
|
|
31
31
|
limit = 50,
|
|
32
32
|
}: UseTransactionHistoryParams): UseTransactionHistoryResult {
|
|
33
33
|
const userId = useAuthStore(selectUserId);
|
|
34
|
-
const isAnonymous = useAuthStore(selectIsAnonymous);
|
|
35
34
|
|
|
36
35
|
const repository = useMemo(
|
|
37
36
|
() => new TransactionRepository(config),
|
|
38
37
|
[config]
|
|
39
38
|
);
|
|
40
39
|
|
|
41
|
-
const
|
|
40
|
+
const hasUser = !!userId;
|
|
42
41
|
|
|
43
42
|
const { data, isLoading, error, refetch } = useQuery({
|
|
44
43
|
queryKey: [...transactionQueryKeys.user(userId ?? ""), limit],
|
|
45
44
|
queryFn: async () => {
|
|
46
|
-
if (!userId
|
|
45
|
+
if (!userId) return [];
|
|
47
46
|
|
|
48
47
|
const result = await repository.getTransactions({
|
|
49
48
|
userId,
|
|
@@ -56,7 +55,7 @@ export function useTransactionHistory({
|
|
|
56
55
|
|
|
57
56
|
return result.data ?? [];
|
|
58
57
|
},
|
|
59
|
-
enabled:
|
|
58
|
+
enabled: hasUser,
|
|
60
59
|
...NO_CACHE_QUERY_CONFIG,
|
|
61
60
|
});
|
|
62
61
|
|