@umituz/react-native-subscription 2.14.92 → 2.14.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 +2 -3
- package/src/domains/wallet/presentation/components/TransactionItem.tsx +7 -7
- package/src/presentation/hooks/useSubscriptionDetails.ts +5 -6
- package/src/presentation/hooks/useSubscriptionSettingsConfig.ts +5 -6
- package/src/presentation/types/SubscriptionSettingsTypes.ts +0 -2
- package/src/presentation/utils/subscriptionDateUtils.ts +7 -10
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.94",
|
|
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",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"@umituz/react-native-design-system": "latest",
|
|
36
36
|
"@umituz/react-native-firebase": "latest",
|
|
37
37
|
"@umituz/react-native-localization": "latest",
|
|
38
|
-
"@umituz/react-native-storage": "latest"
|
|
39
|
-
"@umituz/react-native-timezone": "^1.3.5"
|
|
38
|
+
"@umituz/react-native-storage": "latest"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {
|
|
42
41
|
"@tanstack/react-query": ">=5.0.0",
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
AtomicText,
|
|
13
13
|
AtomicIcon,
|
|
14
14
|
} from "@umituz/react-native-design-system";
|
|
15
|
-
import { timezoneService } from "@umituz/react-native-timezone";
|
|
16
15
|
import type { CreditLog, TransactionReason } from "../../domain/types/transaction.types";
|
|
17
16
|
|
|
18
17
|
export interface TransactionItemTranslations {
|
|
@@ -48,12 +47,13 @@ const getReasonIcon = (reason: TransactionReason): string => {
|
|
|
48
47
|
|
|
49
48
|
const defaultDateFormatter = (timestamp: number): string => {
|
|
50
49
|
const date = new Date(timestamp);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
51
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
52
|
+
const y = date.getFullYear();
|
|
53
|
+
const th = String(date.getHours()).padStart(2, '0');
|
|
54
|
+
const tm = String(date.getMinutes()).padStart(2, '0');
|
|
55
|
+
|
|
56
|
+
return `${d}.${m}.${y} ${th}:${tm}`;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
export const TransactionItem: React.FC<TransactionItemProps> = ({
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
isSubscriptionValid,
|
|
7
7
|
calculateDaysRemaining
|
|
8
8
|
} from "../../domain/entities/SubscriptionStatus";
|
|
9
|
-
import {
|
|
9
|
+
import { formatDate } from "../utils/subscriptionDateUtils";
|
|
10
10
|
|
|
11
11
|
export interface SubscriptionDetails {
|
|
12
12
|
/** Raw subscription status */
|
|
@@ -29,7 +29,6 @@ export interface SubscriptionDetails {
|
|
|
29
29
|
|
|
30
30
|
interface UseSubscriptionDetailsParams {
|
|
31
31
|
status: SubscriptionStatus | null;
|
|
32
|
-
locale?: string;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
/**
|
|
@@ -38,7 +37,7 @@ interface UseSubscriptionDetailsParams {
|
|
|
38
37
|
export function useSubscriptionDetails(
|
|
39
38
|
params: UseSubscriptionDetailsParams,
|
|
40
39
|
): SubscriptionDetails {
|
|
41
|
-
const { status
|
|
40
|
+
const { status } = params;
|
|
42
41
|
|
|
43
42
|
return useMemo(() => {
|
|
44
43
|
if (!status) {
|
|
@@ -77,10 +76,10 @@ export function useSubscriptionDetails(
|
|
|
77
76
|
isExpired,
|
|
78
77
|
isLifetime,
|
|
79
78
|
daysRemaining: daysRemainingValue,
|
|
80
|
-
formattedExpirationDate:
|
|
81
|
-
formattedPurchaseDate:
|
|
79
|
+
formattedExpirationDate: formatDate(status.expiresAt ?? null),
|
|
80
|
+
formattedPurchaseDate: formatDate(status.purchasedAt ?? null),
|
|
82
81
|
statusKey,
|
|
83
82
|
};
|
|
84
|
-
}, [status
|
|
83
|
+
}, [status]);
|
|
85
84
|
}
|
|
86
85
|
|
|
@@ -11,7 +11,7 @@ import { useCustomerInfo } from "../../revenuecat/presentation/hooks/useCustomer
|
|
|
11
11
|
import { usePaywallVisibility } from "./usePaywallVisibility";
|
|
12
12
|
import { calculateDaysRemaining } from "../../domain/entities/SubscriptionStatus";
|
|
13
13
|
import { SubscriptionManager } from "../../revenuecat/infrastructure/managers/SubscriptionManager";
|
|
14
|
-
import {
|
|
14
|
+
import { formatDate, convertPurchasedAt } from "../utils/subscriptionDateUtils";
|
|
15
15
|
import { useCreditsArray, getSubscriptionStatusType } from "./useSubscriptionSettingsConfig.utils";
|
|
16
16
|
import type {
|
|
17
17
|
SubscriptionSettingsConfig,
|
|
@@ -36,7 +36,6 @@ export const useSubscriptionSettingsConfig = (
|
|
|
36
36
|
): SubscriptionSettingsConfig => {
|
|
37
37
|
const {
|
|
38
38
|
userId,
|
|
39
|
-
currentLanguage = "en",
|
|
40
39
|
translations,
|
|
41
40
|
getCreditLimit,
|
|
42
41
|
upgradePrompt,
|
|
@@ -78,13 +77,13 @@ export const useSubscriptionSettingsConfig = (
|
|
|
78
77
|
|
|
79
78
|
// Formatted dates
|
|
80
79
|
const formattedExpirationDate = useMemo(
|
|
81
|
-
() =>
|
|
82
|
-
[expiresAtIso
|
|
80
|
+
() => formatDate(expiresAtIso),
|
|
81
|
+
[expiresAtIso]
|
|
83
82
|
);
|
|
84
83
|
|
|
85
84
|
const formattedPurchaseDate = useMemo(
|
|
86
|
-
() =>
|
|
87
|
-
[purchasedAtIso
|
|
85
|
+
() => formatDate(purchasedAtIso),
|
|
86
|
+
[purchasedAtIso]
|
|
88
87
|
);
|
|
89
88
|
|
|
90
89
|
// Days remaining calculation
|
|
@@ -61,8 +61,6 @@ export interface UseSubscriptionSettingsConfigParams {
|
|
|
61
61
|
userId?: string;
|
|
62
62
|
/** Whether user is anonymous */
|
|
63
63
|
isAnonymous?: boolean;
|
|
64
|
-
/** Current language for date formatting */
|
|
65
|
-
currentLanguage?: string;
|
|
66
64
|
/** Translation strings */
|
|
67
65
|
translations: SubscriptionSettingsTranslations;
|
|
68
66
|
/** Credit limit calculator */
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import { timezoneService } from "@umituz/react-native-timezone";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Converts Firestore timestamp or Date to ISO string
|
|
5
3
|
*/
|
|
6
4
|
export const convertPurchasedAt = (purchasedAt: unknown): string | null => {
|
|
7
5
|
if (!purchasedAt) return null;
|
|
8
6
|
|
|
7
|
+
let date: Date;
|
|
9
8
|
if (
|
|
10
9
|
typeof purchasedAt === "object" &&
|
|
11
10
|
purchasedAt !== null &&
|
|
12
11
|
"toDate" in purchasedAt
|
|
13
12
|
) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (purchasedAt instanceof Date) {
|
|
20
|
-
return timezoneService.formatToISOString(purchasedAt);
|
|
13
|
+
date = (purchasedAt as { toDate: () => Date }).toDate();
|
|
14
|
+
} else if (purchasedAt instanceof Date) {
|
|
15
|
+
date = purchasedAt;
|
|
16
|
+
} else {
|
|
17
|
+
return null;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
return
|
|
20
|
+
return date.toISOString();
|
|
24
21
|
};
|
|
25
22
|
|
|
26
23
|
/**
|