@umituz/react-native-subscription 2.37.74 → 2.37.76
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.37.
|
|
3
|
+
"version": "2.37.76",
|
|
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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
2
|
-
import { StyleSheet, View, Pressable } from "react-native";
|
|
3
|
-
import { AtomicIcon } from "@umituz/react-native-design-system/atoms";
|
|
1
|
+
import React, { useMemo, useState, useCallback } from "react";
|
|
2
|
+
import { StyleSheet, View, Pressable, Alert } from "react-native";
|
|
3
|
+
import { AtomicIcon, AtomicText } from "@umituz/react-native-design-system/atoms";
|
|
4
4
|
import { NavigationHeader } from "@umituz/react-native-design-system/molecules";
|
|
5
5
|
import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
|
|
6
6
|
import { ScreenLayout } from "../../../../shared/presentation";
|
|
@@ -9,6 +9,8 @@ import { CreditsList } from "./components/CreditsList";
|
|
|
9
9
|
import { UpgradePrompt } from "./components/UpgradePrompt";
|
|
10
10
|
import { SubscriptionDetailScreenProps } from "./SubscriptionDetailScreen.types";
|
|
11
11
|
|
|
12
|
+
const IS_DEV = typeof __DEV__ !== "undefined" && __DEV__;
|
|
13
|
+
|
|
12
14
|
export const SubscriptionDetailScreen: React.FC<SubscriptionDetailScreenProps> = ({ config }) => {
|
|
13
15
|
const tokens = useAppDesignTokens();
|
|
14
16
|
const { showHeader, showCredits, showUpgradePrompt, showExpirationDate } = config.display;
|
|
@@ -81,7 +83,65 @@ export const SubscriptionDetailScreen: React.FC<SubscriptionDetailScreenProps> =
|
|
|
81
83
|
onUpgrade={config.upgradePrompt.onUpgrade ?? (() => {})}
|
|
82
84
|
/>
|
|
83
85
|
)}
|
|
86
|
+
{IS_DEV && <DevTestPanel statusType={config.statusType} />}
|
|
84
87
|
</View>
|
|
85
88
|
</ScreenLayout>
|
|
86
89
|
);
|
|
87
90
|
};
|
|
91
|
+
|
|
92
|
+
/* ─── DEV TEST PANEL ─── Only rendered in __DEV__ ─── */
|
|
93
|
+
|
|
94
|
+
const DevTestPanel: React.FC<{ statusType: string }> = ({ statusType }) => {
|
|
95
|
+
const [loading, setLoading] = useState<string | null>(null);
|
|
96
|
+
const isPremium = statusType === "active";
|
|
97
|
+
|
|
98
|
+
const run = useCallback(async (label: string, fn: () => Promise<void>) => {
|
|
99
|
+
if (loading) return;
|
|
100
|
+
setLoading(label);
|
|
101
|
+
try {
|
|
102
|
+
await fn();
|
|
103
|
+
Alert.alert("DEV", `${label} OK`);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
Alert.alert("DEV Error", e instanceof Error ? e.message : String(e));
|
|
106
|
+
} finally {
|
|
107
|
+
setLoading(null);
|
|
108
|
+
}
|
|
109
|
+
}, [loading]);
|
|
110
|
+
|
|
111
|
+
const handleCancel = useCallback(() => run("Cancel", async () => {
|
|
112
|
+
const { useAuthStore, selectUserId } = require("@umituz/react-native-auth");
|
|
113
|
+
const { handleExpiredSubscription } = require("../../application/statusChangeHandlers");
|
|
114
|
+
const userId = selectUserId(useAuthStore.getState());
|
|
115
|
+
if (!userId) throw new Error("No userId found");
|
|
116
|
+
await handleExpiredSubscription(userId);
|
|
117
|
+
}), [run]);
|
|
118
|
+
|
|
119
|
+
const handleRestore = useCallback(() => run("Restore", async () => {
|
|
120
|
+
const Purchases = require("react-native-purchases").default;
|
|
121
|
+
await Purchases.restorePurchases();
|
|
122
|
+
}), [run]);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<View style={{ marginTop: 16, padding: 16, borderRadius: 12, backgroundColor: "#1a1a2e", borderWidth: 1, borderColor: "#e94560" }}>
|
|
126
|
+
<AtomicText type="labelLarge" style={{ color: "#e94560", marginBottom: 12, textAlign: "center" }}>
|
|
127
|
+
DEV TEST PANEL
|
|
128
|
+
</AtomicText>
|
|
129
|
+
<View style={{ gap: 8 }}>
|
|
130
|
+
{isPremium && <DevButton label="Cancel" color="#e94560" loading={loading} onPress={handleCancel} />}
|
|
131
|
+
{!isPremium && <DevButton label="Restore" color="#0f3460" loading={loading} onPress={handleRestore} />}
|
|
132
|
+
</View>
|
|
133
|
+
</View>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const DevButton: React.FC<{ label: string; color: string; loading: string | null; onPress: () => void }> = ({ label, color, loading, onPress }) => (
|
|
138
|
+
<Pressable
|
|
139
|
+
onPress={onPress}
|
|
140
|
+
disabled={!!loading}
|
|
141
|
+
style={{ backgroundColor: loading === label ? "#555" : color, padding: 12, borderRadius: 8, alignItems: "center" }}
|
|
142
|
+
>
|
|
143
|
+
<AtomicText type="labelMedium" style={{ color: "#fff" }}>
|
|
144
|
+
{loading === label ? `${label}...` : label}
|
|
145
|
+
</AtomicText>
|
|
146
|
+
</Pressable>
|
|
147
|
+
);
|