@onairos/react-native 3.1.16 → 3.1.17

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 (198) 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/OnairosButton.js +290 -0
  16. package/lib/commonjs/components/OnairosButton.js.map +1 -0
  17. package/lib/commonjs/components/OnairosSignInButton.js +30 -8
  18. package/lib/commonjs/components/OnairosSignInButton.js.map +1 -1
  19. package/lib/commonjs/components/UniversalOnboarding.js +4 -4
  20. package/lib/commonjs/config/api.js +2 -2
  21. package/lib/commonjs/hooks/useConnections.js +6 -6
  22. package/lib/commonjs/hooks/useUserConnections.js +10 -10
  23. package/lib/commonjs/index.js +9 -10
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/services/apiClient.js +35 -35
  26. package/lib/commonjs/services/apiKeyService.js +99 -99
  27. package/lib/commonjs/services/authService.js +82 -82
  28. package/lib/commonjs/services/biometricPinService.js +10 -10
  29. package/lib/commonjs/services/connectedAccountsService.js +32 -32
  30. package/lib/commonjs/services/googleAuthService.js +15 -15
  31. package/lib/commonjs/services/imageCompressionService.js +15 -15
  32. package/lib/commonjs/services/jwtStorageService.js +59 -59
  33. package/lib/commonjs/services/mobileTrainingService.js +14 -14
  34. package/lib/commonjs/services/pinEncryptionService.js +10 -10
  35. package/lib/commonjs/services/pinStorageUtils.js +15 -15
  36. package/lib/commonjs/services/platformAuthService.js +47 -47
  37. package/lib/commonjs/services/storageService.js +31 -31
  38. package/lib/commonjs/services/trainingApiHelpers.js +33 -33
  39. package/lib/commonjs/services/userConnectionsService.js +24 -24
  40. package/lib/commonjs/utils/Portal.js +4 -4
  41. package/lib/commonjs/utils/api.js +24 -24
  42. package/lib/commonjs/utils/auth.js +18 -18
  43. package/lib/commonjs/utils/crypto.js +13 -13
  44. package/lib/commonjs/utils/encryption.js +12 -12
  45. package/lib/commonjs/utils/eventUtils.js +52 -52
  46. package/lib/commonjs/utils/programmaticFlow.js +16 -16
  47. package/lib/commonjs/utils/retryHelper.js +27 -27
  48. package/lib/module/assets/images/Checkbox.svg +3 -3
  49. package/lib/module/assets/images/EnochE.svg +19 -19
  50. package/lib/module/assets/images/Personalityprofile.svg +3 -3
  51. package/lib/module/assets/images/Personalitytraits.svg +3 -3
  52. package/lib/module/assets/images/Userpreferences.svg +3 -3
  53. package/lib/module/assets/images/arrow.svg +20 -20
  54. package/lib/module/assets/images/basicproficon.svg +43 -43
  55. package/lib/module/assets/images/basicprofile.svg +3 -3
  56. package/lib/module/assets/images/checkmark.svg +4 -4
  57. package/lib/module/assets/images/contentanalysis.svg +3 -3
  58. package/lib/module/assets/images/contenticon.svg +23 -23
  59. package/lib/module/assets/images/personalityicon.svg +18 -18
  60. package/lib/module/assets/images/x-close.svg +3 -3
  61. package/lib/module/components/OnairosButton.js +282 -0
  62. package/lib/module/components/OnairosButton.js.map +1 -0
  63. package/lib/module/components/OnairosSignInButton.js +30 -8
  64. package/lib/module/components/OnairosSignInButton.js.map +1 -1
  65. package/lib/module/components/UniversalOnboarding.js +4 -4
  66. package/lib/module/config/api.js +2 -2
  67. package/lib/module/hooks/useConnections.js +6 -6
  68. package/lib/module/hooks/useUserConnections.js +10 -10
  69. package/lib/module/index.js +8 -10
  70. package/lib/module/index.js.map +1 -1
  71. package/lib/module/services/apiClient.js +35 -35
  72. package/lib/module/services/apiKeyService.js +99 -99
  73. package/lib/module/services/authService.js +82 -82
  74. package/lib/module/services/biometricPinService.js +10 -10
  75. package/lib/module/services/connectedAccountsService.js +32 -32
  76. package/lib/module/services/googleAuthService.js +15 -15
  77. package/lib/module/services/imageCompressionService.js +15 -15
  78. package/lib/module/services/jwtStorageService.js +59 -59
  79. package/lib/module/services/mobileTrainingService.js +14 -14
  80. package/lib/module/services/pinEncryptionService.js +10 -10
  81. package/lib/module/services/pinStorageUtils.js +15 -15
  82. package/lib/module/services/platformAuthService.js +47 -47
  83. package/lib/module/services/storageService.js +31 -31
  84. package/lib/module/services/trainingApiHelpers.js +33 -33
  85. package/lib/module/services/userConnectionsService.js +24 -24
  86. package/lib/module/utils/Portal.js +4 -4
  87. package/lib/module/utils/api.js +24 -24
  88. package/lib/module/utils/auth.js +18 -18
  89. package/lib/module/utils/crypto.js +13 -13
  90. package/lib/module/utils/encryption.js +12 -12
  91. package/lib/module/utils/eventUtils.js +52 -52
  92. package/lib/module/utils/programmaticFlow.js +16 -16
  93. package/lib/module/utils/retryHelper.js +27 -27
  94. package/lib/typescript/components/OnairosButton.d.ts +37 -0
  95. package/lib/typescript/components/OnairosButton.d.ts.map +1 -0
  96. package/lib/typescript/components/OnairosSignInButton.d.ts +2 -1
  97. package/lib/typescript/components/OnairosSignInButton.d.ts.map +1 -1
  98. package/lib/typescript/index.d.ts +3 -4
  99. package/lib/typescript/index.d.ts.map +1 -1
  100. package/package.json +163 -163
  101. package/src/api/index.ts +151 -151
  102. package/src/assets/images/Checkbox.svg +3 -3
  103. package/src/assets/images/EnochE.svg +19 -19
  104. package/src/assets/images/Personalityprofile.svg +3 -3
  105. package/src/assets/images/Personalitytraits.svg +3 -3
  106. package/src/assets/images/Userpreferences.svg +3 -3
  107. package/src/assets/images/arrow.svg +20 -20
  108. package/src/assets/images/basicproficon.svg +43 -43
  109. package/src/assets/images/basicprofile.svg +3 -3
  110. package/src/assets/images/checkmark.svg +4 -4
  111. package/src/assets/images/contentanalysis.svg +3 -3
  112. package/src/assets/images/contenticon.svg +23 -23
  113. package/src/assets/images/personalityicon.svg +18 -18
  114. package/src/assets/images/x-close.svg +3 -3
  115. package/src/components/BodyText.tsx +33 -33
  116. package/src/components/BrandMark.tsx +62 -62
  117. package/src/components/CodeInput.tsx +32 -32
  118. package/src/components/DataRequestScreen.tsx +355 -355
  119. package/src/components/EmailInput.tsx +31 -31
  120. package/src/components/EmailVerificationModal.tsx +363 -363
  121. package/src/components/ExistingUserDataConfirmation.tsx +506 -506
  122. package/src/components/GoogleButton.tsx +55 -55
  123. package/src/components/HeadingGroup.tsx +49 -49
  124. package/src/components/ModalHeader.tsx +125 -125
  125. package/src/components/ModalSheet.tsx +57 -57
  126. package/src/components/Onairos.tsx +422 -422
  127. package/src/components/OnairosButton.tsx +339 -0
  128. package/src/components/OnairosSignInButton.tsx +30 -10
  129. package/src/components/Overlay.tsx +506 -506
  130. package/src/components/PersonaImage.tsx +79 -79
  131. package/src/components/PersonaLoadingScreen.tsx +201 -201
  132. package/src/components/PersonalizationConsentScreen.tsx +410 -410
  133. package/src/components/PinCreationScreen.tsx +492 -492
  134. package/src/components/PinInput.tsx +555 -555
  135. package/src/components/PlatformConnectorsStep.tsx +891 -891
  136. package/src/components/PlatformList.tsx +144 -144
  137. package/src/components/PlatformToggle.tsx +226 -226
  138. package/src/components/PrimaryButton.tsx +213 -213
  139. package/src/components/SignInMatchAnimation.tsx +225 -225
  140. package/src/components/SignInStep.tsx +217 -217
  141. package/src/components/TrainingModal.tsx +1047 -1047
  142. package/src/components/UniversalOnboarding.tsx +2887 -2887
  143. package/src/components/VerificationStep.tsx +198 -198
  144. package/src/components/WelcomeScreen.tsx +473 -473
  145. package/src/components/icons/Basicproficon.tsx +30 -30
  146. package/src/components/icons/Basicprofile.tsx +17 -17
  147. package/src/components/icons/Checkbox.tsx +17 -17
  148. package/src/components/icons/Checkmark.tsx +24 -24
  149. package/src/components/icons/Contentanalysis.tsx +17 -17
  150. package/src/components/icons/Contenticon.tsx +30 -30
  151. package/src/components/icons/EnochE.tsx +39 -39
  152. package/src/components/icons/Personalityicon.tsx +22 -22
  153. package/src/components/icons/Personalityprofile.tsx +17 -17
  154. package/src/components/icons/Personalitytraits.tsx +17 -17
  155. package/src/components/icons/Userpreferences.tsx +17 -17
  156. package/src/components/icons/index.ts +12 -12
  157. package/src/components/onboarding/OAuthWebView.tsx +232 -232
  158. package/src/config/api.ts +25 -25
  159. package/src/context/AuthContext.tsx +393 -393
  160. package/src/hooks/useConnectedAccounts.ts +138 -138
  161. package/src/hooks/useConnections.ts +161 -161
  162. package/src/hooks/useCredentials.ts +174 -174
  163. package/src/hooks/useUserConnections.ts +165 -165
  164. package/src/index.js +14 -0
  165. package/src/index.ts +94 -96
  166. package/src/services/apiClient.ts +336 -336
  167. package/src/services/apiKeyService.ts +919 -919
  168. package/src/services/authService.ts +1008 -1008
  169. package/src/services/biometricPinService.ts +192 -192
  170. package/src/services/connectedAccountsService.ts +289 -289
  171. package/src/services/googleAuthService.ts +279 -279
  172. package/src/services/imageCompressionService.ts +302 -302
  173. package/src/services/jwtStorageService.ts +256 -256
  174. package/src/services/mobileTrainingService.ts +203 -203
  175. package/src/services/pinEncryptionService.ts +75 -75
  176. package/src/services/pinStorageUtils.ts +96 -96
  177. package/src/services/platformAuthService.ts +1346 -1346
  178. package/src/services/storageService.ts +451 -451
  179. package/src/services/trainingApiHelpers.ts +66 -66
  180. package/src/services/userConnectionsService.ts +556 -556
  181. package/src/services/youtubeMigrationService.ts +453 -453
  182. package/src/theme/index.ts +239 -239
  183. package/src/types/ambient.d.ts +28 -28
  184. package/src/types/index.ts +265 -265
  185. package/src/types/node-fix.d.ts +18 -18
  186. package/src/types/node-override.d.ts +23 -23
  187. package/src/types/opacity.d.ts +15 -15
  188. package/src/types/types.d.ts +17 -17
  189. package/src/utils/Portal.tsx +82 -82
  190. package/src/utils/api.js +111 -111
  191. package/src/utils/auth.js +103 -103
  192. package/src/utils/crypto.js +59 -59
  193. package/src/utils/encryption.ts +68 -68
  194. package/src/utils/eventUtils.ts +302 -302
  195. package/src/utils/haptics.ts +58 -58
  196. package/src/utils/imagePreloader.ts +2 -2
  197. package/src/utils/programmaticFlow.ts +112 -112
  198. 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
  });