ordering-ui-react-native 0.23.3 → 0.23.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.23.3",
3
+ "version": "0.23.5",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import { View, Pressable, StyleSheet, Linking, Platform, TouchableOpacity } from 'react-native';
2
+ import { View, Pressable, StyleSheet, Linking, Platform, TouchableOpacity, Modal } from 'react-native';
3
3
  import { useForm, Controller } from 'react-hook-form';
4
4
  import Spinner from 'react-native-loading-spinner-overlay';
5
5
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
@@ -32,11 +32,9 @@ import {
32
32
  } from '../LoginForm/styles';
33
33
 
34
34
  import NavBar from '../NavBar';
35
- import { VerifyPhone } from '../VerifyPhone';
36
35
 
37
36
  import Alert from '../../../../../src/providers/AlertProvider'
38
37
  import { OText, OButton, OInput } from '../shared';
39
- import { OModal } from '../../../../../src/components/shared';
40
38
  import { SignupParams } from '../../types';
41
39
  import { sortInputFields } from '../../utils';
42
40
  import { GoogleLogin } from '../GoogleLogin';
@@ -141,6 +139,8 @@ const SignupFormUI = (props: SignupParams) => {
141
139
  const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
142
140
  const [recaptchaVerified, setRecaptchaVerified] = useState(false)
143
141
  const [tabLayouts, setTabLayouts] = useState<any>({})
142
+ const [isCheckingCode, setCheckingCode] = useState(false)
143
+ const [otpError, setOtpError] = useState(null)
144
144
 
145
145
  const tabsRef = useRef<any>(null)
146
146
  const nameRef = useRef<any>(null);
@@ -467,9 +467,16 @@ const SignupFormUI = (props: SignupParams) => {
467
467
 
468
468
  useEffect(() => {
469
469
  if (checkPhoneCodeState?.result?.error) {
470
- setAlertState({
470
+ const titleText = (
471
+ typeof checkPhoneCodeState?.result?.result === 'string'
472
+ ? checkPhoneCodeState?.result?.result
473
+ : checkPhoneCodeState?.result?.result[0].toString()
474
+ ) || t('ERROR', 'Error')
475
+ setCheckingCode(false)
476
+ setOtpError(titleText)
477
+ checkPhoneCodeState?.generate && setAlertState({
471
478
  open: true,
472
- title: (typeof checkPhoneCodeState?.result?.result === 'string' ? checkPhoneCodeState?.result?.result : checkPhoneCodeState?.result?.result[0].toString()) || t('ERROR', 'Error'),
479
+ title: titleText,
473
480
  content: []
474
481
  })
475
482
  }
@@ -967,13 +974,16 @@ const SignupFormUI = (props: SignupParams) => {
967
974
  )
968
975
  )}
969
976
  </FormSide>
970
- <OModal
971
- open={willVerifyOtpState}
972
- onClose={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
973
- entireModal
974
- title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
977
+ <Modal
978
+ visible={willVerifyOtpState}
979
+ onDismiss={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
980
+ animationType='slide'
975
981
  >
976
982
  <Otp
983
+ isCheckingCode={isCheckingCode}
984
+ setCheckingCode={setCheckingCode}
985
+ otpError={otpError}
986
+ setOtpError={setOtpError}
977
987
  pinCount={numOtpInputs || 6}
978
988
  willVerifyOtpState={willVerifyOtpState || false}
979
989
  setWillVerifyOtpState={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
@@ -981,7 +991,7 @@ const SignupFormUI = (props: SignupParams) => {
981
991
  onSubmit={onSubmit}
982
992
  setAlertState={setAlertState}
983
993
  />
984
- </OModal>
994
+ </Modal>
985
995
  <Spinner
986
996
  visible={formState.loading || validationFields.loading || isFBLoading}
987
997
  />
@@ -16,6 +16,8 @@ import { ListItem } from '../UserProfile/styles';
16
16
  import moment from 'moment';
17
17
  import { DatePickerUI } from '../DatePicker';
18
18
 
19
+ const CONDITIONAL_CODES = ['PR']
20
+
19
21
  export const UserFormDetailsUI = (props: any) => {
20
22
  const {
21
23
  isEdit,
@@ -129,6 +131,16 @@ export const UserFormDetailsUI = (props: any) => {
129
131
  return rules;
130
132
  };
131
133
 
134
+ const cellphoneValue = () => {
135
+ let cellphone = user?.cellphone || null
136
+ if (cellphone && CONDITIONAL_CODES.includes(user?.country_code)) {
137
+ if (user?.country_code === 'PR') {
138
+ cellphone = user?.cellphone?.slice(3)
139
+ }
140
+ }
141
+ return cellphone
142
+ }
143
+
132
144
  const setUserCellPhone = (isEdit = false) => {
133
145
  if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
134
146
  setUserPhoneNumber(userPhoneNumber);
@@ -146,7 +158,7 @@ export const UserFormDetailsUI = (props: any) => {
146
158
  ...phoneInputData,
147
159
  phone: {
148
160
  country_phone_code: user?.country_phone_code || null,
149
- cellphone: user?.cellphone || null,
161
+ cellphone: cellphoneValue()
150
162
  },
151
163
  });
152
164
  return;
@@ -405,7 +417,7 @@ export const UserFormDetailsUI = (props: any) => {
405
417
  data={phoneInputData}
406
418
  handleData={(val: any) => handleChangePhoneNumber(val)}
407
419
  changeCountry={(val: any) => changeCountry(val)}
408
- defaultValue={phoneUpdate ? '' : user?.cellphone}
420
+ defaultValue={phoneUpdate ? '' : cellphoneValue()}
409
421
  defaultCode={user?.country_code ?? user?.country_phone_code ?? null}
410
422
  boxStyle={styles.phoneSelect}
411
423
  inputStyle={styles.phoneInputStyle}
@@ -418,7 +430,7 @@ export const UserFormDetailsUI = (props: any) => {
418
430
  color={theme.colors.error}
419
431
  style={{ marginHorizontal: 10, textAlign: 'center' }}>
420
432
  {t('YOUR_PREVIOUS_CELLPHONE', 'Your previous cellphone')}:{' '}
421
- {user?.cellphone}
433
+ {cellphoneValue()}
422
434
  </OText>
423
435
  )}
424
436
  </WrapperPhone>