ordering-ui-react-native 0.21.17 → 0.21.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -44,11 +44,11 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
44
44
|
useLoginByCellphone,
|
|
45
45
|
useLoginByEmail,
|
|
46
46
|
loginTab,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
otpType,
|
|
48
|
+
setOtpType,
|
|
49
|
+
generateOtpCode,
|
|
50
|
+
useLoginOtpEmail,
|
|
51
|
+
useLoginOtpCellphone,
|
|
52
52
|
} = props;
|
|
53
53
|
|
|
54
54
|
const theme = useTheme()
|
|
@@ -82,31 +82,32 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
const isOtpEmail = loginTab === 'otp' && otpType === 'email'
|
|
85
|
-
|
|
85
|
+
const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
|
|
86
|
+
const isDeviceLoginEnabled = configs?.device_code_login_enabled?.value === '1'
|
|
86
87
|
|
|
87
88
|
const mainLogin = (values) => {
|
|
88
89
|
if (loginTab === 'otp') {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
90
|
+
if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
|
|
91
|
+
showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
if (loginTab === 'otp') {
|
|
95
|
+
generateOtpCode({
|
|
96
|
+
...values,
|
|
97
|
+
...phoneInputData.phone
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
setWillVerifyOtpState(true)
|
|
101
|
+
} else {
|
|
102
|
+
if (phoneInputData.error) {
|
|
103
|
+
showToast(ToastType.Error, phoneInputData.error);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
handleButtonLoginClick({
|
|
107
|
+
...values,
|
|
108
|
+
...phoneInputData.phone,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
const onSubmit = (values: any) => {
|
|
@@ -199,23 +200,23 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
199
200
|
borderColor: theme.colors.inputSignup,
|
|
200
201
|
},
|
|
201
202
|
borderStyleBase: {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
203
|
+
width: 30,
|
|
204
|
+
height: 45
|
|
205
|
+
},
|
|
206
|
+
borderStyleHighLighted: {
|
|
207
|
+
borderColor: "#03DAC6",
|
|
208
|
+
},
|
|
209
|
+
underlineStyleBase: {
|
|
210
|
+
width: 45,
|
|
211
|
+
height: 60,
|
|
212
|
+
borderWidth: 1,
|
|
213
|
+
fontSize: 16
|
|
214
|
+
},
|
|
215
|
+
underlineStyleHighLighted: {
|
|
216
|
+
borderColor: theme.colors.primary,
|
|
217
|
+
color: theme.colors.primary,
|
|
218
|
+
fontSize: 16
|
|
219
|
+
},
|
|
219
220
|
});
|
|
220
221
|
|
|
221
222
|
useEffect(() => {
|
|
@@ -311,32 +312,32 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
311
312
|
};
|
|
312
313
|
|
|
313
314
|
const handleChangeOtpType = (type: string) => {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
315
|
+
handleChangeTab('otp', type)
|
|
316
|
+
setOtpType(type)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const handleLoginOtp = (code: string) => {
|
|
320
|
+
handleButtonLoginClick({ code })
|
|
321
|
+
setWillVerifyOtpState(false)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const closeAlert = () => {
|
|
325
|
+
setAlertState({
|
|
326
|
+
open: false,
|
|
327
|
+
title: '',
|
|
328
|
+
content: []
|
|
329
|
+
})
|
|
330
|
+
}
|
|
330
331
|
|
|
331
332
|
useEffect(() => {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
333
|
+
if (checkPhoneCodeState?.result?.error) {
|
|
334
|
+
setAlertState({
|
|
335
|
+
open: true,
|
|
336
|
+
content: t(checkPhoneCodeState?.result?.error, checkPhoneCodeState?.result?.error),
|
|
337
|
+
title: ''
|
|
338
|
+
})
|
|
339
|
+
}
|
|
340
|
+
}, [checkPhoneCodeState])
|
|
340
341
|
|
|
341
342
|
useEffect(() => {
|
|
342
343
|
const projectInputTimeout = setTimeout(() => {
|
|
@@ -346,9 +347,12 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
346
347
|
project: projectName
|
|
347
348
|
})
|
|
348
349
|
}
|
|
350
|
+
if (isDeviceLoginEnabled) {
|
|
351
|
+
props.handleChangeTab('device_code')
|
|
352
|
+
}
|
|
349
353
|
}, 1500)
|
|
350
354
|
return () => clearTimeout(projectInputTimeout);
|
|
351
|
-
}, [projectName])
|
|
355
|
+
}, [projectName, isDeviceLoginEnabled])
|
|
352
356
|
|
|
353
357
|
const logo = (
|
|
354
358
|
<LogoWrapper>
|
|
@@ -442,7 +446,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
442
446
|
</View>
|
|
443
447
|
)}
|
|
444
448
|
|
|
445
|
-
{(Number(useLoginByEmail) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
|
|
449
|
+
{!isDeviceLoginEnabled && (Number(useLoginByEmail) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
|
|
446
450
|
<LoginWith>
|
|
447
451
|
<ScrollView
|
|
448
452
|
ref={scrollRefTab}
|
|
@@ -553,7 +557,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
553
557
|
style={{
|
|
554
558
|
width: '100%',
|
|
555
559
|
borderBottomColor:
|
|
556
|
-
|
|
560
|
+
isOtpCellphone
|
|
557
561
|
? theme.colors.black
|
|
558
562
|
: theme.colors.border,
|
|
559
563
|
borderBottomWidth: 2,
|
|
@@ -592,8 +596,29 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
592
596
|
)}
|
|
593
597
|
/>
|
|
594
598
|
)}
|
|
595
|
-
|
|
596
|
-
|
|
599
|
+
{isDeviceLoginEnabled && (
|
|
600
|
+
<Controller
|
|
601
|
+
control={control}
|
|
602
|
+
render={({ onChange, value }: any) => (
|
|
603
|
+
<OInput
|
|
604
|
+
placeholder={t('DEVICE_CODE', 'Device Code')}
|
|
605
|
+
style={styles.inputStyle}
|
|
606
|
+
value={value}
|
|
607
|
+
inputStyle={{ textAlign: 'center' }}
|
|
608
|
+
onChange={(val: any) => onChange(val)}
|
|
609
|
+
/>
|
|
610
|
+
)}
|
|
611
|
+
name="device_code"
|
|
612
|
+
rules={{
|
|
613
|
+
required: t(
|
|
614
|
+
'VALIDATION_ERROR_DEVICE_CODE_REQUIRED',
|
|
615
|
+
'The field DEVICE_CODE is required',
|
|
616
|
+
).replace('_attribute_', t('DEVICE_CODE', 'Device Code')),
|
|
617
|
+
}}
|
|
618
|
+
defaultValue=""
|
|
619
|
+
/>
|
|
620
|
+
)}
|
|
621
|
+
{!isDeviceLoginEnabled && ((useLoginByEmail && loginTab === 'email') || (loginTab === 'otp' && otpType === 'email')) && (
|
|
597
622
|
<Controller
|
|
598
623
|
control={control}
|
|
599
624
|
render={({ onChange, value }: any) => (
|
|
@@ -628,7 +653,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
628
653
|
/>
|
|
629
654
|
)}
|
|
630
655
|
|
|
631
|
-
{((useLoginByCellphone && loginTab === 'cellphone') || (loginTab === 'otp' && otpType === 'cellphone')) && (
|
|
656
|
+
{!isDeviceLoginEnabled && ((useLoginByCellphone && loginTab === 'cellphone') || (loginTab === 'otp' && otpType === 'cellphone')) && (
|
|
632
657
|
<View style={{ marginBottom: 20 }}>
|
|
633
658
|
<PhoneInputNumber
|
|
634
659
|
data={phoneInputData}
|
|
@@ -642,7 +667,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
642
667
|
</View>
|
|
643
668
|
)}
|
|
644
669
|
|
|
645
|
-
{loginTab !== 'otp' && (
|
|
670
|
+
{!isDeviceLoginEnabled && loginTab !== 'otp' && (
|
|
646
671
|
<Controller
|
|
647
672
|
control={control}
|
|
648
673
|
render={({ onChange, value }: any) => (
|
|
@@ -732,26 +757,26 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
732
757
|
)}
|
|
733
758
|
</View>
|
|
734
759
|
<OModal
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
760
|
+
open={willVerifyOtpState}
|
|
761
|
+
onClose={() => setWillVerifyOtpState(false)}
|
|
762
|
+
entireModal
|
|
763
|
+
title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
|
|
764
|
+
>
|
|
765
|
+
<Otp
|
|
766
|
+
willVerifyOtpState={willVerifyOtpState}
|
|
767
|
+
setWillVerifyOtpState={setWillVerifyOtpState}
|
|
768
|
+
handleLoginOtp={handleLoginOtp}
|
|
769
|
+
onSubmit={onSubmit}
|
|
770
|
+
setAlertState={setAlertState}
|
|
771
|
+
/>
|
|
772
|
+
</OModal>
|
|
773
|
+
<Alert
|
|
774
|
+
open={alertState.open}
|
|
775
|
+
content={alertState.content}
|
|
776
|
+
title={alertState.title || ''}
|
|
777
|
+
onAccept={closeAlert}
|
|
778
|
+
onClose={closeAlert}
|
|
779
|
+
/>
|
|
755
780
|
</View>
|
|
756
781
|
);
|
|
757
782
|
};
|
|
@@ -24,7 +24,8 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
24
24
|
noDropIcon,
|
|
25
25
|
isDisabled,
|
|
26
26
|
isStartValidation,
|
|
27
|
-
changeCountry
|
|
27
|
+
changeCountry,
|
|
28
|
+
updateStateWithSubmit
|
|
28
29
|
} = props
|
|
29
30
|
|
|
30
31
|
const theme = useTheme();
|
|
@@ -95,6 +96,19 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
95
96
|
}
|
|
96
97
|
}, [userphoneNumber])
|
|
97
98
|
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (defaultValue && updateStateWithSubmit) {
|
|
101
|
+
phoneInput.current?.setState({
|
|
102
|
+
number: defaultValue,
|
|
103
|
+
countryCode: defaultCode ?
|
|
104
|
+
!isNaN(defaultCode)
|
|
105
|
+
? transformCountryCode(defaultCode)
|
|
106
|
+
: findExitingCode(defaultCode)
|
|
107
|
+
: findExitingCode(configs?.default_country_code?.value?.toUpperCase())
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
}, [defaultValue])
|
|
111
|
+
|
|
98
112
|
return (
|
|
99
113
|
<Wrapper onPress={() => forwardRef?.current?.focus?.()}>
|
|
100
114
|
{(isStartValidation && userphoneNumber === '') && (
|
|
@@ -293,7 +293,7 @@ const UserVerificationUI = (props: any) => {
|
|
|
293
293
|
|
|
294
294
|
useEffect(() => {
|
|
295
295
|
setupUserPhoneNumber()
|
|
296
|
-
}, [user])
|
|
296
|
+
}, [user?.cellphone, user?.country_phone_code])
|
|
297
297
|
|
|
298
298
|
return (
|
|
299
299
|
<SafeAreaView style={{ flex: 1 }}>
|
|
@@ -402,6 +402,7 @@ const UserVerificationUI = (props: any) => {
|
|
|
402
402
|
textStyle={{ color: theme.colors.textNormal, fontSize: 12, padding: 0 }}
|
|
403
403
|
noDropIcon
|
|
404
404
|
isDisabled
|
|
405
|
+
updateStateWithSubmit
|
|
405
406
|
/>
|
|
406
407
|
</InputWrapper>
|
|
407
408
|
</>
|
|
@@ -485,6 +486,7 @@ const UserVerificationUI = (props: any) => {
|
|
|
485
486
|
user={user}
|
|
486
487
|
isEdit
|
|
487
488
|
isVerifiedPhone
|
|
489
|
+
dontToggleEditMode
|
|
488
490
|
/>
|
|
489
491
|
</View>
|
|
490
492
|
</ScrollView>
|