ordering-ui-react-native 0.21.9 → 0.21.10

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.21.9",
3
+ "version": "0.21.10",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,17 +1,18 @@
1
1
  import * as React from "react";
2
- import { Animated, StyleSheet, Text, View, Platform } from "react-native";
2
+ import { Animated, StyleSheet, Text, View } from "react-native";
3
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
3
4
  import { ToastType, useToast, useLanguage } from "ordering-components/native";
4
5
  import { useTheme } from 'styled-components/native';
5
6
  import { getTraduction } from '../../utils'
6
7
 
7
8
  const fadeDuration = 300;
8
- const topPosition = Platform.OS === 'ios' ? 40 : 20
9
9
 
10
10
  export const Toast = (props: any) => {
11
11
  const [toastConfig, { hideToast }] = useToast();
12
12
  const [, t] = useLanguage()
13
13
  const opacity = React.useRef(new Animated.Value(0)).current;
14
14
  const theme = useTheme();
15
+ const { top: topPosition } = useSafeAreaInsets();
15
16
 
16
17
  const fadeIn = React.useCallback(() => {
17
18
  Animated.timing(opacity, {
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useRef, useState } from 'react'
2
2
  import { formatSeconds } from '../../../utils'
3
- import { StyleSheet, TouchableOpacity, View, Platform } from 'react-native';
3
+ import { StyleSheet, TouchableOpacity, View, SafeAreaView } from 'react-native';
4
4
  import { useCountdownTimer } from '../../../../../../src/hooks/useCountdownTimer';
5
5
  import { useLanguage } from 'ordering-components/native';
6
6
  import { OTPContainer } from './styles';
@@ -87,20 +87,19 @@ export const Otp = (props: otpParams) => {
87
87
  fontSize: 16
88
88
  },
89
89
  wrapperIcon: {
90
- marginTop: Platform.OS === 'ios' ? 40 : 12,
91
- marginBottom: 20,
92
90
  alignItems: 'center',
93
91
  justifyContent: 'center',
94
- paddingRight: 35
92
+ paddingRight: 20
95
93
  },
96
94
  closeContainer: {
97
95
  width: '100%',
98
96
  flexDirection: 'row',
97
+ alignItems: 'center'
99
98
  }
100
99
  });
101
100
 
102
101
  return (
103
- <>
102
+ <SafeAreaView style={{ flex: 1, backgroundColor: theme.colors.backgroundPage }}>
104
103
  <OTPContainer>
105
104
  <View
106
105
  style={loginStyle.closeContainer}>
@@ -110,9 +109,7 @@ export const Otp = (props: otpParams) => {
110
109
  width={22}
111
110
  />
112
111
  </TouchableOpacity>
113
- <OText size={22} style={{
114
- marginTop: 5
115
- }}>
112
+ <OText size={22}>
116
113
  {t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
117
114
  </OText>
118
115
  </View>
@@ -150,6 +147,6 @@ export const Otp = (props: otpParams) => {
150
147
  text={t('CANCEL', 'Cancel')}
151
148
  />
152
149
  </OTPContainer>
153
- </>
150
+ </SafeAreaView>
154
151
  )
155
152
  }
@@ -179,7 +179,7 @@ const LoginFormUI = (props: LoginParams) => {
179
179
  vibrateApp()
180
180
  return
181
181
  }
182
- if (!values?.cellphone && otpType === 'cellphone') {
182
+ if (otpType === 'cellphone' && phoneInputData?.error && !phoneInputData?.phone?.cellphone) {
183
183
  showToast(ToastType.Error, t('PHONE_NUMBER_REQUIRED', 'Phone number is required'));
184
184
  return
185
185
  }
@@ -195,38 +195,39 @@ const UserVerificationUI = (props: any) => {
195
195
  }
196
196
 
197
197
  useEffect(() => {
198
- let _timer = TIME_COUNTDOWN - 1;
199
- let minutes = 0;
200
- let seconds = 0;
201
- const interval = setInterval(() => {
202
- minutes = _timer / 60;
203
- seconds = _timer % 60;
204
-
205
- minutes = minutes < 10 ? 0 + minutes : minutes;
206
- seconds = seconds < 10 ? 0 + seconds : seconds;
207
-
208
- const formatMinutes = parseInt(minutes.toString()) < 10
209
- ? `0${parseInt(minutes.toString())}`
210
- : parseInt(minutes.toString());
211
-
212
- const formatseconds = parseInt(seconds.toString()) < 10
213
- ? `0${parseInt(seconds.toString())}`
214
- : parseInt(seconds.toString());
215
-
216
- setTimer(`${formatMinutes}:${formatseconds}`);
217
-
218
- if (--_timer < 0) {
219
- clearInterval(interval);
220
- }
221
-
222
- if (timer === `${TIME_COUNTDOWN / 60}:00` && isSendCodeAgain) {
223
- setIsSendCodeAgain(false)
224
- clearInterval(interval);
225
- }
226
- }, 1000);
227
-
228
- return () => clearInterval(interval)
229
- }, [isSendCodeAgain])
198
+ if (verificationState.phone) {
199
+ let _timer = TIME_COUNTDOWN - 1;
200
+ let minutes = 0;
201
+ let seconds = 0;
202
+ const interval = setInterval(() => {
203
+ minutes = _timer / 60;
204
+ seconds = _timer % 60;
205
+
206
+ minutes = minutes < 10 ? 0 + minutes : minutes;
207
+ seconds = seconds < 10 ? 0 + seconds : seconds;
208
+
209
+ const formatMinutes = parseInt(minutes.toString()) < 10
210
+ ? `0${parseInt(minutes.toString())}`
211
+ : parseInt(minutes.toString());
212
+
213
+ const formatseconds = parseInt(seconds.toString()) < 10
214
+ ? `0${parseInt(seconds.toString())}`
215
+ : parseInt(seconds.toString());
216
+
217
+ setTimer(`${formatMinutes}:${formatseconds}`);
218
+
219
+ if (--_timer < 0) {
220
+ clearInterval(interval);
221
+ }
222
+
223
+ if (timer === `${TIME_COUNTDOWN / 60}:00` && isSendCodeAgain) {
224
+ setIsSendCodeAgain(false)
225
+ clearInterval(interval);
226
+ }
227
+ }, 1000);
228
+ return () => clearInterval(interval)
229
+ }
230
+ }, [isSendCodeAgain, verificationState.phone])
230
231
 
231
232
  useEffect(() => {
232
233
  if (otpState?.length === CODE_LENGTH) {
@@ -460,23 +461,25 @@ const UserVerificationUI = (props: any) => {
460
461
  )}
461
462
 
462
463
  </Container>
463
- <ButtonsActions>
464
- <View style={{ width: '100%' }}>
465
- <OButton
466
- onClick={(verificationState.email || verificationState.phone)
467
- ? () => setVerificationState({ email: false, phone: false })
468
- : () => handleSendOtp(isPhoneVerifyRequired && !isEmailVerifyRequired ? 'phone' : '')
469
- }
470
- text={(verificationState.email || verificationState.phone) ? t('CANCEL', 'Cancel') : t('SEND_CODE', 'Send code')}
471
- bgColor={(verificationState.email || verificationState.phone) ? theme.colors.secundary : theme.colors.primary}
472
- borderColor={(verificationState.email || verificationState.phone) ? theme.colors.secundary : theme.colors.primary}
473
- textStyle={{ color: (verificationState.email || verificationState.phone) ? 'black' : 'white' }}
474
- imgRightSrc={null}
475
- isLoading={verifyEmailState?.loadingSendCode || verifyEmailState?.loadingCheckCode || verifyPhoneState?.loadingSendCode || verifyPhoneState?.loadingCheckCode}
476
- style={(verificationState.email || verificationState.phone) ? style.btnStyle : { borderRadius: 7.6 }}
477
- />
478
- </View>
479
- </ButtonsActions>
464
+ {!!phoneState?.cellphone && (
465
+ <ButtonsActions>
466
+ <View style={{ width: '100%' }}>
467
+ <OButton
468
+ onClick={(verificationState.email || verificationState.phone)
469
+ ? () => setVerificationState({ email: false, phone: false })
470
+ : () => handleSendOtp(isPhoneVerifyRequired && !isEmailVerifyRequired ? 'phone' : '')
471
+ }
472
+ text={(verificationState.email || verificationState.phone) ? t('CANCEL', 'Cancel') : t('SEND_CODE', 'Send code')}
473
+ bgColor={(verificationState.email || verificationState.phone) ? theme.colors.secundary : theme.colors.primary}
474
+ borderColor={(verificationState.email || verificationState.phone) ? theme.colors.secundary : theme.colors.primary}
475
+ textStyle={{ color: (verificationState.email || verificationState.phone) ? 'black' : 'white' }}
476
+ imgRightSrc={null}
477
+ isLoading={verifyEmailState?.loadingSendCode || verifyEmailState?.loadingCheckCode || verifyPhoneState?.loadingSendCode || verifyPhoneState?.loadingCheckCode}
478
+ style={(verificationState.email || verificationState.phone) ? style.btnStyle : { borderRadius: 7.6 }}
479
+ />
480
+ </View>
481
+ </ButtonsActions>
482
+ )}
480
483
  <View style={{ paddingHorizontal: 20, paddingBottom: 80 }}>
481
484
  <UserDetails
482
485
  user={user}