ordering-ui-react-native 0.22.76-release → 0.22.77-release

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.
@@ -61,6 +61,7 @@ const UserVerificationUI = (props: any) => {
61
61
  checkVerifyEmailCode,
62
62
  checkVerifyPhoneCode,
63
63
  cleanErrorsState,
64
+ useWhatsappVerification,
64
65
  } = props
65
66
 
66
67
  const theme = useTheme();
@@ -84,6 +85,7 @@ const UserVerificationUI = (props: any) => {
84
85
 
85
86
  const [phoneState, setPhoneState] = useState<any>(null)
86
87
  const [verificationState, setVerificationState] = useState({ email: false, phone: false })
88
+ const [selectedChannel, setSelectedChannel] = useState(2)
87
89
 
88
90
  const codeDigitsArray = new Array(CODE_LENGTH).fill(0);
89
91
 
@@ -173,10 +175,12 @@ const UserVerificationUI = (props: any) => {
173
175
  );
174
176
  };
175
177
 
176
- const handleSendOtp = (opt: string = '') => {
178
+ const handleSendOtp = (opt: string = '', channel?: number) => {
177
179
  setTimer(`${TIME_COUNTDOWN / 60}:00`)
178
180
  setIsSendCodeAgain(true)
179
181
  if (opt === 'phone') {
182
+ const ch = channel || 2
183
+ setSelectedChannel(ch)
180
184
  let cellphone = phoneState?.cellphone
181
185
  let country_phone_code = phoneState?.country_phone_code
182
186
 
@@ -188,7 +192,8 @@ const UserVerificationUI = (props: any) => {
188
192
  }
189
193
  sendVerifyPhoneCode({
190
194
  cellphone,
191
- country_phone_code
195
+ country_phone_code,
196
+ channel: ch
192
197
  })
193
198
  return
194
199
  }
@@ -249,7 +254,8 @@ const UserVerificationUI = (props: any) => {
249
254
  checkVerifyPhoneCode({
250
255
  cellphone: phoneState?.cellphone,
251
256
  country_phone_code: +(phoneState?.country_phone_code),
252
- code: otpState
257
+ code: otpState,
258
+ channel: selectedChannel
253
259
  })
254
260
  return
255
261
  }
@@ -460,7 +466,7 @@ const UserVerificationUI = (props: any) => {
460
466
 
461
467
  <WrapperText>
462
468
  <TouchableOpacity
463
- onPress={() => handleSendOtp('phone')}
469
+ onPress={() => handleSendOtp('phone', selectedChannel)}
464
470
  disabled={verifyPhoneState?.loadingSendCode || verifyPhoneState?.loadingCheckCode}
465
471
  >
466
472
  <OText color={theme.colors.primary}>
@@ -475,21 +481,49 @@ const UserVerificationUI = (props: any) => {
475
481
  </Container>
476
482
  {!!phoneState?.cellphone && (
477
483
  <ButtonsActions>
478
- <View style={{ width: '100%' }}>
479
- <OButton
480
- onClick={(verificationState.email || verificationState.phone)
481
- ? () => setVerificationState({ email: false, phone: false })
482
- : () => handleSendOtp(isPhoneVerifyRequired && !isEmailVerifyRequired ? 'phone' : '')
483
- }
484
- text={(verificationState.email || verificationState.phone) ? t('CANCEL', 'Cancel') : t('SEND_CODE', 'Send code')}
485
- bgColor={(verificationState.email || verificationState.phone) ? theme.colors.secundary : theme.colors.primary}
486
- borderColor={(verificationState.email || verificationState.phone) ? theme.colors.secundary : theme.colors.primary}
487
- textStyle={{ color: (verificationState.email || verificationState.phone) ? 'black' : 'white' }}
488
- imgRightSrc={null}
489
- isLoading={verifyEmailState?.loadingSendCode || verifyEmailState?.loadingCheckCode || verifyPhoneState?.loadingSendCode || verifyPhoneState?.loadingCheckCode}
490
- style={(verificationState.email || verificationState.phone) ? style.btnStyle : { borderRadius: 7.6 }}
491
- />
492
- </View>
484
+ {(verificationState.email || verificationState.phone) ? (
485
+ <View style={{ width: '100%' }}>
486
+ <OButton
487
+ onClick={() => setVerificationState({ email: false, phone: false })}
488
+ text={t('CANCEL', 'Cancel')}
489
+ bgColor={theme.colors.secundary}
490
+ borderColor={theme.colors.secundary}
491
+ textStyle={{ color: 'black' }}
492
+ imgRightSrc={null}
493
+ isLoading={verifyEmailState?.loadingSendCode || verifyEmailState?.loadingCheckCode || verifyPhoneState?.loadingSendCode || verifyPhoneState?.loadingCheckCode}
494
+ style={style.btnStyle}
495
+ />
496
+ </View>
497
+ ) : useWhatsappVerification && isPhoneVerifyRequired && !isEmailVerifyRequired ? (
498
+ <View style={{ flexDirection: 'row', gap: 10, width: '100%' }}>
499
+ <OButton
500
+ onClick={() => handleSendOtp('phone', 2)}
501
+ text={t('SEND_BY_SMS', 'Send by SMS')}
502
+ imgRightSrc={null}
503
+ isLoading={verifyPhoneState?.loadingSendCode || verifyPhoneState?.loadingCheckCode}
504
+ parentStyle={{ flex: 1 }}
505
+ style={{ borderRadius: 7.6 }}
506
+ />
507
+ <OButton
508
+ onClick={() => handleSendOtp('phone', 4)}
509
+ text={t('SEND_BY_WHATSAPP', 'Send by WhatsApp')}
510
+ imgRightSrc={null}
511
+ isLoading={verifyPhoneState?.loadingSendCode || verifyPhoneState?.loadingCheckCode}
512
+ parentStyle={{ flex: 1 }}
513
+ style={{ borderRadius: 7.6 }}
514
+ />
515
+ </View>
516
+ ) : (
517
+ <View style={{ width: '100%' }}>
518
+ <OButton
519
+ onClick={() => handleSendOtp(isPhoneVerifyRequired && !isEmailVerifyRequired ? 'phone' : '')}
520
+ text={t('SEND_CODE', 'Send code')}
521
+ imgRightSrc={null}
522
+ isLoading={verifyEmailState?.loadingSendCode || verifyEmailState?.loadingCheckCode || verifyPhoneState?.loadingSendCode || verifyPhoneState?.loadingCheckCode}
523
+ style={{ borderRadius: 7.6 }}
524
+ />
525
+ </View>
526
+ )}
493
527
  </ButtonsActions>
494
528
  )}
495
529
  <View style={{ paddingHorizontal: 20, paddingBottom: 80 }}>