@onairos/react-native 3.1.16 → 3.1.18

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.
Files changed (207) hide show
  1. package/README.md +404 -0
  2. package/lib/commonjs/assets/images/Checkbox.svg +3 -3
  3. package/lib/commonjs/assets/images/EnochE.svg +19 -19
  4. package/lib/commonjs/assets/images/Personalityprofile.svg +3 -3
  5. package/lib/commonjs/assets/images/Personalitytraits.svg +3 -3
  6. package/lib/commonjs/assets/images/Userpreferences.svg +3 -3
  7. package/lib/commonjs/assets/images/arrow.svg +20 -20
  8. package/lib/commonjs/assets/images/basicproficon.svg +43 -43
  9. package/lib/commonjs/assets/images/basicprofile.svg +3 -3
  10. package/lib/commonjs/assets/images/checkmark.svg +4 -4
  11. package/lib/commonjs/assets/images/contentanalysis.svg +3 -3
  12. package/lib/commonjs/assets/images/contenticon.svg +23 -23
  13. package/lib/commonjs/assets/images/personalityicon.svg +18 -18
  14. package/lib/commonjs/assets/images/x-close.svg +3 -3
  15. package/lib/commonjs/components/ModalSheet.js +8 -2
  16. package/lib/commonjs/components/ModalSheet.js.map +1 -1
  17. package/lib/commonjs/components/OnairosButton.js +290 -0
  18. package/lib/commonjs/components/OnairosButton.js.map +1 -0
  19. package/lib/commonjs/components/OnairosSignInButton.js +32 -8
  20. package/lib/commonjs/components/OnairosSignInButton.js.map +1 -1
  21. package/lib/commonjs/components/UniversalOnboarding.js +4 -4
  22. package/lib/commonjs/components/WelcomeScreen.js +29 -13
  23. package/lib/commonjs/components/WelcomeScreen.js.map +1 -1
  24. package/lib/commonjs/config/api.js +2 -2
  25. package/lib/commonjs/hooks/useConnections.js +6 -6
  26. package/lib/commonjs/hooks/useUserConnections.js +10 -10
  27. package/lib/commonjs/index.js +13 -6
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/commonjs/services/apiClient.js +35 -35
  30. package/lib/commonjs/services/apiKeyService.js +99 -99
  31. package/lib/commonjs/services/authService.js +82 -82
  32. package/lib/commonjs/services/biometricPinService.js +10 -10
  33. package/lib/commonjs/services/connectedAccountsService.js +32 -32
  34. package/lib/commonjs/services/googleAuthService.js +15 -15
  35. package/lib/commonjs/services/imageCompressionService.js +15 -15
  36. package/lib/commonjs/services/jwtStorageService.js +59 -59
  37. package/lib/commonjs/services/mobileTrainingService.js +14 -14
  38. package/lib/commonjs/services/pinEncryptionService.js +10 -10
  39. package/lib/commonjs/services/pinStorageUtils.js +15 -15
  40. package/lib/commonjs/services/platformAuthService.js +47 -47
  41. package/lib/commonjs/services/storageService.js +31 -31
  42. package/lib/commonjs/services/trainingApiHelpers.js +33 -33
  43. package/lib/commonjs/services/userConnectionsService.js +24 -24
  44. package/lib/commonjs/utils/Portal.js +4 -4
  45. package/lib/commonjs/utils/api.js +24 -24
  46. package/lib/commonjs/utils/auth.js +18 -18
  47. package/lib/commonjs/utils/crypto.js +13 -13
  48. package/lib/commonjs/utils/encryption.js +12 -12
  49. package/lib/commonjs/utils/eventUtils.js +52 -52
  50. package/lib/commonjs/utils/programmaticFlow.js +16 -16
  51. package/lib/commonjs/utils/retryHelper.js +27 -27
  52. package/lib/module/assets/images/Checkbox.svg +3 -3
  53. package/lib/module/assets/images/EnochE.svg +19 -19
  54. package/lib/module/assets/images/Personalityprofile.svg +3 -3
  55. package/lib/module/assets/images/Personalitytraits.svg +3 -3
  56. package/lib/module/assets/images/Userpreferences.svg +3 -3
  57. package/lib/module/assets/images/arrow.svg +20 -20
  58. package/lib/module/assets/images/basicproficon.svg +43 -43
  59. package/lib/module/assets/images/basicprofile.svg +3 -3
  60. package/lib/module/assets/images/checkmark.svg +4 -4
  61. package/lib/module/assets/images/contentanalysis.svg +3 -3
  62. package/lib/module/assets/images/contenticon.svg +23 -23
  63. package/lib/module/assets/images/personalityicon.svg +18 -18
  64. package/lib/module/assets/images/x-close.svg +3 -3
  65. package/lib/module/components/ModalSheet.js +7 -2
  66. package/lib/module/components/ModalSheet.js.map +1 -1
  67. package/lib/module/components/OnairosButton.js +282 -0
  68. package/lib/module/components/OnairosButton.js.map +1 -0
  69. package/lib/module/components/OnairosSignInButton.js +32 -8
  70. package/lib/module/components/OnairosSignInButton.js.map +1 -1
  71. package/lib/module/components/UniversalOnboarding.js +4 -4
  72. package/lib/module/components/WelcomeScreen.js +25 -10
  73. package/lib/module/components/WelcomeScreen.js.map +1 -1
  74. package/lib/module/config/api.js +2 -2
  75. package/lib/module/hooks/useConnections.js +6 -6
  76. package/lib/module/hooks/useUserConnections.js +10 -10
  77. package/lib/module/index.js +11 -11
  78. package/lib/module/index.js.map +1 -1
  79. package/lib/module/services/apiClient.js +35 -35
  80. package/lib/module/services/apiKeyService.js +99 -99
  81. package/lib/module/services/authService.js +82 -82
  82. package/lib/module/services/biometricPinService.js +10 -10
  83. package/lib/module/services/connectedAccountsService.js +32 -32
  84. package/lib/module/services/googleAuthService.js +15 -15
  85. package/lib/module/services/imageCompressionService.js +15 -15
  86. package/lib/module/services/jwtStorageService.js +59 -59
  87. package/lib/module/services/mobileTrainingService.js +14 -14
  88. package/lib/module/services/pinEncryptionService.js +10 -10
  89. package/lib/module/services/pinStorageUtils.js +15 -15
  90. package/lib/module/services/platformAuthService.js +47 -47
  91. package/lib/module/services/storageService.js +31 -31
  92. package/lib/module/services/trainingApiHelpers.js +33 -33
  93. package/lib/module/services/userConnectionsService.js +24 -24
  94. package/lib/module/utils/Portal.js +4 -4
  95. package/lib/module/utils/api.js +24 -24
  96. package/lib/module/utils/auth.js +18 -18
  97. package/lib/module/utils/crypto.js +13 -13
  98. package/lib/module/utils/encryption.js +12 -12
  99. package/lib/module/utils/eventUtils.js +52 -52
  100. package/lib/module/utils/programmaticFlow.js +16 -16
  101. package/lib/module/utils/retryHelper.js +27 -27
  102. package/lib/typescript/components/ModalSheet.d.ts.map +1 -1
  103. package/lib/typescript/components/OnairosButton.d.ts +37 -0
  104. package/lib/typescript/components/OnairosButton.d.ts.map +1 -0
  105. package/lib/typescript/components/OnairosSignInButton.d.ts.map +1 -1
  106. package/lib/typescript/components/WelcomeScreen.d.ts.map +1 -1
  107. package/lib/typescript/index.d.ts +3 -1
  108. package/lib/typescript/index.d.ts.map +1 -1
  109. package/package.json +145 -163
  110. package/src/api/index.ts +151 -151
  111. package/src/assets/images/Checkbox.svg +3 -3
  112. package/src/assets/images/EnochE.svg +19 -19
  113. package/src/assets/images/Personalityprofile.svg +3 -3
  114. package/src/assets/images/Personalitytraits.svg +3 -3
  115. package/src/assets/images/Userpreferences.svg +3 -3
  116. package/src/assets/images/arrow.svg +20 -20
  117. package/src/assets/images/basicproficon.svg +43 -43
  118. package/src/assets/images/basicprofile.svg +3 -3
  119. package/src/assets/images/checkmark.svg +4 -4
  120. package/src/assets/images/contentanalysis.svg +3 -3
  121. package/src/assets/images/contenticon.svg +23 -23
  122. package/src/assets/images/personalityicon.svg +18 -18
  123. package/src/assets/images/x-close.svg +3 -3
  124. package/src/components/BodyText.tsx +33 -33
  125. package/src/components/BrandMark.tsx +62 -62
  126. package/src/components/CodeInput.tsx +32 -32
  127. package/src/components/DataRequestScreen.tsx +355 -355
  128. package/src/components/EmailInput.tsx +31 -31
  129. package/src/components/EmailVerificationModal.tsx +363 -363
  130. package/src/components/ExistingUserDataConfirmation.tsx +506 -506
  131. package/src/components/GoogleButton.tsx +55 -55
  132. package/src/components/HeadingGroup.tsx +49 -49
  133. package/src/components/ModalHeader.tsx +125 -125
  134. package/src/components/ModalSheet.tsx +59 -57
  135. package/src/components/Onairos.tsx +422 -422
  136. package/src/components/OnairosButton.tsx +339 -0
  137. package/src/components/OnairosSignInButton.tsx +31 -9
  138. package/src/components/Overlay.tsx +506 -506
  139. package/src/components/PersonaImage.tsx +79 -79
  140. package/src/components/PersonaLoadingScreen.tsx +201 -201
  141. package/src/components/PersonalizationConsentScreen.tsx +410 -410
  142. package/src/components/PinCreationScreen.tsx +492 -492
  143. package/src/components/PinInput.tsx +555 -555
  144. package/src/components/PlatformConnectorsStep.tsx +891 -891
  145. package/src/components/PlatformList.tsx +144 -144
  146. package/src/components/PlatformToggle.tsx +226 -226
  147. package/src/components/PrimaryButton.tsx +213 -213
  148. package/src/components/SignInMatchAnimation.tsx +225 -225
  149. package/src/components/SignInStep.tsx +217 -217
  150. package/src/components/TrainingModal.tsx +1047 -1047
  151. package/src/components/UniversalOnboarding.tsx +2887 -2887
  152. package/src/components/VerificationStep.tsx +198 -198
  153. package/src/components/WelcomeScreen.tsx +490 -473
  154. package/src/components/icons/Basicproficon.tsx +30 -30
  155. package/src/components/icons/Basicprofile.tsx +17 -17
  156. package/src/components/icons/Checkbox.tsx +17 -17
  157. package/src/components/icons/Checkmark.tsx +24 -24
  158. package/src/components/icons/Contentanalysis.tsx +17 -17
  159. package/src/components/icons/Contenticon.tsx +30 -30
  160. package/src/components/icons/EnochE.tsx +39 -39
  161. package/src/components/icons/Personalityicon.tsx +22 -22
  162. package/src/components/icons/Personalityprofile.tsx +17 -17
  163. package/src/components/icons/Personalitytraits.tsx +17 -17
  164. package/src/components/icons/Userpreferences.tsx +17 -17
  165. package/src/components/icons/index.ts +12 -12
  166. package/src/components/onboarding/OAuthWebView.tsx +232 -232
  167. package/src/config/api.ts +25 -25
  168. package/src/context/AuthContext.tsx +393 -393
  169. package/src/hooks/useConnectedAccounts.ts +138 -138
  170. package/src/hooks/useConnections.ts +161 -161
  171. package/src/hooks/useCredentials.ts +174 -174
  172. package/src/hooks/useUserConnections.ts +165 -165
  173. package/src/index.js +14 -0
  174. package/src/index.ts +99 -96
  175. package/src/services/apiClient.ts +336 -336
  176. package/src/services/apiKeyService.ts +919 -919
  177. package/src/services/authService.ts +1008 -1008
  178. package/src/services/biometricPinService.ts +192 -192
  179. package/src/services/connectedAccountsService.ts +289 -289
  180. package/src/services/googleAuthService.ts +279 -279
  181. package/src/services/imageCompressionService.ts +302 -302
  182. package/src/services/jwtStorageService.ts +256 -256
  183. package/src/services/mobileTrainingService.ts +203 -203
  184. package/src/services/pinEncryptionService.ts +75 -75
  185. package/src/services/pinStorageUtils.ts +96 -96
  186. package/src/services/platformAuthService.ts +1346 -1346
  187. package/src/services/storageService.ts +451 -451
  188. package/src/services/trainingApiHelpers.ts +66 -66
  189. package/src/services/userConnectionsService.ts +556 -556
  190. package/src/services/youtubeMigrationService.ts +453 -453
  191. package/src/theme/index.ts +239 -239
  192. package/src/types/ambient.d.ts +28 -28
  193. package/src/types/index.ts +265 -265
  194. package/src/types/node-fix.d.ts +18 -18
  195. package/src/types/node-override.d.ts +23 -23
  196. package/src/types/opacity.d.ts +15 -15
  197. package/src/types/types.d.ts +17 -17
  198. package/src/utils/Portal.tsx +82 -82
  199. package/src/utils/api.js +111 -111
  200. package/src/utils/auth.js +103 -103
  201. package/src/utils/crypto.js +59 -59
  202. package/src/utils/encryption.ts +68 -68
  203. package/src/utils/eventUtils.ts +302 -302
  204. package/src/utils/haptics.ts +58 -58
  205. package/src/utils/imagePreloader.ts +2 -2
  206. package/src/utils/programmaticFlow.ts +112 -112
  207. package/src/utils/retryHelper.ts +274 -274
@@ -1,507 +1,507 @@
1
- import React, { useState, useEffect } from 'react';
2
- import {
3
- View,
4
- Text,
5
- StyleSheet,
6
- TouchableOpacity,
7
- ScrollView,
8
- Dimensions,
9
- ActivityIndicator,
10
- Alert,
11
- } from 'react-native';
12
- import LinearGradient from 'react-native-linear-gradient';
13
- import { triggerHaptic, HapticType } from '../utils/haptics';
14
-
15
- const { width, height } = Dimensions.get('window');
16
-
17
- interface ExistingUserDataConfirmationProps {
18
- visible: boolean;
19
- onConfirm: () => void;
20
- onCancel: () => void;
21
- onAddMoreData: () => void;
22
- accountInfo: any;
23
- userEmail: string;
24
- }
25
-
26
- interface ConnectionInfo {
27
- platform: string;
28
- connectedAt: string;
29
- status: 'active' | 'inactive' | 'expired';
30
- hasData: boolean;
31
- displayName?: string;
32
- }
33
-
34
- export const ExistingUserDataConfirmation: React.FC<ExistingUserDataConfirmationProps> = ({
35
- visible,
36
- onConfirm,
37
- onCancel,
38
- onAddMoreData,
39
- accountInfo,
40
- userEmail,
41
- }) => {
42
- const [isLoading, setIsLoading] = useState(false);
43
- const [connections, setConnections] = useState<ConnectionInfo[]>([]);
44
- const [dataStats, setDataStats] = useState({
45
- connectionsCount: 0,
46
- traitsCount: 0,
47
- hasPersonalityData: false,
48
- hasTrainedModel: false,
49
- hasAvatar: false,
50
- });
51
-
52
- useEffect(() => {
53
- if (visible && accountInfo) {
54
- parseAccountInfo();
55
- }
56
- }, [visible, accountInfo]);
57
-
58
- const parseAccountInfo = () => {
59
- console.log('🔍 Parsing account info for existing user:', accountInfo);
60
-
61
- // Parse existing user data from backend response
62
- const existingData = accountInfo.existingUserData || {};
63
- const summary = existingData.summary || {};
64
- const connectionsList = existingData.connections || [];
65
-
66
- // Set data statistics
67
- setDataStats({
68
- connectionsCount: summary.connectionsCount || 0,
69
- traitsCount: summary.traitsCount || 0,
70
- hasPersonalityData: summary.hasPersonalityData || false,
71
- hasTrainedModel: summary.hasTrainedModel || false,
72
- hasAvatar: summary.hasAvatar || false,
73
- });
74
-
75
- // Parse connections
76
- const parsedConnections: ConnectionInfo[] = connectionsList.map((conn: any) => ({
77
- platform: conn.platform,
78
- connectedAt: conn.connectedAt,
79
- status: conn.status,
80
- hasData: conn.hasData,
81
- displayName: conn.displayName || conn.platform,
82
- }));
83
-
84
- setConnections(parsedConnections);
85
-
86
- console.log('📊 Parsed data stats:', dataStats);
87
- console.log('🔗 Parsed connections:', parsedConnections);
88
- };
89
-
90
- const handleConfirm = async () => {
91
- setIsLoading(true);
92
- triggerHaptic(HapticType.SUCCESS);
93
-
94
- try {
95
- // Small delay for better UX
96
- await new Promise<void>(resolve => setTimeout(() => resolve(), 500));
97
- onConfirm();
98
- } finally {
99
- setIsLoading(false);
100
- }
101
- };
102
-
103
- const handleCancel = () => {
104
- triggerHaptic(HapticType.BUTTON_PRESS);
105
- onCancel();
106
- };
107
-
108
- const handleAddMoreData = () => {
109
- triggerHaptic(HapticType.BUTTON_PRESS);
110
- onAddMoreData();
111
- };
112
-
113
- const getPlatformEmoji = (platform: string): string => {
114
- const emojiMap: { [key: string]: string } = {
115
- 'YouTube': '📺',
116
- 'Reddit': '🔴',
117
- 'Instagram': '📸',
118
- 'LinkedIn': '💼',
119
- 'Pinterest': '📌',
120
- 'Facebook': '📘',
121
- 'Gmail': '📧',
122
- 'Email': '✉️',
123
- };
124
- return emojiMap[platform] || '🔗';
125
- };
126
-
127
- const getStatusColor = (status: string): string => {
128
- switch (status) {
129
- case 'active': return '#10B981';
130
- case 'expired': return '#F59E0B';
131
- case 'inactive': return '#6B7280';
132
- default: return '#6B7280';
133
- }
134
- };
135
-
136
- if (!visible) return null;
137
-
138
- return (
139
- <View style={styles.overlay}>
140
- <View style={styles.container}>
141
- <ScrollView style={styles.scrollView} showsVerticalScrollIndicator={false}>
142
- {/* Header */}
143
- <View style={styles.header}>
144
- <Text style={styles.headerTitle}>Welcome Back!</Text>
145
- <Text style={styles.headerSubtitle}>
146
- We found your existing Onairos account
147
- </Text>
148
- </View>
149
-
150
- {/* User Info */}
151
- <View style={styles.userInfoContainer}>
152
- <View style={styles.userInfoRow}>
153
- <Text style={styles.userInfoLabel}>Email:</Text>
154
- <Text style={styles.userInfoValue}>{userEmail}</Text>
155
- </View>
156
- <View style={styles.userInfoRow}>
157
- <Text style={styles.userInfoLabel}>Account Status:</Text>
158
- <Text style={[styles.userInfoValue, { color: '#10B981' }]}>Verified</Text>
159
- </View>
160
- </View>
161
-
162
- {/* Data Summary */}
163
- <View style={styles.dataSummaryContainer}>
164
- <Text style={styles.sectionTitle}>Your Existing Data</Text>
165
-
166
- <View style={styles.statsGrid}>
167
- <View style={styles.statItem}>
168
- <Text style={styles.statNumber}>{dataStats.connectionsCount}</Text>
169
- <Text style={styles.statLabel}>Connections</Text>
170
- </View>
171
- <View style={styles.statItem}>
172
- <Text style={styles.statNumber}>{dataStats.traitsCount}</Text>
173
- <Text style={styles.statLabel}>Traits</Text>
174
- </View>
175
- <View style={styles.statItem}>
176
- <Text style={styles.statNumber}>{dataStats.hasTrainedModel ? '✅' : '❌'}</Text>
177
- <Text style={styles.statLabel}>AI Model</Text>
178
- </View>
179
- </View>
180
- </View>
181
-
182
- {/* Connected Platforms */}
183
- {connections.length > 0 && (
184
- <View style={styles.connectionsContainer}>
185
- <Text style={styles.sectionTitle}>Connected Platforms</Text>
186
-
187
- {connections.map((connection, index) => (
188
- <View key={index} style={styles.connectionItem}>
189
- <View style={styles.connectionLeft}>
190
- <Text style={styles.connectionEmoji}>
191
- {getPlatformEmoji(connection.platform)}
192
- </Text>
193
- <View style={styles.connectionInfo}>
194
- <Text style={styles.connectionName}>{connection.displayName}</Text>
195
- <Text style={styles.connectionDate}>
196
- Connected {new Date(connection.connectedAt).toLocaleDateString()}
197
- </Text>
198
- </View>
199
- </View>
200
- <View style={styles.connectionRight}>
201
- <View style={[
202
- styles.statusDot,
203
- { backgroundColor: getStatusColor(connection.status) }
204
- ]} />
205
- <Text style={[
206
- styles.statusText,
207
- { color: getStatusColor(connection.status) }
208
- ]}>
209
- {connection.status}
210
- </Text>
211
- </View>
212
- </View>
213
- ))}
214
- </View>
215
- )}
216
-
217
- {/* Data Usage Explanation */}
218
- <View style={styles.explanationContainer}>
219
- <Text style={styles.explanationTitle}>Share Your Data with Enoch?</Text>
220
- <Text style={styles.explanationText}>
221
- Your existing personality data and connected accounts will be used to:
222
- </Text>
223
- <View style={styles.benefitsList}>
224
- <Text style={styles.benefitItem}>• Create personalized experiences</Text>
225
- <Text style={styles.benefitItem}>• Match you with compatible people</Text>
226
- <Text style={styles.benefitItem}>• Provide AI-powered insights</Text>
227
- <Text style={styles.benefitItem}>• Enhance your social connections</Text>
228
- </View>
229
- <Text style={styles.privacyNote}>
230
- Your data remains secure and encrypted. You can manage your privacy settings anytime.
231
- </Text>
232
- </View>
233
-
234
- {/* Action Buttons */}
235
- <View style={styles.actionButtonsContainer}>
236
- {/* Add More Data Button */}
237
- <TouchableOpacity
238
- style={styles.addMoreButton}
239
- onPress={handleAddMoreData}
240
- activeOpacity={0.8}
241
- >
242
- <Text style={styles.addMoreButtonText}>+ Add More Data</Text>
243
- </TouchableOpacity>
244
-
245
- {/* Main Action Buttons */}
246
- <View style={styles.mainButtons}>
247
- <TouchableOpacity
248
- style={styles.cancelButton}
249
- onPress={handleCancel}
250
- activeOpacity={0.8}
251
- >
252
- <Text style={styles.cancelButtonText}>Not Now</Text>
253
- </TouchableOpacity>
254
-
255
- <TouchableOpacity
256
- style={styles.confirmButton}
257
- onPress={handleConfirm}
258
- activeOpacity={0.8}
259
- disabled={isLoading}
260
- >
261
- <LinearGradient
262
- colors={['#D4A536', '#B8941F']}
263
- style={styles.confirmButtonGradient}
264
- >
265
- {isLoading ? (
266
- <ActivityIndicator color="#FFFFFF" size="small" />
267
- ) : (
268
- <Text style={styles.confirmButtonText}>Share Data</Text>
269
- )}
270
- </LinearGradient>
271
- </TouchableOpacity>
272
- </View>
273
- </View>
274
- </ScrollView>
275
- </View>
276
- </View>
277
- );
278
- };
279
-
280
- const styles = StyleSheet.create({
281
- overlay: {
282
- position: 'absolute',
283
- top: 0,
284
- left: 0,
285
- right: 0,
286
- bottom: 0,
287
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
288
- justifyContent: 'center',
289
- alignItems: 'center',
290
- zIndex: 1000,
291
- },
292
- container: {
293
- backgroundColor: '#FFFFFF',
294
- borderRadius: 20,
295
- width: width * 0.9,
296
- maxHeight: height * 0.8,
297
- shadowColor: '#000',
298
- shadowOffset: { width: 0, height: 4 },
299
- shadowOpacity: 0.25,
300
- shadowRadius: 12,
301
- elevation: 10,
302
- },
303
- scrollView: {
304
- flex: 1,
305
- },
306
- header: {
307
- padding: 24,
308
- alignItems: 'center',
309
- borderBottomWidth: 1,
310
- borderBottomColor: '#F3F4F6',
311
- },
312
- headerTitle: {
313
- fontSize: 24,
314
- fontWeight: '700',
315
- color: '#1F2937',
316
- marginBottom: 8,
317
- },
318
- headerSubtitle: {
319
- fontSize: 16,
320
- color: '#6B7280',
321
- textAlign: 'center',
322
- },
323
- userInfoContainer: {
324
- padding: 20,
325
- backgroundColor: '#F9FAFB',
326
- marginHorizontal: 20,
327
- marginTop: 20,
328
- borderRadius: 12,
329
- },
330
- userInfoRow: {
331
- flexDirection: 'row',
332
- justifyContent: 'space-between',
333
- alignItems: 'center',
334
- marginBottom: 8,
335
- },
336
- userInfoLabel: {
337
- fontSize: 14,
338
- color: '#6B7280',
339
- fontWeight: '500',
340
- },
341
- userInfoValue: {
342
- fontSize: 14,
343
- color: '#1F2937',
344
- fontWeight: '600',
345
- },
346
- dataSummaryContainer: {
347
- padding: 20,
348
- },
349
- sectionTitle: {
350
- fontSize: 18,
351
- fontWeight: '600',
352
- color: '#1F2937',
353
- marginBottom: 16,
354
- },
355
- statsGrid: {
356
- flexDirection: 'row',
357
- justifyContent: 'space-around',
358
- backgroundColor: '#F9FAFB',
359
- borderRadius: 12,
360
- padding: 16,
361
- },
362
- statItem: {
363
- alignItems: 'center',
364
- },
365
- statNumber: {
366
- fontSize: 24,
367
- fontWeight: '700',
368
- color: '#D4A536',
369
- marginBottom: 4,
370
- },
371
- statLabel: {
372
- fontSize: 12,
373
- color: '#6B7280',
374
- fontWeight: '500',
375
- },
376
- connectionsContainer: {
377
- padding: 20,
378
- },
379
- connectionItem: {
380
- flexDirection: 'row',
381
- alignItems: 'center',
382
- justifyContent: 'space-between',
383
- padding: 16,
384
- backgroundColor: '#F9FAFB',
385
- borderRadius: 12,
386
- marginBottom: 8,
387
- },
388
- connectionLeft: {
389
- flexDirection: 'row',
390
- alignItems: 'center',
391
- flex: 1,
392
- },
393
- connectionEmoji: {
394
- fontSize: 24,
395
- marginRight: 12,
396
- },
397
- connectionInfo: {
398
- flex: 1,
399
- },
400
- connectionName: {
401
- fontSize: 16,
402
- fontWeight: '600',
403
- color: '#1F2937',
404
- marginBottom: 2,
405
- },
406
- connectionDate: {
407
- fontSize: 12,
408
- color: '#6B7280',
409
- },
410
- connectionRight: {
411
- flexDirection: 'row',
412
- alignItems: 'center',
413
- },
414
- statusDot: {
415
- width: 8,
416
- height: 8,
417
- borderRadius: 4,
418
- marginRight: 6,
419
- },
420
- statusText: {
421
- fontSize: 12,
422
- fontWeight: '500',
423
- textTransform: 'capitalize',
424
- },
425
- explanationContainer: {
426
- padding: 20,
427
- backgroundColor: '#F0F9FF',
428
- marginHorizontal: 20,
429
- borderRadius: 12,
430
- marginBottom: 20,
431
- },
432
- explanationTitle: {
433
- fontSize: 16,
434
- fontWeight: '600',
435
- color: '#1F2937',
436
- marginBottom: 12,
437
- },
438
- explanationText: {
439
- fontSize: 14,
440
- color: '#4B5563',
441
- marginBottom: 12,
442
- lineHeight: 20,
443
- },
444
- benefitsList: {
445
- marginBottom: 12,
446
- },
447
- benefitItem: {
448
- fontSize: 14,
449
- color: '#4B5563',
450
- marginBottom: 4,
451
- lineHeight: 20,
452
- },
453
- privacyNote: {
454
- fontSize: 12,
455
- color: '#6B7280',
456
- fontStyle: 'italic',
457
- lineHeight: 16,
458
- },
459
- actionButtonsContainer: {
460
- padding: 20,
461
- },
462
- addMoreButton: {
463
- backgroundColor: '#F3F4F6',
464
- borderRadius: 12,
465
- padding: 16,
466
- alignItems: 'center',
467
- marginBottom: 16,
468
- borderWidth: 1,
469
- borderColor: '#D1D5DB',
470
- },
471
- addMoreButtonText: {
472
- fontSize: 16,
473
- color: '#4B5563',
474
- fontWeight: '600',
475
- },
476
- mainButtons: {
477
- flexDirection: 'row',
478
- gap: 12,
479
- },
480
- cancelButton: {
481
- flex: 1,
482
- backgroundColor: '#F3F4F6',
483
- borderRadius: 12,
484
- padding: 16,
485
- alignItems: 'center',
486
- },
487
- cancelButtonText: {
488
- fontSize: 16,
489
- color: '#6B7280',
490
- fontWeight: '600',
491
- },
492
- confirmButton: {
493
- flex: 2,
494
- borderRadius: 12,
495
- overflow: 'hidden',
496
- },
497
- confirmButtonGradient: {
498
- padding: 16,
499
- alignItems: 'center',
500
- justifyContent: 'center',
501
- },
502
- confirmButtonText: {
503
- fontSize: 16,
504
- color: '#FFFFFF',
505
- fontWeight: '700',
506
- },
1
+ import React, { useState, useEffect } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ TouchableOpacity,
7
+ ScrollView,
8
+ Dimensions,
9
+ ActivityIndicator,
10
+ Alert,
11
+ } from 'react-native';
12
+ import LinearGradient from 'react-native-linear-gradient';
13
+ import { triggerHaptic, HapticType } from '../utils/haptics';
14
+
15
+ const { width, height } = Dimensions.get('window');
16
+
17
+ interface ExistingUserDataConfirmationProps {
18
+ visible: boolean;
19
+ onConfirm: () => void;
20
+ onCancel: () => void;
21
+ onAddMoreData: () => void;
22
+ accountInfo: any;
23
+ userEmail: string;
24
+ }
25
+
26
+ interface ConnectionInfo {
27
+ platform: string;
28
+ connectedAt: string;
29
+ status: 'active' | 'inactive' | 'expired';
30
+ hasData: boolean;
31
+ displayName?: string;
32
+ }
33
+
34
+ export const ExistingUserDataConfirmation: React.FC<ExistingUserDataConfirmationProps> = ({
35
+ visible,
36
+ onConfirm,
37
+ onCancel,
38
+ onAddMoreData,
39
+ accountInfo,
40
+ userEmail,
41
+ }) => {
42
+ const [isLoading, setIsLoading] = useState(false);
43
+ const [connections, setConnections] = useState<ConnectionInfo[]>([]);
44
+ const [dataStats, setDataStats] = useState({
45
+ connectionsCount: 0,
46
+ traitsCount: 0,
47
+ hasPersonalityData: false,
48
+ hasTrainedModel: false,
49
+ hasAvatar: false,
50
+ });
51
+
52
+ useEffect(() => {
53
+ if (visible && accountInfo) {
54
+ parseAccountInfo();
55
+ }
56
+ }, [visible, accountInfo]);
57
+
58
+ const parseAccountInfo = () => {
59
+ console.log('🔍 Parsing account info for existing user:', accountInfo);
60
+
61
+ // Parse existing user data from backend response
62
+ const existingData = accountInfo.existingUserData || {};
63
+ const summary = existingData.summary || {};
64
+ const connectionsList = existingData.connections || [];
65
+
66
+ // Set data statistics
67
+ setDataStats({
68
+ connectionsCount: summary.connectionsCount || 0,
69
+ traitsCount: summary.traitsCount || 0,
70
+ hasPersonalityData: summary.hasPersonalityData || false,
71
+ hasTrainedModel: summary.hasTrainedModel || false,
72
+ hasAvatar: summary.hasAvatar || false,
73
+ });
74
+
75
+ // Parse connections
76
+ const parsedConnections: ConnectionInfo[] = connectionsList.map((conn: any) => ({
77
+ platform: conn.platform,
78
+ connectedAt: conn.connectedAt,
79
+ status: conn.status,
80
+ hasData: conn.hasData,
81
+ displayName: conn.displayName || conn.platform,
82
+ }));
83
+
84
+ setConnections(parsedConnections);
85
+
86
+ console.log('📊 Parsed data stats:', dataStats);
87
+ console.log('🔗 Parsed connections:', parsedConnections);
88
+ };
89
+
90
+ const handleConfirm = async () => {
91
+ setIsLoading(true);
92
+ triggerHaptic(HapticType.SUCCESS);
93
+
94
+ try {
95
+ // Small delay for better UX
96
+ await new Promise<void>(resolve => setTimeout(() => resolve(), 500));
97
+ onConfirm();
98
+ } finally {
99
+ setIsLoading(false);
100
+ }
101
+ };
102
+
103
+ const handleCancel = () => {
104
+ triggerHaptic(HapticType.BUTTON_PRESS);
105
+ onCancel();
106
+ };
107
+
108
+ const handleAddMoreData = () => {
109
+ triggerHaptic(HapticType.BUTTON_PRESS);
110
+ onAddMoreData();
111
+ };
112
+
113
+ const getPlatformEmoji = (platform: string): string => {
114
+ const emojiMap: { [key: string]: string } = {
115
+ 'YouTube': '📺',
116
+ 'Reddit': '🔴',
117
+ 'Instagram': '📸',
118
+ 'LinkedIn': '💼',
119
+ 'Pinterest': '📌',
120
+ 'Facebook': '📘',
121
+ 'Gmail': '📧',
122
+ 'Email': '✉️',
123
+ };
124
+ return emojiMap[platform] || '🔗';
125
+ };
126
+
127
+ const getStatusColor = (status: string): string => {
128
+ switch (status) {
129
+ case 'active': return '#10B981';
130
+ case 'expired': return '#F59E0B';
131
+ case 'inactive': return '#6B7280';
132
+ default: return '#6B7280';
133
+ }
134
+ };
135
+
136
+ if (!visible) return null;
137
+
138
+ return (
139
+ <View style={styles.overlay}>
140
+ <View style={styles.container}>
141
+ <ScrollView style={styles.scrollView} showsVerticalScrollIndicator={false}>
142
+ {/* Header */}
143
+ <View style={styles.header}>
144
+ <Text style={styles.headerTitle}>Welcome Back!</Text>
145
+ <Text style={styles.headerSubtitle}>
146
+ We found your existing Onairos account
147
+ </Text>
148
+ </View>
149
+
150
+ {/* User Info */}
151
+ <View style={styles.userInfoContainer}>
152
+ <View style={styles.userInfoRow}>
153
+ <Text style={styles.userInfoLabel}>Email:</Text>
154
+ <Text style={styles.userInfoValue}>{userEmail}</Text>
155
+ </View>
156
+ <View style={styles.userInfoRow}>
157
+ <Text style={styles.userInfoLabel}>Account Status:</Text>
158
+ <Text style={[styles.userInfoValue, { color: '#10B981' }]}>Verified</Text>
159
+ </View>
160
+ </View>
161
+
162
+ {/* Data Summary */}
163
+ <View style={styles.dataSummaryContainer}>
164
+ <Text style={styles.sectionTitle}>Your Existing Data</Text>
165
+
166
+ <View style={styles.statsGrid}>
167
+ <View style={styles.statItem}>
168
+ <Text style={styles.statNumber}>{dataStats.connectionsCount}</Text>
169
+ <Text style={styles.statLabel}>Connections</Text>
170
+ </View>
171
+ <View style={styles.statItem}>
172
+ <Text style={styles.statNumber}>{dataStats.traitsCount}</Text>
173
+ <Text style={styles.statLabel}>Traits</Text>
174
+ </View>
175
+ <View style={styles.statItem}>
176
+ <Text style={styles.statNumber}>{dataStats.hasTrainedModel ? '✅' : '❌'}</Text>
177
+ <Text style={styles.statLabel}>AI Model</Text>
178
+ </View>
179
+ </View>
180
+ </View>
181
+
182
+ {/* Connected Platforms */}
183
+ {connections.length > 0 && (
184
+ <View style={styles.connectionsContainer}>
185
+ <Text style={styles.sectionTitle}>Connected Platforms</Text>
186
+
187
+ {connections.map((connection, index) => (
188
+ <View key={index} style={styles.connectionItem}>
189
+ <View style={styles.connectionLeft}>
190
+ <Text style={styles.connectionEmoji}>
191
+ {getPlatformEmoji(connection.platform)}
192
+ </Text>
193
+ <View style={styles.connectionInfo}>
194
+ <Text style={styles.connectionName}>{connection.displayName}</Text>
195
+ <Text style={styles.connectionDate}>
196
+ Connected {new Date(connection.connectedAt).toLocaleDateString()}
197
+ </Text>
198
+ </View>
199
+ </View>
200
+ <View style={styles.connectionRight}>
201
+ <View style={[
202
+ styles.statusDot,
203
+ { backgroundColor: getStatusColor(connection.status) }
204
+ ]} />
205
+ <Text style={[
206
+ styles.statusText,
207
+ { color: getStatusColor(connection.status) }
208
+ ]}>
209
+ {connection.status}
210
+ </Text>
211
+ </View>
212
+ </View>
213
+ ))}
214
+ </View>
215
+ )}
216
+
217
+ {/* Data Usage Explanation */}
218
+ <View style={styles.explanationContainer}>
219
+ <Text style={styles.explanationTitle}>Share Your Data with Enoch?</Text>
220
+ <Text style={styles.explanationText}>
221
+ Your existing personality data and connected accounts will be used to:
222
+ </Text>
223
+ <View style={styles.benefitsList}>
224
+ <Text style={styles.benefitItem}>• Create personalized experiences</Text>
225
+ <Text style={styles.benefitItem}>• Match you with compatible people</Text>
226
+ <Text style={styles.benefitItem}>• Provide AI-powered insights</Text>
227
+ <Text style={styles.benefitItem}>• Enhance your social connections</Text>
228
+ </View>
229
+ <Text style={styles.privacyNote}>
230
+ Your data remains secure and encrypted. You can manage your privacy settings anytime.
231
+ </Text>
232
+ </View>
233
+
234
+ {/* Action Buttons */}
235
+ <View style={styles.actionButtonsContainer}>
236
+ {/* Add More Data Button */}
237
+ <TouchableOpacity
238
+ style={styles.addMoreButton}
239
+ onPress={handleAddMoreData}
240
+ activeOpacity={0.8}
241
+ >
242
+ <Text style={styles.addMoreButtonText}>+ Add More Data</Text>
243
+ </TouchableOpacity>
244
+
245
+ {/* Main Action Buttons */}
246
+ <View style={styles.mainButtons}>
247
+ <TouchableOpacity
248
+ style={styles.cancelButton}
249
+ onPress={handleCancel}
250
+ activeOpacity={0.8}
251
+ >
252
+ <Text style={styles.cancelButtonText}>Not Now</Text>
253
+ </TouchableOpacity>
254
+
255
+ <TouchableOpacity
256
+ style={styles.confirmButton}
257
+ onPress={handleConfirm}
258
+ activeOpacity={0.8}
259
+ disabled={isLoading}
260
+ >
261
+ <LinearGradient
262
+ colors={['#D4A536', '#B8941F']}
263
+ style={styles.confirmButtonGradient}
264
+ >
265
+ {isLoading ? (
266
+ <ActivityIndicator color="#FFFFFF" size="small" />
267
+ ) : (
268
+ <Text style={styles.confirmButtonText}>Share Data</Text>
269
+ )}
270
+ </LinearGradient>
271
+ </TouchableOpacity>
272
+ </View>
273
+ </View>
274
+ </ScrollView>
275
+ </View>
276
+ </View>
277
+ );
278
+ };
279
+
280
+ const styles = StyleSheet.create({
281
+ overlay: {
282
+ position: 'absolute',
283
+ top: 0,
284
+ left: 0,
285
+ right: 0,
286
+ bottom: 0,
287
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
288
+ justifyContent: 'center',
289
+ alignItems: 'center',
290
+ zIndex: 1000,
291
+ },
292
+ container: {
293
+ backgroundColor: '#FFFFFF',
294
+ borderRadius: 20,
295
+ width: width * 0.9,
296
+ maxHeight: height * 0.8,
297
+ shadowColor: '#000',
298
+ shadowOffset: { width: 0, height: 4 },
299
+ shadowOpacity: 0.25,
300
+ shadowRadius: 12,
301
+ elevation: 10,
302
+ },
303
+ scrollView: {
304
+ flex: 1,
305
+ },
306
+ header: {
307
+ padding: 24,
308
+ alignItems: 'center',
309
+ borderBottomWidth: 1,
310
+ borderBottomColor: '#F3F4F6',
311
+ },
312
+ headerTitle: {
313
+ fontSize: 24,
314
+ fontWeight: '700',
315
+ color: '#1F2937',
316
+ marginBottom: 8,
317
+ },
318
+ headerSubtitle: {
319
+ fontSize: 16,
320
+ color: '#6B7280',
321
+ textAlign: 'center',
322
+ },
323
+ userInfoContainer: {
324
+ padding: 20,
325
+ backgroundColor: '#F9FAFB',
326
+ marginHorizontal: 20,
327
+ marginTop: 20,
328
+ borderRadius: 12,
329
+ },
330
+ userInfoRow: {
331
+ flexDirection: 'row',
332
+ justifyContent: 'space-between',
333
+ alignItems: 'center',
334
+ marginBottom: 8,
335
+ },
336
+ userInfoLabel: {
337
+ fontSize: 14,
338
+ color: '#6B7280',
339
+ fontWeight: '500',
340
+ },
341
+ userInfoValue: {
342
+ fontSize: 14,
343
+ color: '#1F2937',
344
+ fontWeight: '600',
345
+ },
346
+ dataSummaryContainer: {
347
+ padding: 20,
348
+ },
349
+ sectionTitle: {
350
+ fontSize: 18,
351
+ fontWeight: '600',
352
+ color: '#1F2937',
353
+ marginBottom: 16,
354
+ },
355
+ statsGrid: {
356
+ flexDirection: 'row',
357
+ justifyContent: 'space-around',
358
+ backgroundColor: '#F9FAFB',
359
+ borderRadius: 12,
360
+ padding: 16,
361
+ },
362
+ statItem: {
363
+ alignItems: 'center',
364
+ },
365
+ statNumber: {
366
+ fontSize: 24,
367
+ fontWeight: '700',
368
+ color: '#D4A536',
369
+ marginBottom: 4,
370
+ },
371
+ statLabel: {
372
+ fontSize: 12,
373
+ color: '#6B7280',
374
+ fontWeight: '500',
375
+ },
376
+ connectionsContainer: {
377
+ padding: 20,
378
+ },
379
+ connectionItem: {
380
+ flexDirection: 'row',
381
+ alignItems: 'center',
382
+ justifyContent: 'space-between',
383
+ padding: 16,
384
+ backgroundColor: '#F9FAFB',
385
+ borderRadius: 12,
386
+ marginBottom: 8,
387
+ },
388
+ connectionLeft: {
389
+ flexDirection: 'row',
390
+ alignItems: 'center',
391
+ flex: 1,
392
+ },
393
+ connectionEmoji: {
394
+ fontSize: 24,
395
+ marginRight: 12,
396
+ },
397
+ connectionInfo: {
398
+ flex: 1,
399
+ },
400
+ connectionName: {
401
+ fontSize: 16,
402
+ fontWeight: '600',
403
+ color: '#1F2937',
404
+ marginBottom: 2,
405
+ },
406
+ connectionDate: {
407
+ fontSize: 12,
408
+ color: '#6B7280',
409
+ },
410
+ connectionRight: {
411
+ flexDirection: 'row',
412
+ alignItems: 'center',
413
+ },
414
+ statusDot: {
415
+ width: 8,
416
+ height: 8,
417
+ borderRadius: 4,
418
+ marginRight: 6,
419
+ },
420
+ statusText: {
421
+ fontSize: 12,
422
+ fontWeight: '500',
423
+ textTransform: 'capitalize',
424
+ },
425
+ explanationContainer: {
426
+ padding: 20,
427
+ backgroundColor: '#F0F9FF',
428
+ marginHorizontal: 20,
429
+ borderRadius: 12,
430
+ marginBottom: 20,
431
+ },
432
+ explanationTitle: {
433
+ fontSize: 16,
434
+ fontWeight: '600',
435
+ color: '#1F2937',
436
+ marginBottom: 12,
437
+ },
438
+ explanationText: {
439
+ fontSize: 14,
440
+ color: '#4B5563',
441
+ marginBottom: 12,
442
+ lineHeight: 20,
443
+ },
444
+ benefitsList: {
445
+ marginBottom: 12,
446
+ },
447
+ benefitItem: {
448
+ fontSize: 14,
449
+ color: '#4B5563',
450
+ marginBottom: 4,
451
+ lineHeight: 20,
452
+ },
453
+ privacyNote: {
454
+ fontSize: 12,
455
+ color: '#6B7280',
456
+ fontStyle: 'italic',
457
+ lineHeight: 16,
458
+ },
459
+ actionButtonsContainer: {
460
+ padding: 20,
461
+ },
462
+ addMoreButton: {
463
+ backgroundColor: '#F3F4F6',
464
+ borderRadius: 12,
465
+ padding: 16,
466
+ alignItems: 'center',
467
+ marginBottom: 16,
468
+ borderWidth: 1,
469
+ borderColor: '#D1D5DB',
470
+ },
471
+ addMoreButtonText: {
472
+ fontSize: 16,
473
+ color: '#4B5563',
474
+ fontWeight: '600',
475
+ },
476
+ mainButtons: {
477
+ flexDirection: 'row',
478
+ gap: 12,
479
+ },
480
+ cancelButton: {
481
+ flex: 1,
482
+ backgroundColor: '#F3F4F6',
483
+ borderRadius: 12,
484
+ padding: 16,
485
+ alignItems: 'center',
486
+ },
487
+ cancelButtonText: {
488
+ fontSize: 16,
489
+ color: '#6B7280',
490
+ fontWeight: '600',
491
+ },
492
+ confirmButton: {
493
+ flex: 2,
494
+ borderRadius: 12,
495
+ overflow: 'hidden',
496
+ },
497
+ confirmButtonGradient: {
498
+ padding: 16,
499
+ alignItems: 'center',
500
+ justifyContent: 'center',
501
+ },
502
+ confirmButtonText: {
503
+ fontSize: 16,
504
+ color: '#FFFFFF',
505
+ fontWeight: '700',
506
+ },
507
507
  });