ordering-ui-react-native 0.17.31-release → 0.17.32-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.
- package/package.json +1 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +55 -7
- package/themes/original/src/components/LoginForm/index.tsx +23 -25
- package/themes/original/src/components/SingleProductCard/index.tsx +2 -2
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -1
- package/themes/original/src/components/StripeCardsList/index.tsx +6 -3
- package/themes/original/src/types/index.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
2
2
|
import { formatSeconds } from '../../../utils'
|
|
3
|
-
import { StyleSheet, TouchableOpacity } from 'react-native';
|
|
3
|
+
import { StyleSheet, TouchableOpacity, View, Platform } 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';
|
|
7
|
-
import { OText, OButton } from '../../shared';
|
|
7
|
+
import { OText, OButton, OIcon } from '../../shared';
|
|
8
8
|
import OtpInputs from 'react-native-otp-inputs';
|
|
9
9
|
import { useTheme } from 'styled-components/native';
|
|
10
10
|
import { otpParams } from '../../../types'
|
|
@@ -16,7 +16,9 @@ export const Otp = (props: otpParams) => {
|
|
|
16
16
|
onSubmit,
|
|
17
17
|
handleLoginOtp,
|
|
18
18
|
setAlertState,
|
|
19
|
-
pinCount
|
|
19
|
+
pinCount,
|
|
20
|
+
otpError,
|
|
21
|
+
setOtpError
|
|
20
22
|
} = props
|
|
21
23
|
|
|
22
24
|
const theme = useTheme();
|
|
@@ -25,7 +27,7 @@ export const Otp = (props: otpParams) => {
|
|
|
25
27
|
600, willVerifyOtpState)
|
|
26
28
|
|
|
27
29
|
const [code, setCode] = useState('')
|
|
28
|
-
|
|
30
|
+
const inputRef = useRef<any>()
|
|
29
31
|
|
|
30
32
|
const handleOnSubmit = () => {
|
|
31
33
|
setAlertState({
|
|
@@ -36,6 +38,16 @@ export const Otp = (props: otpParams) => {
|
|
|
36
38
|
onSubmit()
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
const handleChangeCode = (code : string) => {
|
|
42
|
+
setCode(code)
|
|
43
|
+
setOtpError(null)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const handleCloseOtp = () => {
|
|
47
|
+
setWillVerifyOtpState(false)
|
|
48
|
+
setOtpError(null)
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
useEffect(() => {
|
|
40
52
|
if (otpLeftTime === 0) {
|
|
41
53
|
setAlertState({
|
|
@@ -49,6 +61,7 @@ export const Otp = (props: otpParams) => {
|
|
|
49
61
|
useEffect(() => {
|
|
50
62
|
if (code?.length === (pinCount || 6)) {
|
|
51
63
|
handleLoginOtp(code)
|
|
64
|
+
inputRef?.current?.reset()
|
|
52
65
|
}
|
|
53
66
|
}, [code])
|
|
54
67
|
|
|
@@ -73,28 +86,63 @@ export const Otp = (props: otpParams) => {
|
|
|
73
86
|
color: theme.colors.primary,
|
|
74
87
|
fontSize: 16
|
|
75
88
|
},
|
|
89
|
+
wrapperIcon: {
|
|
90
|
+
marginTop: Platform.OS === 'ios' ? 40 : 12,
|
|
91
|
+
marginBottom: 20,
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
justifyContent: 'center',
|
|
94
|
+
paddingRight: 35
|
|
95
|
+
},
|
|
96
|
+
closeContainer: {
|
|
97
|
+
width: '100%',
|
|
98
|
+
flexDirection: 'row',
|
|
99
|
+
}
|
|
76
100
|
});
|
|
77
101
|
|
|
78
102
|
return (
|
|
79
103
|
<>
|
|
80
104
|
<OTPContainer>
|
|
105
|
+
<View
|
|
106
|
+
style={loginStyle.closeContainer}>
|
|
107
|
+
<TouchableOpacity onPress={() => handleCloseOtp()} style={loginStyle.wrapperIcon}>
|
|
108
|
+
<OIcon
|
|
109
|
+
src={theme.images.general.close}
|
|
110
|
+
width={22}
|
|
111
|
+
/>
|
|
112
|
+
</TouchableOpacity>
|
|
113
|
+
<OText size={22} style={{
|
|
114
|
+
marginTop: 5
|
|
115
|
+
}}>
|
|
116
|
+
{t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
|
|
117
|
+
</OText>
|
|
118
|
+
</View>
|
|
81
119
|
<OText size={24}>
|
|
82
120
|
{formatSeconds(otpLeftTime)}
|
|
83
121
|
</OText>
|
|
84
122
|
<OtpInputs
|
|
123
|
+
ref={inputRef}
|
|
85
124
|
autofillFromClipboard
|
|
86
125
|
numberOfInputs={pinCount || 6}
|
|
87
126
|
style={loginStyle.container}
|
|
88
127
|
inputStyles={loginStyle.underlineStyleBase}
|
|
89
|
-
handleChange={
|
|
128
|
+
handleChange={handleChangeCode}
|
|
90
129
|
/>
|
|
130
|
+
{!!otpError && (
|
|
131
|
+
<OText
|
|
132
|
+
color={theme?.colors?.error}
|
|
133
|
+
size={20}
|
|
134
|
+
mBottom={10}
|
|
135
|
+
>
|
|
136
|
+
{t(otpError, otpError)}
|
|
137
|
+
</OText>
|
|
138
|
+
)}
|
|
91
139
|
<TouchableOpacity onPress={() => handleOnSubmit()} disabled={otpLeftTime > 520}>
|
|
92
140
|
<OText size={16} mBottom={30} color={otpLeftTime > 520 ? theme.colors.disabled : theme.colors.primary}>
|
|
93
141
|
{t('RESEND_CODE', 'Resend code')}
|
|
94
142
|
</OText>
|
|
95
143
|
</TouchableOpacity>
|
|
96
144
|
<OButton
|
|
97
|
-
onClick={() =>
|
|
145
|
+
onClick={() => handleCloseOtp()}
|
|
98
146
|
bgColor={theme.colors.white}
|
|
99
147
|
borderColor={theme.colors.primary}
|
|
100
148
|
textStyle={{ color: theme.colors.primary }}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { StyleSheet, View, Keyboard,
|
|
2
|
+
import { StyleSheet, View, Keyboard, Modal } from 'react-native';
|
|
3
3
|
import Spinner from 'react-native-loading-spinner-overlay';
|
|
4
4
|
import { useForm, Controller } from 'react-hook-form';
|
|
5
5
|
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
@@ -97,6 +97,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
97
97
|
const [recaptchaVerified, setRecaptchaVerified] = useState(false)
|
|
98
98
|
const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
|
|
99
99
|
const [tabLayouts, setTabLayouts] = useState<any>({})
|
|
100
|
+
const [otpError, setOtpError] = useState(null)
|
|
100
101
|
const tabsRef = useRef<any>(null)
|
|
101
102
|
const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
|
|
102
103
|
const theme = useTheme();
|
|
@@ -175,7 +176,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
175
176
|
if (loginTab === 'otp') {
|
|
176
177
|
if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
|
|
177
178
|
showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
|
|
178
|
-
|
|
179
|
+
vibrateApp()
|
|
179
180
|
return
|
|
180
181
|
}
|
|
181
182
|
if (!values?.cellphone && otpType === 'cellphone') {
|
|
@@ -192,7 +193,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
192
193
|
} else {
|
|
193
194
|
if (phoneInputData.error) {
|
|
194
195
|
showToast(ToastType.Error, phoneInputData.error);
|
|
195
|
-
|
|
196
|
+
vibrateApp()
|
|
196
197
|
return;
|
|
197
198
|
}
|
|
198
199
|
handleButtonLoginClick({
|
|
@@ -205,7 +206,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
205
206
|
const handleVerifyCodeClick = () => {
|
|
206
207
|
if (phoneInputData.error) {
|
|
207
208
|
showToast(ToastType.Error, phoneInputData.error);
|
|
208
|
-
|
|
209
|
+
vibrateApp()
|
|
209
210
|
return;
|
|
210
211
|
}
|
|
211
212
|
if (
|
|
@@ -220,7 +221,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
220
221
|
'The field Mobile phone is required.',
|
|
221
222
|
),
|
|
222
223
|
);
|
|
223
|
-
|
|
224
|
+
vibrateApp()
|
|
224
225
|
return;
|
|
225
226
|
}
|
|
226
227
|
handleSendVerifyCode && handleSendVerifyCode(phoneInputData.phone);
|
|
@@ -242,12 +243,12 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
242
243
|
setRecaptchaVerified(false)
|
|
243
244
|
if (!recaptchaConfig?.siteKey) {
|
|
244
245
|
showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
|
|
245
|
-
|
|
246
|
+
vibrateApp()
|
|
246
247
|
return
|
|
247
248
|
}
|
|
248
249
|
if (!recaptchaConfig?.baseUrl) {
|
|
249
250
|
showToast(ToastType.Error, t('NO_RECAPTCHA_BASE_URL', 'The config doesn\'t have recaptcha base url'));
|
|
250
|
-
|
|
251
|
+
vibrateApp()
|
|
251
252
|
return
|
|
252
253
|
}
|
|
253
254
|
|
|
@@ -270,11 +271,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
270
271
|
if (logged) {
|
|
271
272
|
setWillVerifyOtpState(false)
|
|
272
273
|
} else {
|
|
273
|
-
|
|
274
|
-
open: true,
|
|
275
|
-
title: '',
|
|
276
|
-
content: t('OTP_CODE_INCORRECT', 'Otp code incorrect')
|
|
277
|
-
})
|
|
274
|
+
setOtpError(t('OTP_CODE_INCORRECT', 'Otp code incorrect'))
|
|
278
275
|
}
|
|
279
276
|
}
|
|
280
277
|
|
|
@@ -333,7 +330,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
333
330
|
baseUrl: configs?.security_recaptcha_base_url?.value || null
|
|
334
331
|
})
|
|
335
332
|
showToast(ToastType.Info, t('TRY_AGAIN', 'Please try again'))
|
|
336
|
-
|
|
333
|
+
vibrateApp()
|
|
337
334
|
return
|
|
338
335
|
}
|
|
339
336
|
formState.result?.result &&
|
|
@@ -343,7 +340,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
343
340
|
? formState.result?.result
|
|
344
341
|
: formState.result?.result[0],
|
|
345
342
|
);
|
|
346
|
-
formState.result?.result &&
|
|
343
|
+
formState.result?.result && vibrateApp()
|
|
347
344
|
}
|
|
348
345
|
}, [formState]);
|
|
349
346
|
|
|
@@ -355,7 +352,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
355
352
|
? verifyPhoneState?.result?.result
|
|
356
353
|
: verifyPhoneState?.result?.result[0];
|
|
357
354
|
verifyPhoneState.result?.result && showToast(ToastType.Error, message);
|
|
358
|
-
verifyPhoneState.result?.result &&
|
|
355
|
+
verifyPhoneState.result?.result && vibrateApp();
|
|
359
356
|
setIsLoadingVerifyModal(false);
|
|
360
357
|
return;
|
|
361
358
|
}
|
|
@@ -396,7 +393,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
396
393
|
}, [checkPhoneCodeState])
|
|
397
394
|
|
|
398
395
|
useEffect(() => {
|
|
399
|
-
if (!!Object.values(errors)?.length)
|
|
396
|
+
if (!!Object.values(errors)?.length) vibrateApp()
|
|
400
397
|
}, [errors])
|
|
401
398
|
|
|
402
399
|
return (
|
|
@@ -788,7 +785,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
788
785
|
facebookLoginEnabled && (
|
|
789
786
|
<FacebookLogin
|
|
790
787
|
notificationState={notificationState}
|
|
791
|
-
handleErrors={(err: any) => { showToast(ToastType.Error, err),
|
|
788
|
+
handleErrors={(err: any) => { showToast(ToastType.Error, err), vibrateApp() }}
|
|
792
789
|
handleLoading={(val: boolean) => setIsFBLoading(val)}
|
|
793
790
|
handleSuccessFacebookLogin={handleSuccessFacebook}
|
|
794
791
|
/>
|
|
@@ -797,7 +794,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
797
794
|
<GoogleLogin
|
|
798
795
|
notificationState={notificationState}
|
|
799
796
|
webClientId={configs?.google_login_client_id?.value}
|
|
800
|
-
handleErrors={(err: any) => { showToast(ToastType.Error, err),
|
|
797
|
+
handleErrors={(err: any) => { showToast(ToastType.Error, err), vibrateApp() }}
|
|
801
798
|
handleLoading={(val: boolean) => setIsFBLoading(val)}
|
|
802
799
|
handleSuccessGoogleLogin={handleSuccessFacebook}
|
|
803
800
|
/>
|
|
@@ -805,7 +802,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
805
802
|
{(configs?.apple_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && appleLoginEnabled && (
|
|
806
803
|
<AppleLogin
|
|
807
804
|
notificationState={notificationState}
|
|
808
|
-
handleErrors={(err: any) => { showToast(ToastType.Error, err),
|
|
805
|
+
handleErrors={(err: any) => { showToast(ToastType.Error, err), vibrateApp() }}
|
|
809
806
|
handleLoading={(val: boolean) => setIsFBLoading(val)}
|
|
810
807
|
handleSuccessAppleLogin={handleSuccessFacebook}
|
|
811
808
|
/>
|
|
@@ -851,20 +848,21 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
851
848
|
onClose={() => setIsModalVisible(false)}
|
|
852
849
|
/>
|
|
853
850
|
</OModal>
|
|
854
|
-
<
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
|
|
851
|
+
<Modal
|
|
852
|
+
visible={willVerifyOtpState}
|
|
853
|
+
onDismiss={() => setWillVerifyOtpState(false)}
|
|
854
|
+
animationType='slide'
|
|
859
855
|
>
|
|
860
856
|
<Otp
|
|
861
857
|
willVerifyOtpState={willVerifyOtpState}
|
|
858
|
+
otpError={otpError}
|
|
859
|
+
setOtpError={setOtpError}
|
|
862
860
|
setWillVerifyOtpState={setWillVerifyOtpState}
|
|
863
861
|
handleLoginOtp={handleLoginOtp}
|
|
864
862
|
onSubmit={onSubmit}
|
|
865
863
|
setAlertState={setAlertState}
|
|
866
864
|
/>
|
|
867
|
-
</
|
|
865
|
+
</Modal>
|
|
868
866
|
<Alert
|
|
869
867
|
open={alertState.open}
|
|
870
868
|
content={alertState.content}
|
|
@@ -169,7 +169,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
return (
|
|
172
|
-
<InView style={{ minHeight: hideAddButton ? 125 : 190 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
|
|
172
|
+
<InView style={{ minHeight: hideAddButton ? 125 : 190, marginLeft: logoPosition === 'left' ? 12.5 : 0 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
|
|
173
173
|
{isIntersectionObserver ? (
|
|
174
174
|
<CardAnimation
|
|
175
175
|
onClick={() => handleClickproduct()}
|
|
@@ -182,7 +182,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
|
|
|
182
182
|
<View style={{ flexDirection: logoPosition === 'left' ? 'row-reverse' : 'row' }}>
|
|
183
183
|
{productAddedToCartLength > 0 && (
|
|
184
184
|
<QuantityContainer businessSingleId={businessSingleId} style={[styles.quantityContainer, {
|
|
185
|
-
transform: [{ translateX: 25 }, { translateY: -25 }],
|
|
185
|
+
transform: [{ translateX: logoPosition === 'right' ? 25 : -25 }, { translateY: -25 }],
|
|
186
186
|
}]}>
|
|
187
187
|
<OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
|
|
188
188
|
</QuantityContainer>
|
|
@@ -18,14 +18,15 @@ import {
|
|
|
18
18
|
OSItemActions,
|
|
19
19
|
} from '../PaymentOptionStripe/styles';
|
|
20
20
|
|
|
21
|
-
const StripeCardsListUI = (props: any) => {
|
|
21
|
+
export const StripeCardsListUI = (props: any) => {
|
|
22
22
|
const {
|
|
23
23
|
onSelectCard,
|
|
24
24
|
deleteCard,
|
|
25
25
|
cardSelected,
|
|
26
26
|
cardsList,
|
|
27
27
|
handleCardClick,
|
|
28
|
-
setAddCardOpen
|
|
28
|
+
setAddCardOpen,
|
|
29
|
+
gateway
|
|
29
30
|
} = props;
|
|
30
31
|
|
|
31
32
|
const theme = useTheme();
|
|
@@ -33,13 +34,15 @@ const StripeCardsListUI = (props: any) => {
|
|
|
33
34
|
const [{ token }] = useSession();
|
|
34
35
|
const [, t] = useLanguage();
|
|
35
36
|
|
|
37
|
+
const paymethodsWithoutSaveCards = ['credomatic']
|
|
38
|
+
|
|
36
39
|
const handleCardSelected = (card: any) => {
|
|
37
40
|
handleCardClick(card);
|
|
38
41
|
onSelectCard(card);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
useEffect(() => {
|
|
42
|
-
if (!cardsList && !cardsList?.loading && cardsList?.cards?.length === 0) {
|
|
45
|
+
if (!cardsList && !cardsList?.loading && cardsList?.cards?.length === 0 && !paymethodsWithoutSaveCards.includes(gateway)) {
|
|
43
46
|
setAddCardOpen(true)
|
|
44
47
|
}
|
|
45
48
|
}, [cardsList?.loading])
|