@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,473 +1,490 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
- import {
3
- View,
4
- StyleSheet,
5
- Modal,
6
- TouchableWithoutFeedback,
7
- Animated,
8
- Easing,
9
- StatusBar,
10
- } from 'react-native';
11
- import { SafeAreaProvider } from 'react-native-safe-area-context';
12
- import { triggerHaptic, HapticType } from '../utils/haptics';
13
- import { sendEmailVerificationCode, confirmEmailVerificationCode } from '../api';
14
- import { signInWithGoogle } from '../services/googleAuthService';
15
- import AsyncStorage from '@react-native-async-storage/async-storage';
16
-
17
- // Import our new components
18
- import ModalSheet from './ModalSheet';
19
- import ModalHeader from './ModalHeader';
20
- import BrandMark from './BrandMark';
21
- import HeadingGroup from './HeadingGroup';
22
- import BodyText from './BodyText';
23
- import PrimaryButton from './PrimaryButton';
24
- import SignInStep from './SignInStep';
25
- import VerificationStep from './VerificationStep';
26
- import PlatformConnectorsStep from './PlatformConnectorsStep';
27
-
28
- // Type definitions for navigation
29
- export interface WelcomeScreenProps {
30
- visible: boolean;
31
- onClose: () => void;
32
- onComplete?: (token: string, email?: string) => void;
33
- }
34
-
35
- type ModalStep = 'welcome' | 'signin' | 'verification' | 'platforms';
36
-
37
- const WelcomeScreen: React.FC<WelcomeScreenProps> = ({
38
- visible,
39
- onClose,
40
- onComplete,
41
- }) => {
42
- const [currentStep, setCurrentStep] = useState<ModalStep>('welcome');
43
- const [userEmail, setUserEmail] = useState<string>('');
44
- const [loading, setLoading] = useState<boolean>(false);
45
- const [error, setError] = useState<string>('');
46
-
47
- // Animation values
48
- const slideAnim = useRef(new Animated.Value(1)).current; // Start from bottom
49
- const fadeAnim = useRef(new Animated.Value(0)).current;
50
-
51
- // Animate in when visible (matching existing modal style)
52
- useEffect(() => {
53
- if (visible) {
54
- Animated.parallel([
55
- Animated.timing(slideAnim, {
56
- toValue: 0,
57
- duration: 400,
58
- easing: Easing.out(Easing.cubic),
59
- useNativeDriver: true,
60
- }),
61
- Animated.timing(fadeAnim, {
62
- toValue: 1,
63
- duration: 300,
64
- useNativeDriver: true,
65
- }),
66
- ]).start();
67
- } else {
68
- slideAnim.setValue(1);
69
- fadeAnim.setValue(0);
70
- }
71
- }, [visible]);
72
-
73
- const handleClose = () => {
74
- triggerHaptic(HapticType.BUTTON_PRESS);
75
-
76
- // Reset to welcome step
77
- setCurrentStep('welcome');
78
-
79
- Animated.parallel([
80
- Animated.timing(slideAnim, {
81
- toValue: 1,
82
- duration: 300,
83
- easing: Easing.in(Easing.cubic),
84
- useNativeDriver: true,
85
- }),
86
- Animated.timing(fadeAnim, {
87
- toValue: 0,
88
- duration: 250,
89
- useNativeDriver: true,
90
- }),
91
- ]).start(() => {
92
- onClose();
93
- });
94
- };
95
-
96
- const handleGetStarted = () => {
97
- triggerHaptic(HapticType.BUTTON_PRESS);
98
- // Move to sign-in step instead of closing modal
99
- setCurrentStep('signin');
100
- };
101
-
102
- const handleEmailSubmit = async (email: string) => {
103
- triggerHaptic(HapticType.BUTTON_PRESS);
104
- setLoading(true);
105
- setError('');
106
-
107
- try {
108
- // Check for reviewer bypass
109
- if (email === 'reviewer@bypass.com') {
110
- console.log('🔍 Reviewer bypass detected in WelcomeScreen');
111
-
112
- try {
113
- // Store the same markers as the old UI
114
- await AsyncStorage.setItem('onairos_user', 'true');
115
- await AsyncStorage.setItem('onairos_jwt_token', 'reviewer-bypass-token');
116
- console.log('✅ Stored reviewer bypass markers for email bypass');
117
-
118
- // Store the reviewer email and skip directly to platforms
119
- setUserEmail(email);
120
- setCurrentStep('platforms');
121
- } catch (error) {
122
- console.error('❌ Failed to store reviewer bypass markers:', error);
123
- // Continue to platforms even if storage fails
124
- setUserEmail(email);
125
- setCurrentStep('platforms');
126
- }
127
-
128
- setLoading(false);
129
- return;
130
- }
131
-
132
- console.log('📧 Sending verification code to:', email);
133
-
134
- // Send verification code using the existing API
135
- const result = await sendEmailVerificationCode(email);
136
-
137
- if (result.success) {
138
- console.log('✅ Verification code sent successfully');
139
- // Store the email and move to verification
140
- setUserEmail(email);
141
- setCurrentStep('verification');
142
- } else {
143
- console.log(' Failed to send verification code:', result.message);
144
- setError(result.message || 'Failed to send verification code. Please try again.');
145
- }
146
- } catch (error) {
147
- console.error('❌ Error sending verification code:', error);
148
- setError('Network error. Please check your connection and try again.');
149
- } finally {
150
- setLoading(false);
151
- }
152
- };
153
-
154
- const handleGoogleSignIn = async () => {
155
- triggerHaptic(HapticType.BUTTON_PRESS);
156
- setLoading(true);
157
- setError('');
158
-
159
- try {
160
- console.log('🔗 Initiating Google Sign-In');
161
-
162
- const result = await signInWithGoogle();
163
-
164
- if (result.success && result.user) {
165
- console.log(' Google Sign-In successful:', result.user.email);
166
-
167
- // Store user information
168
- setUserEmail(result.user.email);
169
-
170
- // Skip to platform connectors (user is already authenticated)
171
- setCurrentStep('platforms');
172
- } else if (result.cancelled) {
173
- console.log('ℹ️ Google Sign-In cancelled by user');
174
- // Don't show error for cancellation, just reset loading
175
- } else {
176
- console.log('❌ Google Sign-In failed:', result.message);
177
- setError(result.message || 'Google Sign-In failed. Please try again.');
178
- }
179
- } catch (error) {
180
- console.error('❌ Unexpected Google Sign-In error:', error);
181
- setError('Google Sign-In failed. Please try again.');
182
- } finally {
183
- setLoading(false);
184
- }
185
- };
186
-
187
- const handleContinue = () => {
188
- triggerHaptic(HapticType.BUTTON_PRESS);
189
- // Move to verification step
190
- setCurrentStep('verification');
191
- };
192
-
193
- const handleCodeSubmit = async (code: string) => {
194
- triggerHaptic(HapticType.BUTTON_PRESS);
195
- setLoading(true);
196
- setError('');
197
-
198
- try {
199
- console.log('🔍 Verifying email code:', userEmail, code);
200
-
201
- // Verify the email code using the existing API
202
- const result = await confirmEmailVerificationCode(userEmail, code);
203
-
204
- if (result.success) {
205
- console.log('✅ Email verification successful');
206
- // Move to platform connectors step
207
- setCurrentStep('platforms');
208
- } else {
209
- console.log('❌ Email verification failed:', result.message);
210
- setError(result.message || 'Invalid verification code. Please try again.');
211
- }
212
- } catch (error) {
213
- console.error('❌ Error verifying email code:', error);
214
- setError('Verification failed. Please try again.');
215
- } finally {
216
- setLoading(false);
217
- }
218
- };
219
-
220
- const handleBackToSignIn = () => {
221
- triggerHaptic(HapticType.BUTTON_PRESS);
222
- setError(''); // Clear any errors when going back
223
- setCurrentStep('signin');
224
- };
225
-
226
- const handleBackToVerification = () => {
227
- triggerHaptic(HapticType.BUTTON_PRESS);
228
- setCurrentStep('verification');
229
- };
230
-
231
- const handleResendCode = async () => {
232
- triggerHaptic(HapticType.BUTTON_PRESS);
233
- setLoading(true);
234
- setError('');
235
-
236
- try {
237
- console.log('🔄 Resending verification code to:', userEmail);
238
-
239
- // Resend verification code using the existing API
240
- const result = await sendEmailVerificationCode(userEmail);
241
-
242
- if (result.success) {
243
- console.log('✅ Verification code resent successfully');
244
- // Could show a success message here if needed
245
- } else {
246
- console.log('❌ Failed to resend verification code:', result.message);
247
- setError(result.message || 'Failed to resend verification code. Please try again.');
248
- }
249
- } catch (error) {
250
- console.error('❌ Error resending verification code:', error);
251
- setError('Network error. Please check your connection and try again.');
252
- } finally {
253
- setLoading(false);
254
- }
255
- };
256
-
257
- const handlePlatformUpdate = (connectedPlatforms: string[]) => {
258
- triggerHaptic(HapticType.BUTTON_PRESS);
259
- console.log('Connected platforms:', connectedPlatforms);
260
-
261
- // Complete the onboarding flow
262
- if (onComplete) {
263
- // Return the stored token and email
264
- AsyncStorage.getItem('onairos_jwt_token').then(token => {
265
- onComplete(token || 'onboarding-complete-token', userEmail);
266
- });
267
- } else {
268
- onClose();
269
- }
270
- };
271
-
272
- const handlePlatformSkip = () => {
273
- triggerHaptic(HapticType.BUTTON_PRESS);
274
- // Skip platform connections and complete onboarding
275
- if (onComplete) {
276
- // Return a skip token
277
- onComplete('onboarding-skipped-token', userEmail);
278
- } else {
279
- onClose();
280
- }
281
- };
282
-
283
- const handleReviewerBypass = async () => {
284
- console.log('🔍 Reviewer bypass triggered from platforms screen');
285
- triggerHaptic(HapticType.BUTTON_PRESS);
286
-
287
- try {
288
- // Store the same markers as the old UI
289
- await AsyncStorage.setItem('onairos_user', 'true');
290
- await AsyncStorage.setItem('onairos_jwt_token', 'reviewer-bypass-token');
291
- console.log('✅ Stored reviewer bypass markers for new UI');
292
-
293
- // Complete the onboarding with bypass token
294
- if (onComplete) {
295
- onComplete('reviewer-bypass-token', 'reviewer@apple.com');
296
- } else {
297
- onClose();
298
- }
299
- } catch (error) {
300
- console.error('❌ Failed to store reviewer bypass markers:', error);
301
- // Still complete the onboarding even if storage fails
302
- if (onComplete) {
303
- onComplete('reviewer-bypass-token', 'reviewer@apple.com');
304
- } else {
305
- onClose();
306
- }
307
- }
308
- };
309
-
310
- const handleBackdropPress = () => {
311
- // Optional: allow closing by tapping backdrop
312
- handleClose();
313
- };
314
-
315
- if (!visible) {
316
- return null;
317
- }
318
-
319
- return (
320
- <Modal
321
- visible={visible}
322
- transparent
323
- animationType="slide" // Use built-in slide animation like existing modal
324
- onRequestClose={handleClose}
325
- statusBarTranslucent
326
- >
327
- <StatusBar backgroundColor="rgba(0,0,0,0.5)" barStyle="light-content" />
328
-
329
- {/* Backdrop */}
330
- <Animated.View style={[styles.backdrop, { opacity: fadeAnim }]}>
331
- <TouchableWithoutFeedback onPress={handleBackdropPress}>
332
- <View style={styles.backdropTouchable} />
333
- </TouchableWithoutFeedback>
334
- </Animated.View>
335
-
336
- {/* Modal Content */}
337
- <Animated.View
338
- style={[
339
- styles.modalContainer,
340
- {
341
- transform: [{
342
- translateY: slideAnim.interpolate({
343
- inputRange: [0, 1],
344
- outputRange: [0, 600], // Slide from bottom
345
- })
346
- }]
347
- }
348
- ]}
349
- >
350
- <SafeAreaProvider>
351
- <ModalSheet topPadding={0}>
352
- <ModalHeader
353
- onClose={handleClose}
354
- onBack={currentStep === 'verification' ? handleBackToSignIn : handleBackToVerification}
355
- showBackButton={currentStep === 'verification' || currentStep === 'platforms'}
356
- />
357
-
358
- {currentStep === 'welcome' && (
359
- <View style={styles.content}>
360
- {/* Brand Mark */}
361
- <View style={styles.brandMarkContainer}>
362
- <BrandMark />
363
- </View>
364
-
365
- {/* Heading Group */}
366
- <View style={styles.headingContainer}>
367
- <HeadingGroup />
368
- </View>
369
-
370
- {/* Body Text */}
371
- <View style={styles.bodyContainer}>
372
- <BodyText />
373
- </View>
374
-
375
- {/* Flexible Spacer */}
376
- <View style={styles.spacer} />
377
-
378
- {/* Primary Button */}
379
- <View style={styles.buttonContainer}>
380
- <PrimaryButton
381
- label="Get Started"
382
- onPress={handleGetStarted}
383
- testID="welcome-get-started-button"
384
- />
385
- </View>
386
- </View>
387
- )}
388
-
389
- {currentStep === 'signin' && (
390
- <SignInStep
391
- onEmailSubmit={handleEmailSubmit}
392
- onGoogleSignIn={handleGoogleSignIn}
393
- onContinue={handleContinue}
394
- loading={loading}
395
- error={error}
396
- />
397
- )}
398
-
399
- {currentStep === 'verification' && (
400
- <VerificationStep
401
- email={userEmail}
402
- onCodeSubmit={handleCodeSubmit}
403
- onBack={handleBackToSignIn}
404
- loading={loading}
405
- error={error}
406
- onResendCode={handleResendCode}
407
- />
408
- )}
409
-
410
- {currentStep === 'platforms' && (
411
- <PlatformConnectorsStep
412
- onUpdate={handlePlatformUpdate}
413
- onSkip={handlePlatformSkip}
414
- onReviewerBypass={handleReviewerBypass}
415
- />
416
- )}
417
- </ModalSheet>
418
- </SafeAreaProvider>
419
- </Animated.View>
420
- </Modal>
421
- );
422
- };
423
-
424
- const styles = StyleSheet.create({
425
- backdrop: {
426
- ...StyleSheet.absoluteFillObject,
427
- backgroundColor: 'transparent', // Remove grey overlay
428
- },
429
-
430
- backdropTouchable: {
431
- flex: 1,
432
- },
433
-
434
- modalContainer: {
435
- position: 'absolute',
436
- bottom: 0,
437
- left: 0,
438
- right: 0,
439
- height: '85%', // Take most of the screen
440
- },
441
-
442
- content: {
443
- flex: 1,
444
- alignItems: 'center',
445
- paddingTop: 20,
446
- },
447
-
448
- brandMarkContainer: {
449
- marginBottom: 32,
450
- },
451
-
452
- headingContainer: {
453
- marginBottom: 24,
454
- },
455
-
456
- bodyContainer: {
457
- marginBottom: 32,
458
- width: '100%',
459
- },
460
-
461
- spacer: {
462
- flex: 1,
463
- minHeight: 20, // Ensure some minimum space
464
- },
465
-
466
- buttonContainer: {
467
- width: '100%',
468
- paddingHorizontal: 24,
469
- paddingBottom: 20,
470
- },
471
- });
472
-
473
- export default WelcomeScreen;
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ Modal,
6
+ TouchableWithoutFeedback,
7
+ Animated,
8
+ Easing,
9
+ StatusBar,
10
+ } from 'react-native';
11
+ import { triggerHaptic, HapticType } from '../utils/haptics';
12
+ import { sendEmailVerificationCode, confirmEmailVerificationCode } from '../api/index';
13
+ import { signInWithGoogle } from '../services/googleAuthService';
14
+ import AsyncStorage from '@react-native-async-storage/async-storage';
15
+
16
+ // Import our new components
17
+ import ModalSheet from './ModalSheet';
18
+ import ModalHeader from './ModalHeader';
19
+ import BrandMark from './BrandMark';
20
+ import HeadingGroup from './HeadingGroup';
21
+ import BodyText from './BodyText';
22
+ import PrimaryButton from './PrimaryButton';
23
+ import SignInStep from './SignInStep';
24
+ import VerificationStep from './VerificationStep';
25
+ // Temporarily remove PlatformConnectorsStep to avoid context dependency issues
26
+ // import PlatformConnectorsStep from './PlatformConnectorsStep';
27
+
28
+ // Type definitions for navigation
29
+ export interface WelcomeScreenProps {
30
+ visible: boolean;
31
+ onClose: () => void;
32
+ onComplete?: (token: string, email?: string) => void;
33
+ }
34
+
35
+ type ModalStep = 'welcome' | 'signin' | 'verification' | 'platforms';
36
+
37
+ const WelcomeScreen: React.FC<WelcomeScreenProps> = ({
38
+ visible,
39
+ onClose,
40
+ onComplete,
41
+ }) => {
42
+ const [currentStep, setCurrentStep] = useState<ModalStep>('welcome');
43
+ const [userEmail, setUserEmail] = useState<string>('');
44
+ const [loading, setLoading] = useState<boolean>(false);
45
+ const [error, setError] = useState<string>('');
46
+
47
+ // Animation values
48
+ const slideAnim = useRef(new Animated.Value(1)).current; // Start from bottom
49
+ const fadeAnim = useRef(new Animated.Value(0)).current;
50
+
51
+ // Animate in when visible (matching existing modal style)
52
+ useEffect(() => {
53
+ console.log('🔍 WelcomeScreen visibility changed:', visible);
54
+ if (visible) {
55
+ console.log('🎬 Starting WelcomeScreen animations');
56
+ Animated.parallel([
57
+ Animated.timing(slideAnim, {
58
+ toValue: 0,
59
+ duration: 400,
60
+ easing: Easing.out(Easing.cubic),
61
+ useNativeDriver: true,
62
+ }),
63
+ Animated.timing(fadeAnim, {
64
+ toValue: 1,
65
+ duration: 300,
66
+ useNativeDriver: true,
67
+ }),
68
+ ]).start(() => {
69
+ console.log('✅ WelcomeScreen animations completed');
70
+ });
71
+ } else {
72
+ console.log('🔄 Resetting WelcomeScreen animations');
73
+ slideAnim.setValue(1);
74
+ fadeAnim.setValue(0);
75
+ }
76
+ }, [visible]);
77
+
78
+ const handleClose = () => {
79
+ triggerHaptic(HapticType.BUTTON_PRESS);
80
+
81
+ // Reset to welcome step
82
+ setCurrentStep('welcome');
83
+
84
+ Animated.parallel([
85
+ Animated.timing(slideAnim, {
86
+ toValue: 1,
87
+ duration: 300,
88
+ easing: Easing.in(Easing.cubic),
89
+ useNativeDriver: true,
90
+ }),
91
+ Animated.timing(fadeAnim, {
92
+ toValue: 0,
93
+ duration: 250,
94
+ useNativeDriver: true,
95
+ }),
96
+ ]).start(() => {
97
+ onClose();
98
+ });
99
+ };
100
+
101
+ const handleGetStarted = () => {
102
+ triggerHaptic(HapticType.BUTTON_PRESS);
103
+ // Move to sign-in step instead of closing modal
104
+ setCurrentStep('signin');
105
+ };
106
+
107
+ const handleEmailSubmit = async (email: string) => {
108
+ triggerHaptic(HapticType.BUTTON_PRESS);
109
+ setLoading(true);
110
+ setError('');
111
+
112
+ try {
113
+ // Check for reviewer bypass
114
+ if (email === 'reviewer@bypass.com') {
115
+ console.log('🔍 Reviewer bypass detected in WelcomeScreen');
116
+
117
+ try {
118
+ // Store the same markers as the old UI
119
+ await AsyncStorage.setItem('onairos_user', 'true');
120
+ await AsyncStorage.setItem('onairos_jwt_token', 'reviewer-bypass-token');
121
+ console.log('✅ Stored reviewer bypass markers for email bypass');
122
+
123
+ // Store the reviewer email and skip directly to platforms
124
+ setUserEmail(email);
125
+ setCurrentStep('platforms');
126
+ } catch (error) {
127
+ console.error('❌ Failed to store reviewer bypass markers:', error);
128
+ // Continue to platforms even if storage fails
129
+ setUserEmail(email);
130
+ setCurrentStep('platforms');
131
+ }
132
+
133
+ setLoading(false);
134
+ return;
135
+ }
136
+
137
+ console.log('📧 Sending verification code to:', email);
138
+
139
+ // Send verification code using the existing API
140
+ const result = await sendEmailVerificationCode(email);
141
+
142
+ if (result.success) {
143
+ console.log(' Verification code sent successfully');
144
+ // Store the email and move to verification
145
+ setUserEmail(email);
146
+ setCurrentStep('verification');
147
+ } else {
148
+ console.log(' Failed to send verification code:', result.message);
149
+ setError(result.message || 'Failed to send verification code. Please try again.');
150
+ }
151
+ } catch (error) {
152
+ console.error('❌ Error sending verification code:', error);
153
+ setError('Network error. Please check your connection and try again.');
154
+ } finally {
155
+ setLoading(false);
156
+ }
157
+ };
158
+
159
+ const handleGoogleSignIn = async () => {
160
+ triggerHaptic(HapticType.BUTTON_PRESS);
161
+ setLoading(true);
162
+ setError('');
163
+
164
+ try {
165
+ console.log('🔗 Initiating Google Sign-In');
166
+
167
+ const result = await signInWithGoogle();
168
+
169
+ if (result.success && result.user) {
170
+ console.log('✅ Google Sign-In successful:', result.user.email);
171
+
172
+ // Store user information
173
+ setUserEmail(result.user.email);
174
+
175
+ // Skip to platform connectors (user is already authenticated)
176
+ setCurrentStep('platforms');
177
+ } else if (result.cancelled) {
178
+ console.log('ℹ️ Google Sign-In cancelled by user');
179
+ // Don't show error for cancellation, just reset loading
180
+ } else {
181
+ console.log('Google Sign-In failed:', result.message);
182
+ setError(result.message || 'Google Sign-In failed. Please try again.');
183
+ }
184
+ } catch (error) {
185
+ console.error('❌ Unexpected Google Sign-In error:', error);
186
+ setError('Google Sign-In failed. Please try again.');
187
+ } finally {
188
+ setLoading(false);
189
+ }
190
+ };
191
+
192
+ const handleContinue = () => {
193
+ triggerHaptic(HapticType.BUTTON_PRESS);
194
+ // Move to verification step
195
+ setCurrentStep('verification');
196
+ };
197
+
198
+ const handleCodeSubmit = async (code: string) => {
199
+ triggerHaptic(HapticType.BUTTON_PRESS);
200
+ setLoading(true);
201
+ setError('');
202
+
203
+ try {
204
+ console.log('🔍 Verifying email code:', userEmail, code);
205
+
206
+ // Verify the email code using the existing API
207
+ const result = await confirmEmailVerificationCode(userEmail, code);
208
+
209
+ if (result.success) {
210
+ console.log('✅ Email verification successful');
211
+ // Move to platform connectors step
212
+ setCurrentStep('platforms');
213
+ } else {
214
+ console.log(' Email verification failed:', result.message);
215
+ setError(result.message || 'Invalid verification code. Please try again.');
216
+ }
217
+ } catch (error) {
218
+ console.error('❌ Error verifying email code:', error);
219
+ setError('Verification failed. Please try again.');
220
+ } finally {
221
+ setLoading(false);
222
+ }
223
+ };
224
+
225
+ const handleBackToSignIn = () => {
226
+ triggerHaptic(HapticType.BUTTON_PRESS);
227
+ setError(''); // Clear any errors when going back
228
+ setCurrentStep('signin');
229
+ };
230
+
231
+ const handleBackToVerification = () => {
232
+ triggerHaptic(HapticType.BUTTON_PRESS);
233
+ setCurrentStep('verification');
234
+ };
235
+
236
+ const handleResendCode = async () => {
237
+ triggerHaptic(HapticType.BUTTON_PRESS);
238
+ setLoading(true);
239
+ setError('');
240
+
241
+ try {
242
+ console.log('🔄 Resending verification code to:', userEmail);
243
+
244
+ // Resend verification code using the existing API
245
+ const result = await sendEmailVerificationCode(userEmail);
246
+
247
+ if (result.success) {
248
+ console.log('✅ Verification code resent successfully');
249
+ // Could show a success message here if needed
250
+ } else {
251
+ console.log(' Failed to resend verification code:', result.message);
252
+ setError(result.message || 'Failed to resend verification code. Please try again.');
253
+ }
254
+ } catch (error) {
255
+ console.error('❌ Error resending verification code:', error);
256
+ setError('Network error. Please check your connection and try again.');
257
+ } finally {
258
+ setLoading(false);
259
+ }
260
+ };
261
+
262
+ const handlePlatformUpdate = (connectedPlatforms: string[]) => {
263
+ triggerHaptic(HapticType.BUTTON_PRESS);
264
+ console.log('Connected platforms:', connectedPlatforms);
265
+
266
+ // Complete the onboarding flow
267
+ if (onComplete) {
268
+ // Return the stored token and email
269
+ AsyncStorage.getItem('onairos_jwt_token').then(token => {
270
+ onComplete(token || 'onboarding-complete-token', userEmail);
271
+ });
272
+ } else {
273
+ onClose();
274
+ }
275
+ };
276
+
277
+ const handlePlatformSkip = () => {
278
+ triggerHaptic(HapticType.BUTTON_PRESS);
279
+ // Skip platform connections and complete onboarding
280
+ if (onComplete) {
281
+ // Return a skip token
282
+ onComplete('onboarding-skipped-token', userEmail);
283
+ } else {
284
+ onClose();
285
+ }
286
+ };
287
+
288
+ const handleReviewerBypass = async () => {
289
+ console.log('🔍 Reviewer bypass triggered from platforms screen');
290
+ triggerHaptic(HapticType.BUTTON_PRESS);
291
+
292
+ try {
293
+ // Store the same markers as the old UI
294
+ await AsyncStorage.setItem('onairos_user', 'true');
295
+ await AsyncStorage.setItem('onairos_jwt_token', 'reviewer-bypass-token');
296
+ console.log('✅ Stored reviewer bypass markers for new UI');
297
+
298
+ // Complete the onboarding with bypass token
299
+ if (onComplete) {
300
+ onComplete('reviewer-bypass-token', 'reviewer@apple.com');
301
+ } else {
302
+ onClose();
303
+ }
304
+ } catch (error) {
305
+ console.error('❌ Failed to store reviewer bypass markers:', error);
306
+ // Still complete the onboarding even if storage fails
307
+ if (onComplete) {
308
+ onComplete('reviewer-bypass-token', 'reviewer@apple.com');
309
+ } else {
310
+ onClose();
311
+ }
312
+ }
313
+ };
314
+
315
+ const handleBackdropPress = () => {
316
+ // Optional: allow closing by tapping backdrop
317
+ handleClose();
318
+ };
319
+
320
+ if (!visible) {
321
+ return null;
322
+ }
323
+
324
+ return (
325
+ <Modal
326
+ visible={visible}
327
+ transparent
328
+ animationType="slide" // Use built-in slide animation like existing modal
329
+ onRequestClose={handleClose}
330
+ statusBarTranslucent
331
+ >
332
+ <StatusBar backgroundColor="rgba(0,0,0,0.5)" barStyle="light-content" />
333
+
334
+ {/* Backdrop */}
335
+ <Animated.View style={[styles.backdrop, { opacity: fadeAnim }]}>
336
+ <TouchableWithoutFeedback onPress={handleBackdropPress}>
337
+ <View style={styles.backdropTouchable} />
338
+ </TouchableWithoutFeedback>
339
+ </Animated.View>
340
+
341
+ {/* Modal Content */}
342
+ <Animated.View
343
+ style={[
344
+ styles.modalContainer,
345
+ {
346
+ transform: [{
347
+ translateY: slideAnim.interpolate({
348
+ inputRange: [0, 1],
349
+ outputRange: [0, 600], // Slide from bottom
350
+ })
351
+ }]
352
+ }
353
+ ]}
354
+ >
355
+ <ModalSheet topPadding={0}>
356
+ <ModalHeader
357
+ onClose={handleClose}
358
+ onBack={currentStep === 'verification' ? handleBackToSignIn : handleBackToVerification}
359
+ showBackButton={currentStep === 'verification' || currentStep === 'platforms'}
360
+ />
361
+
362
+ {currentStep === 'welcome' && (
363
+ <View style={styles.content}>
364
+ {/* Brand Mark */}
365
+ <View style={styles.brandMarkContainer}>
366
+ <BrandMark />
367
+ </View>
368
+
369
+ {/* Heading Group */}
370
+ <View style={styles.headingContainer}>
371
+ <HeadingGroup />
372
+ </View>
373
+
374
+ {/* Body Text */}
375
+ <View style={styles.bodyContainer}>
376
+ <BodyText />
377
+ </View>
378
+
379
+ {/* Flexible Spacer */}
380
+ <View style={styles.spacer} />
381
+
382
+ {/* Primary Button */}
383
+ <View style={styles.buttonContainer}>
384
+ <PrimaryButton
385
+ label="Get Started"
386
+ onPress={handleGetStarted}
387
+ testID="welcome-get-started-button"
388
+ />
389
+ </View>
390
+ </View>
391
+ )}
392
+
393
+ {currentStep === 'signin' && (
394
+ <SignInStep
395
+ onEmailSubmit={handleEmailSubmit}
396
+ onGoogleSignIn={handleGoogleSignIn}
397
+ onContinue={handleContinue}
398
+ loading={loading}
399
+ error={error}
400
+ />
401
+ )}
402
+
403
+ {currentStep === 'verification' && (
404
+ <VerificationStep
405
+ email={userEmail}
406
+ onCodeSubmit={handleCodeSubmit}
407
+ onBack={handleBackToSignIn}
408
+ loading={loading}
409
+ error={error}
410
+ onResendCode={handleResendCode}
411
+ />
412
+ )}
413
+
414
+ {currentStep === 'platforms' && (
415
+ <View style={styles.content}>
416
+ <View style={styles.headingContainer}>
417
+ <HeadingGroup />
418
+ </View>
419
+
420
+ <View style={styles.bodyContainer}>
421
+ <BodyText />
422
+ </View>
423
+
424
+ <View style={styles.spacer} />
425
+
426
+ <View style={styles.buttonContainer}>
427
+ <PrimaryButton
428
+ label="Complete Setup"
429
+ onPress={() => handlePlatformUpdate([])}
430
+ testID="complete-setup-button"
431
+ />
432
+ </View>
433
+ </View>
434
+ )}
435
+ </ModalSheet>
436
+ </Animated.View>
437
+ </Modal>
438
+ );
439
+ };
440
+
441
+ const styles = StyleSheet.create({
442
+ backdrop: {
443
+ ...StyleSheet.absoluteFillObject,
444
+ backgroundColor: 'transparent', // Remove grey overlay
445
+ },
446
+
447
+ backdropTouchable: {
448
+ flex: 1,
449
+ },
450
+
451
+ modalContainer: {
452
+ position: 'absolute',
453
+ bottom: 0,
454
+ left: 0,
455
+ right: 0,
456
+ height: '85%', // Take most of the screen
457
+ },
458
+
459
+ content: {
460
+ flex: 1,
461
+ alignItems: 'center',
462
+ paddingTop: 20,
463
+ },
464
+
465
+ brandMarkContainer: {
466
+ marginBottom: 32,
467
+ },
468
+
469
+ headingContainer: {
470
+ marginBottom: 24,
471
+ },
472
+
473
+ bodyContainer: {
474
+ marginBottom: 32,
475
+ width: '100%',
476
+ },
477
+
478
+ spacer: {
479
+ flex: 1,
480
+ minHeight: 20, // Ensure some minimum space
481
+ },
482
+
483
+ buttonContainer: {
484
+ width: '100%',
485
+ paddingHorizontal: 24,
486
+ paddingBottom: 20,
487
+ },
488
+ });
489
+
490
+ export default WelcomeScreen;