@oxyhq/services 6.9.43 → 6.9.45
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/lib/commonjs/index.js +9 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/ActingAsBanner.js +143 -0
- package/lib/commonjs/ui/components/ActingAsBanner.js.map +1 -0
- package/lib/commonjs/ui/components/OxyPayButton.js +4 -2
- package/lib/commonjs/ui/components/OxyPayButton.js.map +1 -1
- package/lib/commonjs/ui/components/OxySignInButton.js +83 -82
- package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
- package/lib/commonjs/ui/components/SettingRow.js +11 -5
- package/lib/commonjs/ui/components/SettingRow.js.map +1 -1
- package/lib/commonjs/ui/components/fileManagement/FileDetailsModal.js +76 -121
- package/lib/commonjs/ui/components/fileManagement/FileDetailsModal.js.map +1 -1
- package/lib/commonjs/ui/components/fileManagement/UploadPreview.js +32 -18
- package/lib/commonjs/ui/components/fileManagement/UploadPreview.js.map +1 -1
- package/lib/commonjs/ui/components/icon/OxyIcon.js +5 -4
- package/lib/commonjs/ui/components/icon/OxyIcon.js.map +1 -1
- package/lib/commonjs/ui/components/internal/GroupedPillButtons.js +11 -9
- package/lib/commonjs/ui/components/internal/GroupedPillButtons.js.map +1 -1
- package/lib/commonjs/ui/components/internal/PinInput.js +3 -2
- package/lib/commonjs/ui/components/internal/PinInput.js.map +1 -1
- package/lib/commonjs/ui/components/modals/DeleteAccountModal.js +83 -219
- package/lib/commonjs/ui/components/modals/DeleteAccountModal.js.map +1 -1
- package/lib/commonjs/ui/constants/theme.js +2 -2
- package/lib/commonjs/ui/constants/theme.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +78 -3
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/navigation/routes.js +3 -2
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +33 -11
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +70 -79
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +22 -10
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +376 -82
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountVerificationScreen.js +21 -9
- package/lib/commonjs/ui/screens/AccountVerificationScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/CreateManagedAccountScreen.js +346 -0
- package/lib/commonjs/ui/screens/CreateManagedAccountScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/FileManagementScreen.js +83 -50
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/HistoryViewScreen.js +80 -101
- package/lib/commonjs/ui/screens/HistoryViewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +66 -93
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SessionManagementScreen.js +101 -66
- package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/utils/fileManagement.js +0 -21
- package/lib/commonjs/ui/utils/fileManagement.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/ActingAsBanner.js +140 -0
- package/lib/module/ui/components/ActingAsBanner.js.map +1 -0
- package/lib/module/ui/components/OxyPayButton.js +4 -2
- package/lib/module/ui/components/OxyPayButton.js.map +1 -1
- package/lib/module/ui/components/OxySignInButton.js +84 -83
- package/lib/module/ui/components/OxySignInButton.js.map +1 -1
- package/lib/module/ui/components/SettingRow.js +11 -5
- package/lib/module/ui/components/SettingRow.js.map +1 -1
- package/lib/module/ui/components/fileManagement/FileDetailsModal.js +76 -122
- package/lib/module/ui/components/fileManagement/FileDetailsModal.js.map +1 -1
- package/lib/module/ui/components/fileManagement/UploadPreview.js +32 -19
- package/lib/module/ui/components/fileManagement/UploadPreview.js.map +1 -1
- package/lib/module/ui/components/icon/OxyIcon.js +5 -4
- package/lib/module/ui/components/icon/OxyIcon.js.map +1 -1
- package/lib/module/ui/components/internal/GroupedPillButtons.js +11 -9
- package/lib/module/ui/components/internal/GroupedPillButtons.js.map +1 -1
- package/lib/module/ui/components/internal/PinInput.js +3 -2
- package/lib/module/ui/components/internal/PinInput.js.map +1 -1
- package/lib/module/ui/components/modals/DeleteAccountModal.js +83 -220
- package/lib/module/ui/components/modals/DeleteAccountModal.js.map +1 -1
- package/lib/module/ui/constants/theme.js +2 -2
- package/lib/module/ui/constants/theme.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +78 -3
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/navigation/routes.js +3 -2
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +32 -11
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +71 -80
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +22 -10
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +375 -82
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountVerificationScreen.js +22 -10
- package/lib/module/ui/screens/AccountVerificationScreen.js.map +1 -1
- package/lib/module/ui/screens/CreateManagedAccountScreen.js +342 -0
- package/lib/module/ui/screens/CreateManagedAccountScreen.js.map +1 -0
- package/lib/module/ui/screens/FileManagementScreen.js +85 -52
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/HistoryViewScreen.js +80 -101
- package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -1
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js +66 -94
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/module/ui/screens/SessionManagementScreen.js +101 -67
- package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/module/ui/utils/fileManagement.js +0 -20
- package/lib/module/ui/utils/fileManagement.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ActingAsBanner.d.ts +4 -0
- package/lib/typescript/commonjs/ui/components/ActingAsBanner.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/OxyPayButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxySignInButton.d.ts +0 -1
- package/lib/typescript/commonjs/ui/components/OxySignInButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/SettingRow.d.ts +2 -2
- package/lib/typescript/commonjs/ui/components/SettingRow.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/fileManagement/FileDetailsModal.d.ts +3 -4
- package/lib/typescript/commonjs/ui/components/fileManagement/FileDetailsModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/fileManagement/UploadPreview.d.ts +2 -3
- package/lib/typescript/commonjs/ui/components/fileManagement/UploadPreview.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/icon/OxyIcon.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/internal/GroupedPillButtons.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/internal/PinInput.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/modals/DeleteAccountModal.d.ts +2 -2
- package/lib/typescript/commonjs/ui/components/modals/DeleteAccountModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +6 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/navigation/routes.d.ts +1 -1
- package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountCenterScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountVerificationScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/CreateManagedAccountScreen.d.ts +5 -0
- package/lib/typescript/commonjs/ui/screens/CreateManagedAccountScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/FileManagementScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/HistoryViewScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/SessionManagementScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/fileManagement.d.ts +0 -4
- package/lib/typescript/commonjs/ui/utils/fileManagement.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ActingAsBanner.d.ts +4 -0
- package/lib/typescript/module/ui/components/ActingAsBanner.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/OxyPayButton.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxySignInButton.d.ts +0 -1
- package/lib/typescript/module/ui/components/OxySignInButton.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/SettingRow.d.ts +2 -2
- package/lib/typescript/module/ui/components/SettingRow.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/fileManagement/FileDetailsModal.d.ts +3 -4
- package/lib/typescript/module/ui/components/fileManagement/FileDetailsModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/fileManagement/UploadPreview.d.ts +2 -3
- package/lib/typescript/module/ui/components/fileManagement/UploadPreview.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/icon/OxyIcon.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/internal/GroupedPillButtons.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/internal/PinInput.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/modals/DeleteAccountModal.d.ts +2 -2
- package/lib/typescript/module/ui/components/modals/DeleteAccountModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts +6 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/navigation/routes.d.ts +1 -1
- package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AccountCenterScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AccountVerificationScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/CreateManagedAccountScreen.d.ts +5 -0
- package/lib/typescript/module/ui/screens/CreateManagedAccountScreen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/FileManagementScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/HistoryViewScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/SessionManagementScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/fileManagement.d.ts +0 -4
- package/lib/typescript/module/ui/utils/fileManagement.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +3 -0
- package/src/ui/components/ActingAsBanner.tsx +135 -0
- package/src/ui/components/OxyPayButton.tsx +5 -3
- package/src/ui/components/OxySignInButton.tsx +82 -81
- package/src/ui/components/SettingRow.tsx +14 -7
- package/src/ui/components/fileManagement/FileDetailsModal.tsx +69 -99
- package/src/ui/components/fileManagement/UploadPreview.tsx +58 -46
- package/src/ui/components/icon/OxyIcon.tsx +5 -4
- package/src/ui/components/internal/GroupedPillButtons.tsx +15 -12
- package/src/ui/components/internal/PinInput.tsx +4 -3
- package/src/ui/components/modals/DeleteAccountModal.tsx +79 -221
- package/src/ui/constants/theme.ts +2 -2
- package/src/ui/context/OxyContext.tsx +85 -0
- package/src/ui/navigation/routes.ts +3 -1
- package/src/ui/screens/AccountCenterScreen.tsx +40 -122
- package/src/ui/screens/AccountOverviewScreen.tsx +63 -98
- package/src/ui/screens/AccountSettingsScreen.tsx +21 -7
- package/src/ui/screens/AccountSwitcherScreen.tsx +344 -87
- package/src/ui/screens/AccountVerificationScreen.tsx +24 -16
- package/src/ui/screens/CreateManagedAccountScreen.tsx +338 -0
- package/src/ui/screens/FileManagementScreen.tsx +62 -54
- package/src/ui/screens/HistoryViewScreen.tsx +57 -204
- package/src/ui/screens/PremiumSubscriptionScreen.tsx +73 -93
- package/src/ui/screens/SessionManagementScreen.tsx +101 -73
- package/src/ui/utils/fileManagement.ts +0 -30
- package/lib/commonjs/ui/utils/confirmAction.js +0 -28
- package/lib/commonjs/ui/utils/confirmAction.js.map +0 -1
- package/lib/module/ui/utils/confirmAction.js +0 -25
- package/lib/module/ui/utils/confirmAction.js.map +0 -1
- package/lib/typescript/commonjs/ui/utils/confirmAction.d.ts +0 -7
- package/lib/typescript/commonjs/ui/utils/confirmAction.d.ts.map +0 -1
- package/lib/typescript/module/ui/utils/confirmAction.d.ts +0 -7
- package/lib/typescript/module/ui/utils/confirmAction.d.ts.map +0 -1
- package/src/ui/utils/confirmAction.ts +0 -23
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import React, { useState, useCallback } from 'react';
|
|
4
4
|
import { View, StyleSheet, ScrollView } from 'react-native';
|
|
5
5
|
import { toast } from '../../lib/sonner';
|
|
6
|
-
import { confirmAction } from "../utils/confirmAction.js";
|
|
7
6
|
import { Header, Section, GroupedSection, LoadingState, EmptyState } from "../components/index.js";
|
|
8
7
|
import { useI18n } from "../hooks/useI18n.js";
|
|
9
8
|
import { useTheme } from '@oxyhq/bloom/theme';
|
|
@@ -11,13 +10,14 @@ import { useColorScheme } from "../hooks/useColorScheme.js";
|
|
|
11
10
|
import { Colors } from "../constants/theme.js";
|
|
12
11
|
import { normalizeColorScheme } from "../utils/themeUtils.js";
|
|
13
12
|
import { useOxy } from "../context/OxyContext.js";
|
|
13
|
+
import * as Prompt from '@oxyhq/bloom/prompt';
|
|
14
|
+
import { usePromptControl } from '@oxyhq/bloom/prompt';
|
|
14
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
16
|
const HistoryViewScreen = ({
|
|
16
17
|
onClose,
|
|
17
18
|
theme,
|
|
18
19
|
goBack
|
|
19
20
|
}) => {
|
|
20
|
-
// Use useOxy() hook for OxyContext values
|
|
21
21
|
const {
|
|
22
22
|
user
|
|
23
23
|
} = useOxy();
|
|
@@ -31,128 +31,93 @@ const HistoryViewScreen = ({
|
|
|
31
31
|
const [history, setHistory] = useState([]);
|
|
32
32
|
const [isLoading, setIsLoading] = useState(true);
|
|
33
33
|
const [isDeleting, setIsDeleting] = useState(false);
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const deleteLast15Prompt = usePromptControl();
|
|
35
|
+
const clearAllPrompt = usePromptControl();
|
|
36
36
|
const getStorage = async () => {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
37
|
+
const isRN = typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
38
|
+
if (isRN) {
|
|
39
39
|
try {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
40
|
+
const mod = await import('@react-native-async-storage/async-storage');
|
|
41
|
+
const s = mod.default;
|
|
42
42
|
return {
|
|
43
|
-
getItem:
|
|
44
|
-
setItem:
|
|
45
|
-
removeItem:
|
|
43
|
+
getItem: s.getItem.bind(s),
|
|
44
|
+
setItem: s.setItem.bind(s),
|
|
45
|
+
removeItem: s.removeItem.bind(s)
|
|
46
46
|
};
|
|
47
|
-
} catch (
|
|
48
|
-
if (__DEV__)
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
throw new Error('AsyncStorage is required in React Native environment');
|
|
47
|
+
} catch (e) {
|
|
48
|
+
if (__DEV__) console.error('AsyncStorage not available:', e);
|
|
49
|
+
throw new Error('AsyncStorage required');
|
|
52
50
|
}
|
|
53
|
-
} else {
|
|
54
|
-
// Use localStorage for web
|
|
55
|
-
return {
|
|
56
|
-
getItem: async key => {
|
|
57
|
-
if (typeof window !== 'undefined' && window.localStorage) {
|
|
58
|
-
return window.localStorage.getItem(key);
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
},
|
|
62
|
-
setItem: async (key, value) => {
|
|
63
|
-
if (typeof window !== 'undefined' && window.localStorage) {
|
|
64
|
-
window.localStorage.setItem(key, value);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
removeItem: async key => {
|
|
68
|
-
if (typeof window !== 'undefined' && window.localStorage) {
|
|
69
|
-
window.localStorage.removeItem(key);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
51
|
}
|
|
52
|
+
return {
|
|
53
|
+
getItem: async k => typeof window !== 'undefined' && window.localStorage ? window.localStorage.getItem(k) : null,
|
|
54
|
+
setItem: async (k, v) => {
|
|
55
|
+
if (typeof window !== 'undefined' && window.localStorage) window.localStorage.setItem(k, v);
|
|
56
|
+
},
|
|
57
|
+
removeItem: async k => {
|
|
58
|
+
if (typeof window !== 'undefined' && window.localStorage) window.localStorage.removeItem(k);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
74
61
|
};
|
|
75
|
-
|
|
76
|
-
// TODO: Integrate with backend API for history storage
|
|
77
|
-
// Currently uses local storage only. Should fetch from backend API and sync across devices.
|
|
78
|
-
// Load history from storage
|
|
79
62
|
React.useEffect(() => {
|
|
80
|
-
const
|
|
63
|
+
const load = async () => {
|
|
81
64
|
try {
|
|
82
65
|
setIsLoading(true);
|
|
83
66
|
const storage = await getStorage();
|
|
84
|
-
const
|
|
85
|
-
const stored = await storage.getItem(historyKey);
|
|
67
|
+
const stored = await storage.getItem(`history_${user?.id || 'guest'}`);
|
|
86
68
|
if (stored) {
|
|
87
69
|
const parsed = JSON.parse(stored);
|
|
88
|
-
setHistory(parsed.map(
|
|
89
|
-
...
|
|
90
|
-
timestamp: new Date(
|
|
70
|
+
setHistory(parsed.map(i => ({
|
|
71
|
+
...i,
|
|
72
|
+
timestamp: new Date(i.timestamp)
|
|
91
73
|
})));
|
|
92
|
-
} else
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
} catch (error) {
|
|
74
|
+
} else setHistory([]);
|
|
75
|
+
} catch {
|
|
96
76
|
setHistory([]);
|
|
97
77
|
} finally {
|
|
98
78
|
setIsLoading(false);
|
|
99
79
|
}
|
|
100
80
|
};
|
|
101
|
-
|
|
81
|
+
load();
|
|
102
82
|
}, [user?.id]);
|
|
103
83
|
const handleDeleteLast15Minutes = useCallback(async () => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
console.error('Failed to delete history:', error);
|
|
119
|
-
}
|
|
120
|
-
toast.error(t('history.deleteLast15Minutes.error') || 'Failed to delete history');
|
|
121
|
-
} finally {
|
|
122
|
-
setIsDeleting(false);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
84
|
+
try {
|
|
85
|
+
setIsDeleting(true);
|
|
86
|
+
const cutoff = new Date(Date.now() - 15 * 60 * 1000);
|
|
87
|
+
const filtered = history.filter(item => item.timestamp < cutoff);
|
|
88
|
+
setHistory(filtered);
|
|
89
|
+
const storage = await getStorage();
|
|
90
|
+
await storage.setItem(`history_${user?.id || 'guest'}`, JSON.stringify(filtered));
|
|
91
|
+
toast.success(t('history.deleteLast15Minutes.success') || 'Last 15 minutes deleted');
|
|
92
|
+
} catch (e) {
|
|
93
|
+
if (__DEV__) console.error('Failed to delete history:', e);
|
|
94
|
+
toast.error(t('history.deleteLast15Minutes.error') || 'Failed to delete history');
|
|
95
|
+
} finally {
|
|
96
|
+
setIsDeleting(false);
|
|
97
|
+
}
|
|
125
98
|
}, [history, user?.id, t]);
|
|
126
99
|
const handleClearAll = useCallback(async () => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
console.error('Failed to clear history:', error);
|
|
140
|
-
}
|
|
141
|
-
toast.error(t('history.clearAll.error') || 'Failed to clear history');
|
|
142
|
-
} finally {
|
|
143
|
-
setIsDeleting(false);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
100
|
+
try {
|
|
101
|
+
setIsDeleting(true);
|
|
102
|
+
setHistory([]);
|
|
103
|
+
const storage = await getStorage();
|
|
104
|
+
await storage.removeItem(`history_${user?.id || 'guest'}`);
|
|
105
|
+
toast.success(t('history.clearAll.success') || 'History cleared');
|
|
106
|
+
} catch (e) {
|
|
107
|
+
if (__DEV__) console.error('Failed to clear history:', e);
|
|
108
|
+
toast.error(t('history.clearAll.error') || 'Failed to clear history');
|
|
109
|
+
} finally {
|
|
110
|
+
setIsDeleting(false);
|
|
111
|
+
}
|
|
146
112
|
}, [user?.id, t]);
|
|
147
113
|
const formatTime = date => {
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
if (
|
|
155
|
-
if (hours < 24) return `${hours} ${t('history.hoursAgo') || 'hours ago'}`;
|
|
114
|
+
const diff = new Date().getTime() - date.getTime();
|
|
115
|
+
const min = Math.floor(diff / 60000);
|
|
116
|
+
const hrs = Math.floor(min / 60);
|
|
117
|
+
const days = Math.floor(hrs / 24);
|
|
118
|
+
if (min < 1) return t('history.justNow') || 'Just now';
|
|
119
|
+
if (min < 60) return `${min} ${t('history.minutesAgo') || 'minutes ago'}`;
|
|
120
|
+
if (hrs < 24) return `${hrs} ${t('history.hoursAgo') || 'hours ago'}`;
|
|
156
121
|
if (days < 7) return `${days} ${t('history.daysAgo') || 'days ago'}`;
|
|
157
122
|
return date.toLocaleDateString();
|
|
158
123
|
};
|
|
@@ -177,7 +142,7 @@ const HistoryViewScreen = ({
|
|
|
177
142
|
iconColor: themeColors.iconStorage,
|
|
178
143
|
title: t('history.deleteLast15Minutes.title') || 'Delete Last 15 Minutes',
|
|
179
144
|
subtitle: t('history.deleteLast15Minutes.subtitle') || 'Remove recent history entries',
|
|
180
|
-
onPress:
|
|
145
|
+
onPress: () => deleteLast15Prompt.open(),
|
|
181
146
|
disabled: isDeleting || history.length === 0
|
|
182
147
|
}, {
|
|
183
148
|
id: 'clear-all',
|
|
@@ -185,7 +150,7 @@ const HistoryViewScreen = ({
|
|
|
185
150
|
iconColor: themeColors.iconSharing,
|
|
186
151
|
title: t('history.clearAll.title') || 'Clear All History',
|
|
187
152
|
subtitle: t('history.clearAll.subtitle') || 'Remove all history entries',
|
|
188
|
-
onPress:
|
|
153
|
+
onPress: () => clearAllPrompt.open(),
|
|
189
154
|
disabled: isDeleting || history.length === 0
|
|
190
155
|
}]
|
|
191
156
|
})
|
|
@@ -207,6 +172,20 @@ const HistoryViewScreen = ({
|
|
|
207
172
|
}))
|
|
208
173
|
})
|
|
209
174
|
})]
|
|
175
|
+
}), /*#__PURE__*/_jsx(Prompt.Basic, {
|
|
176
|
+
control: deleteLast15Prompt,
|
|
177
|
+
title: t('history.deleteLast15Minutes.title') || 'Delete Last 15 Minutes',
|
|
178
|
+
description: t('history.deleteLast15Minutes.confirm') || 'Delete last 15 minutes of history?',
|
|
179
|
+
onConfirm: handleDeleteLast15Minutes,
|
|
180
|
+
confirmButtonCta: t('common.actions.delete') || 'Delete',
|
|
181
|
+
confirmButtonColor: "negative"
|
|
182
|
+
}), /*#__PURE__*/_jsx(Prompt.Basic, {
|
|
183
|
+
control: clearAllPrompt,
|
|
184
|
+
title: t('history.clearAll.title') || 'Clear All History',
|
|
185
|
+
description: t('history.clearAll.confirm') || 'Clear all history? This cannot be undone.',
|
|
186
|
+
onConfirm: handleClearAll,
|
|
187
|
+
confirmButtonCta: t('history.clearAll.title') || 'Clear All',
|
|
188
|
+
confirmButtonColor: "negative"
|
|
210
189
|
})]
|
|
211
190
|
});
|
|
212
191
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","useCallback","View","StyleSheet","ScrollView","toast","
|
|
1
|
+
{"version":3,"names":["React","useState","useCallback","View","StyleSheet","ScrollView","toast","Header","Section","GroupedSection","LoadingState","EmptyState","useI18n","useTheme","useColorScheme","Colors","normalizeColorScheme","useOxy","Prompt","usePromptControl","jsx","_jsx","jsxs","_jsxs","HistoryViewScreen","onClose","theme","goBack","user","t","bloomTheme","colorScheme","normalizedColorScheme","themeColors","history","setHistory","isLoading","setIsLoading","isDeleting","setIsDeleting","deleteLast15Prompt","clearAllPrompt","getStorage","isRN","navigator","product","mod","s","default","getItem","bind","setItem","removeItem","e","__DEV__","console","error","Error","k","window","localStorage","v","useEffect","load","storage","stored","id","parsed","JSON","parse","map","i","timestamp","Date","handleDeleteLast15Minutes","cutoff","now","filtered","filter","item","stringify","success","handleClearAll","formatTime","date","diff","getTime","min","Math","floor","hrs","days","toLocaleDateString","style","styles","container","backgroundColor","colors","background","children","title","onBack","variant","elevation","content","isFirst","items","icon","iconColor","iconStorage","subtitle","onPress","open","disabled","length","iconSharing","message","color","text","textColor","type","iconSecurity","iconPersonalInfo","query","Basic","control","description","onConfirm","confirmButtonCta","confir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0G,KAAK;MAACC,OAAO,EAAEpF,cAAe;MAAC2D,KAAK,EAAEvE,CAAC,CAAC,wBAAwB,CAAC,IAAI,mBAAoB;MAACiG,WAAW,EAAEjG,CAAC,CAAC,0BAA0B,CAAC,IAAI,2CAA4C;MAACkG,SAAS,EAAE7C,cAAe;MAAC8C,gBAAgB,EAAEnG,CAAC,CAAC,wBAAwB,CAAC,IAAI,WAAY;MAACoG,kBAAkB,EAAC;IAAU,CAAE,CAAC;EAAA,CACpT,CAAC;AAEf,CAAC;AAED,MAAMnC,MAAM,GAAG1F,UAAU,CAAC8H,MAAM,CAAC;EAAEnC,SAAS,EAAE;IAAEoC,IAAI,EAAE;EAAE,CAAC;EAAE3B,OAAO,EAAE;IAAE2B,IAAI,EAAE,CAAC;IAAEC,OAAO,EAAE;EAAG;AAAE,CAAC,CAAC;AAE/F,4BAAepI,KAAK,CAACqI,IAAI,CAAC7G,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
4
4
|
import { View, Text, TouchableOpacity, StyleSheet, ScrollView, ActivityIndicator } from 'react-native';
|
|
5
5
|
import { fontFamilies } from "../styles/fonts.js";
|
|
6
6
|
import { toast } from '../../lib/sonner';
|
|
7
|
-
import
|
|
7
|
+
import * as Prompt from '@oxyhq/bloom/prompt';
|
|
8
|
+
import { usePromptControl } from '@oxyhq/bloom/prompt';
|
|
8
9
|
import { Ionicons } from '@expo/vector-icons';
|
|
9
10
|
import { useI18n } from "../hooks/useI18n.js";
|
|
10
11
|
import { useTheme } from '@oxyhq/bloom/theme';
|
|
@@ -30,11 +31,16 @@ const PremiumSubscriptionScreen = ({
|
|
|
30
31
|
const [billingInterval, setBillingInterval] = useState('month');
|
|
31
32
|
const [activeTab, setActiveTab] = useState('plans');
|
|
32
33
|
const [currentAppPackage, setCurrentAppPackage] = useState('mention'); // Default to mention for demo
|
|
33
|
-
|
|
34
|
+
const [pendingUnsubscribeFeatureId, setPendingUnsubscribeFeatureId] = useState(null);
|
|
34
35
|
const {
|
|
35
36
|
t
|
|
36
37
|
} = useI18n();
|
|
37
38
|
const bloomTheme = useTheme();
|
|
39
|
+
|
|
40
|
+
// Prompt controls
|
|
41
|
+
const cancelSubscriptionPrompt = usePromptControl();
|
|
42
|
+
const unsubscribeFeaturePrompt = usePromptControl();
|
|
43
|
+
|
|
38
44
|
// Extract commonly used colors for readability
|
|
39
45
|
const textColor = bloomTheme.colors.text;
|
|
40
46
|
const backgroundColor = bloomTheme.colors.background;
|
|
@@ -217,46 +223,14 @@ const PremiumSubscriptionScreen = ({
|
|
|
217
223
|
}
|
|
218
224
|
}, [currentAppPackage, user?.isPremium]);
|
|
219
225
|
const detectCurrentApp = () => {
|
|
220
|
-
|
|
221
|
-
// For now, we'll use a mock detection based on available methods
|
|
222
|
-
|
|
223
|
-
// Real app detection methods you could use:
|
|
224
|
-
// 1. Check bundle identifier in React Native:
|
|
225
|
-
// import DeviceInfo from 'react-native-device-info';
|
|
226
|
-
// const bundleId = DeviceInfo.getBundleId();
|
|
227
|
-
// Example: com.oxy.mention -> 'mention'
|
|
228
|
-
|
|
229
|
-
// 2. Environment variables or build configuration
|
|
230
|
-
// const appPackage = __DEV__ ? process.env.APP_PACKAGE : 'mention';
|
|
231
|
-
|
|
232
|
-
// 3. Check specific app capabilities or modules
|
|
233
|
-
// if (typeof MentionModule !== 'undefined') return 'mention';
|
|
234
|
-
// if (typeof OxyWorkspaceModule !== 'undefined') return 'oxy-workspace';
|
|
235
|
-
|
|
236
|
-
// 4. Use build-time configuration with Metro or similar
|
|
237
|
-
// const appPackage = require('../config/app.json').packageName;
|
|
238
|
-
|
|
239
|
-
// For demo purposes, we'll simulate different apps
|
|
240
|
-
// You would replace this with actual app detection logic
|
|
241
|
-
|
|
242
|
-
// IMPORTANT: This ensures subscription restrictions work properly:
|
|
243
|
-
// - Mention+ plan can only be subscribed to when app package == 'mention'
|
|
244
|
-
// - Other app-specific plans follow the same pattern
|
|
245
|
-
// - Ecosystem plans work across all apps
|
|
246
|
-
|
|
247
|
-
const detectedApp = 'mention'; // This would be dynamic in real implementation
|
|
248
|
-
|
|
226
|
+
const detectedApp = 'mention';
|
|
249
227
|
setCurrentAppPackage(detectedApp);
|
|
250
228
|
};
|
|
251
229
|
const loadSubscriptionData = async () => {
|
|
252
230
|
try {
|
|
253
231
|
setLoading(true);
|
|
254
|
-
|
|
255
|
-
// Filter plans available for current app
|
|
256
232
|
const availablePlans = mockPlans.filter(plan => plan.applicableApps.includes(currentAppPackage));
|
|
257
233
|
setPlans(availablePlans);
|
|
258
|
-
|
|
259
|
-
// Mock current subscription
|
|
260
234
|
let currentSubscription = null;
|
|
261
235
|
if (user?.isPremium) {
|
|
262
236
|
currentSubscription = {
|
|
@@ -269,15 +243,13 @@ const PremiumSubscriptionScreen = ({
|
|
|
269
243
|
};
|
|
270
244
|
setSubscription(currentSubscription);
|
|
271
245
|
}
|
|
272
|
-
|
|
273
|
-
// Filter features available for current app and update based on current subscription
|
|
274
246
|
const availableFeatures = mockIndividualFeatures.filter(feature => feature.applicableApps.includes(currentAppPackage));
|
|
275
247
|
const updatedFeatures = availableFeatures.map(feature => {
|
|
276
248
|
const isIncludedInCurrentPlan = !!(currentSubscription && feature.includedInPlans.includes(currentSubscription.planId));
|
|
277
249
|
return {
|
|
278
250
|
...feature,
|
|
279
251
|
isIncludedInCurrentPlan,
|
|
280
|
-
isSubscribed: !!isIncludedInCurrentPlan
|
|
252
|
+
isSubscribed: !!isIncludedInCurrentPlan
|
|
281
253
|
};
|
|
282
254
|
});
|
|
283
255
|
setIndividualFeatures(updatedFeatures);
|
|
@@ -295,7 +267,6 @@ const PremiumSubscriptionScreen = ({
|
|
|
295
267
|
};
|
|
296
268
|
const handleSubscribe = async planId => {
|
|
297
269
|
try {
|
|
298
|
-
// Check if plan is available for current app
|
|
299
270
|
const selectedPlan = mockPlans.find(plan => plan.id === planId);
|
|
300
271
|
if (!selectedPlan?.applicableApps.includes(currentAppPackage)) {
|
|
301
272
|
toast.error(t('premium.toasts.planUnavailable', {
|
|
@@ -303,19 +274,13 @@ const PremiumSubscriptionScreen = ({
|
|
|
303
274
|
}) || `This plan is not available for the current app (${currentAppPackage})`);
|
|
304
275
|
return;
|
|
305
276
|
}
|
|
306
|
-
|
|
307
|
-
// Special restriction for Mention+ plan - only available in mention app
|
|
308
277
|
if (planId === 'mention-plus' && currentAppPackage !== 'mention') {
|
|
309
278
|
toast.error(t('premium.toasts.mentionOnly') || 'Mention+ is only available in the Mention app');
|
|
310
279
|
return;
|
|
311
280
|
}
|
|
312
281
|
setProcessingPayment(true);
|
|
313
|
-
|
|
314
|
-
// Mock payment processing
|
|
315
282
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
316
283
|
toast.success(t('premium.toasts.activated') || 'Subscription activated successfully!');
|
|
317
|
-
|
|
318
|
-
// Mock subscription update
|
|
319
284
|
setSubscription({
|
|
320
285
|
id: `sub_${Date.now()}`,
|
|
321
286
|
planId,
|
|
@@ -324,8 +289,6 @@ const PremiumSubscriptionScreen = ({
|
|
|
324
289
|
currentPeriodEnd: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),
|
|
325
290
|
cancelAtPeriodEnd: false
|
|
326
291
|
});
|
|
327
|
-
|
|
328
|
-
// Reload data to update feature states
|
|
329
292
|
loadSubscriptionData();
|
|
330
293
|
} catch (error) {
|
|
331
294
|
if (__DEV__) {
|
|
@@ -336,20 +299,20 @@ const PremiumSubscriptionScreen = ({
|
|
|
336
299
|
setProcessingPayment(false);
|
|
337
300
|
}
|
|
338
301
|
};
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
};
|
|
302
|
+
const confirmCancelSubscription = useCallback(() => {
|
|
303
|
+
cancelSubscriptionPrompt.open();
|
|
304
|
+
}, [cancelSubscriptionPrompt]);
|
|
305
|
+
const handleCancelSubscription = useCallback(async () => {
|
|
306
|
+
try {
|
|
307
|
+
setSubscription(prev => prev ? {
|
|
308
|
+
...prev,
|
|
309
|
+
cancelAtPeriodEnd: true
|
|
310
|
+
} : null);
|
|
311
|
+
toast.success(t('premium.toasts.willCancel') || 'Subscription will be canceled at the end of the billing period');
|
|
312
|
+
} catch (error) {
|
|
313
|
+
toast.error(t('premium.toasts.cancelFailed') || 'Failed to cancel subscription');
|
|
314
|
+
}
|
|
315
|
+
}, [t]);
|
|
353
316
|
const handleReactivateSubscription = async () => {
|
|
354
317
|
try {
|
|
355
318
|
setSubscription(prev => prev ? {
|
|
@@ -362,7 +325,7 @@ const PremiumSubscriptionScreen = ({
|
|
|
362
325
|
}
|
|
363
326
|
};
|
|
364
327
|
const formatPrice = (price, currency, interval) => {
|
|
365
|
-
const yearlyPrice = interval === 'year' ? price : price * 12 * 0.8;
|
|
328
|
+
const yearlyPrice = interval === 'year' ? price : price * 12 * 0.8;
|
|
366
329
|
const displayPrice = billingInterval === 'year' ? yearlyPrice : price;
|
|
367
330
|
return {
|
|
368
331
|
price: displayPrice,
|
|
@@ -376,16 +339,12 @@ const PremiumSubscriptionScreen = ({
|
|
|
376
339
|
};
|
|
377
340
|
const handleFeatureSubscribe = async featureId => {
|
|
378
341
|
try {
|
|
379
|
-
// Check if feature is available for current app
|
|
380
342
|
const selectedFeature = mockIndividualFeatures.find(feature => feature.id === featureId);
|
|
381
343
|
if (!selectedFeature?.applicableApps.includes(currentAppPackage)) {
|
|
382
344
|
toast.error(`This feature is not available for the current app (${currentAppPackage})`);
|
|
383
345
|
return;
|
|
384
346
|
}
|
|
385
|
-
|
|
386
|
-
// Special restrictions for app-specific features
|
|
387
347
|
if (selectedFeature.appScope === 'specific') {
|
|
388
|
-
// For features that are only available in specific apps, enforce strict matching
|
|
389
348
|
const hasExactMatch = selectedFeature.applicableApps.length === 1 && selectedFeature.applicableApps[0] === currentAppPackage;
|
|
390
349
|
if (!hasExactMatch && selectedFeature.applicableApps.length === 1) {
|
|
391
350
|
const requiredApp = selectedFeature.applicableApps[0];
|
|
@@ -394,8 +353,6 @@ const PremiumSubscriptionScreen = ({
|
|
|
394
353
|
}
|
|
395
354
|
}
|
|
396
355
|
setProcessingPayment(true);
|
|
397
|
-
|
|
398
|
-
// Mock feature subscription
|
|
399
356
|
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
400
357
|
setIndividualFeatures(prev => prev.map(feature => feature.id === featureId ? {
|
|
401
358
|
...feature,
|
|
@@ -414,24 +371,28 @@ const PremiumSubscriptionScreen = ({
|
|
|
414
371
|
setProcessingPayment(false);
|
|
415
372
|
}
|
|
416
373
|
};
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
374
|
+
const confirmFeatureUnsubscribe = useCallback(featureId => {
|
|
375
|
+
setPendingUnsubscribeFeatureId(featureId);
|
|
376
|
+
unsubscribeFeaturePrompt.open();
|
|
377
|
+
}, [unsubscribeFeaturePrompt]);
|
|
378
|
+
const handleFeatureUnsubscribe = useCallback(async () => {
|
|
379
|
+
if (!pendingUnsubscribeFeatureId) return;
|
|
380
|
+
const feature = individualFeatures.find(f => f.id === pendingUnsubscribeFeatureId);
|
|
381
|
+
try {
|
|
382
|
+
setIndividualFeatures(prev => prev.map(f => f.id === pendingUnsubscribeFeatureId ? {
|
|
383
|
+
...f,
|
|
384
|
+
isSubscribed: false
|
|
385
|
+
} : f));
|
|
386
|
+
toast.success(t('premium.toasts.featureUnsubscribed', {
|
|
387
|
+
name: feature?.name ?? ''
|
|
388
|
+
}) ?? `Unsubscribed from ${feature?.name}`);
|
|
389
|
+
} catch (error) {
|
|
390
|
+
toast.error(t('premium.toasts.featureUnsubscribeFailed') || 'Failed to unsubscribe from feature');
|
|
391
|
+
} finally {
|
|
392
|
+
setPendingUnsubscribeFeatureId(null);
|
|
393
|
+
}
|
|
394
|
+
}, [pendingUnsubscribeFeatureId, individualFeatures, t]);
|
|
395
|
+
const pendingUnsubscribeFeature = useMemo(() => individualFeatures.find(f => f.id === pendingUnsubscribeFeatureId), [individualFeatures, pendingUnsubscribeFeatureId]);
|
|
435
396
|
const renderHeader = () => {
|
|
436
397
|
const getAppDisplayName = packageName => {
|
|
437
398
|
const appNames = {
|
|
@@ -558,7 +519,7 @@ const PremiumSubscriptionScreen = ({
|
|
|
558
519
|
style: [styles.actionButton, {
|
|
559
520
|
backgroundColor: dangerColor
|
|
560
521
|
}],
|
|
561
|
-
onPress:
|
|
522
|
+
onPress: confirmCancelSubscription,
|
|
562
523
|
children: /*#__PURE__*/_jsx(Text, {
|
|
563
524
|
style: styles.actionButtonText,
|
|
564
525
|
children: t('premium.actions.cancelSubBtn') || 'Cancel Subscription'
|
|
@@ -938,7 +899,7 @@ const PremiumSubscriptionScreen = ({
|
|
|
938
899
|
style: [styles.unsubscribeButton, {
|
|
939
900
|
borderColor: dangerColor
|
|
940
901
|
}],
|
|
941
|
-
onPress: () =>
|
|
902
|
+
onPress: () => confirmFeatureUnsubscribe(feature.id),
|
|
942
903
|
children: /*#__PURE__*/_jsx(Text, {
|
|
943
904
|
style: [styles.unsubscribeText, {
|
|
944
905
|
color: dangerColor
|
|
@@ -1164,6 +1125,22 @@ const PremiumSubscriptionScreen = ({
|
|
|
1164
1125
|
}), /*#__PURE__*/_jsx(View, {
|
|
1165
1126
|
style: styles.bottomSpacing
|
|
1166
1127
|
})]
|
|
1128
|
+
}), /*#__PURE__*/_jsx(Prompt.Basic, {
|
|
1129
|
+
control: cancelSubscriptionPrompt,
|
|
1130
|
+
title: t('premium.confirms.cancelSubTitle') || 'Cancel Subscription',
|
|
1131
|
+
description: t('premium.confirms.cancelSub') || 'Are you sure you want to cancel your subscription? You will lose access to premium features at the end of your current billing period.',
|
|
1132
|
+
onConfirm: handleCancelSubscription,
|
|
1133
|
+
confirmButtonCta: t('premium.actions.cancelSubBtn') || 'Cancel Subscription',
|
|
1134
|
+
confirmButtonColor: "negative"
|
|
1135
|
+
}), /*#__PURE__*/_jsx(Prompt.Basic, {
|
|
1136
|
+
control: unsubscribeFeaturePrompt,
|
|
1137
|
+
title: t('premium.confirms.unsubscribeFeatureTitle') || 'Unsubscribe from Feature',
|
|
1138
|
+
description: pendingUnsubscribeFeature ? t('premium.confirms.unsubscribeFeature', {
|
|
1139
|
+
name: pendingUnsubscribeFeature.name
|
|
1140
|
+
}) ?? `Are you sure you want to unsubscribe from ${pendingUnsubscribeFeature.name}?` : '',
|
|
1141
|
+
onConfirm: handleFeatureUnsubscribe,
|
|
1142
|
+
confirmButtonCta: t('premium.actions.unsubscribe') || 'Unsubscribe',
|
|
1143
|
+
confirmButtonColor: "negative"
|
|
1167
1144
|
})]
|
|
1168
1145
|
});
|
|
1169
1146
|
};
|
|
@@ -1415,7 +1392,6 @@ const styles = StyleSheet.create({
|
|
|
1415
1392
|
bottomSpacing: {
|
|
1416
1393
|
height: 40
|
|
1417
1394
|
},
|
|
1418
|
-
// Tab Navigation Styles
|
|
1419
1395
|
tabContainer: {
|
|
1420
1396
|
flexDirection: 'row',
|
|
1421
1397
|
borderBottomWidth: 1,
|
|
@@ -1431,7 +1407,6 @@ const styles = StyleSheet.create({
|
|
|
1431
1407
|
fontSize: 16,
|
|
1432
1408
|
fontWeight: '600'
|
|
1433
1409
|
},
|
|
1434
|
-
// Individual Feature Styles
|
|
1435
1410
|
featureCard: {
|
|
1436
1411
|
borderRadius: 12,
|
|
1437
1412
|
borderWidth: 1,
|
|
@@ -1525,7 +1500,6 @@ const styles = StyleSheet.create({
|
|
|
1525
1500
|
fontWeight: '600',
|
|
1526
1501
|
marginBottom: 12
|
|
1527
1502
|
},
|
|
1528
|
-
// New styles for enhanced feature cards
|
|
1529
1503
|
featureNameRow: {
|
|
1530
1504
|
flexDirection: 'row',
|
|
1531
1505
|
alignItems: 'center',
|
|
@@ -1573,7 +1547,6 @@ const styles = StyleSheet.create({
|
|
|
1573
1547
|
fontWeight: '500',
|
|
1574
1548
|
textAlign: 'center'
|
|
1575
1549
|
},
|
|
1576
|
-
// App-specific plan styles
|
|
1577
1550
|
appSpecificBadge: {
|
|
1578
1551
|
position: 'absolute',
|
|
1579
1552
|
top: 16,
|
|
@@ -1603,7 +1576,6 @@ const styles = StyleSheet.create({
|
|
|
1603
1576
|
fontSize: 16,
|
|
1604
1577
|
fontWeight: '600'
|
|
1605
1578
|
},
|
|
1606
|
-
// App switcher styles (for development/testing)
|
|
1607
1579
|
appSwitcher: {
|
|
1608
1580
|
padding: 16,
|
|
1609
1581
|
borderBottomWidth: 1,
|