@umituz/react-native-subscription 2.1.3 → 2.2.1
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.1
|
|
3
|
+
"version": "2.2.1",
|
|
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",
|
|
@@ -58,4 +58,4 @@
|
|
|
58
58
|
"README.md",
|
|
59
59
|
"LICENSE"
|
|
60
60
|
]
|
|
61
|
-
}
|
|
61
|
+
}
|
|
@@ -18,6 +18,8 @@ export interface CreditsConfig {
|
|
|
18
18
|
collectionName: string;
|
|
19
19
|
textCreditLimit: number;
|
|
20
20
|
imageCreditLimit: number;
|
|
21
|
+
/** When true, stores credits at users/{userId}/credits instead of {collectionName}/{userId} */
|
|
22
|
+
useUserSubcollection?: boolean;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export interface CreditsResult<T = UserCredits> {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
runTransaction,
|
|
14
14
|
serverTimestamp,
|
|
15
15
|
type FieldValue,
|
|
16
|
+
type Firestore,
|
|
16
17
|
} from "firebase/firestore";
|
|
17
18
|
import { BaseRepository, getFirestore } from "@umituz/react-native-firestore";
|
|
18
19
|
import type {
|
|
@@ -44,6 +45,13 @@ export class CreditsRepository extends BaseRepository {
|
|
|
44
45
|
this.config = config;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
private getCreditsDocRef(db: Firestore, userId: string) {
|
|
49
|
+
if (this.config.useUserSubcollection) {
|
|
50
|
+
return doc(db, "users", userId, "credits", "data");
|
|
51
|
+
}
|
|
52
|
+
return doc(db, this.config.collectionName, userId);
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
async getCredits(userId: string): Promise<CreditsResult> {
|
|
48
56
|
const db = this.getDb();
|
|
49
57
|
if (!db) {
|
|
@@ -54,7 +62,7 @@ export class CreditsRepository extends BaseRepository {
|
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
try {
|
|
57
|
-
const creditsRef =
|
|
65
|
+
const creditsRef = this.getCreditsDocRef(db, userId);
|
|
58
66
|
const snapshot = await getDoc(creditsRef);
|
|
59
67
|
|
|
60
68
|
if (!snapshot.exists()) {
|
|
@@ -96,7 +104,7 @@ export class CreditsRepository extends BaseRepository {
|
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
try {
|
|
99
|
-
const creditsRef =
|
|
107
|
+
const creditsRef = this.getCreditsDocRef(db, userId);
|
|
100
108
|
|
|
101
109
|
const result = await runTransaction(db, async (transaction) => {
|
|
102
110
|
const creditsDoc = await transaction.get(creditsRef);
|
|
@@ -181,7 +189,7 @@ export class CreditsRepository extends BaseRepository {
|
|
|
181
189
|
}
|
|
182
190
|
|
|
183
191
|
try {
|
|
184
|
-
const creditsRef =
|
|
192
|
+
const creditsRef = this.getCreditsDocRef(db, userId);
|
|
185
193
|
const fieldName = creditType === "text" ? "textCredits" : "imageCredits";
|
|
186
194
|
|
|
187
195
|
const newCredits = await runTransaction(db, async (transaction) => {
|
|
@@ -17,16 +17,11 @@ export const PaywallFeatureItem: React.FC<PaywallFeatureItemProps> = React.memo(
|
|
|
17
17
|
({ icon, text }) => {
|
|
18
18
|
const tokens = useAppDesignTokens();
|
|
19
19
|
|
|
20
|
-
//
|
|
21
|
-
//
|
|
20
|
+
// Pass icon name directly to AtomicIcon (which uses Ionicons)
|
|
21
|
+
// Do NOT capitalize, as Ionicons names are lowercase/kebab-case.
|
|
22
22
|
const iconName = useMemo(() => {
|
|
23
|
-
if (!icon) return "
|
|
24
|
-
|
|
25
|
-
if (/^[A-Z]/.test(icon)) {
|
|
26
|
-
return icon;
|
|
27
|
-
}
|
|
28
|
-
// Convert first letter to uppercase
|
|
29
|
-
return icon.charAt(0).toUpperCase() + icon.slice(1);
|
|
23
|
+
if (!icon) return "help-circle-outline";
|
|
24
|
+
return icon;
|
|
30
25
|
}, [icon]);
|
|
31
26
|
|
|
32
27
|
return (
|