ordering-ui-react-native 0.23.58 → 0.23.60
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/Checkout/index.tsx +2 -5
- package/themes/original/src/components/LoginForm/index.tsx +8 -2
- package/themes/original/src/components/PhoneInputNumber/index.tsx +17 -3
- package/themes/original/src/components/ProductItemAccordion/index.tsx +27 -36
- package/themes/original/src/components/SignupForm/index.tsx +16 -10
- package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
- package/themes/original/src/components/UserFormDetails/index.tsx +6 -4
- package/themes/original/src/types/index.tsx +5 -2
package/package.json
CHANGED
|
@@ -264,14 +264,11 @@ const CheckoutUI = (props: any) => {
|
|
|
264
264
|
ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
const handleSuccessSignup = (user: any) => {
|
|
268
|
-
login({
|
|
267
|
+
const handleSuccessSignup = async (user: any) => {
|
|
268
|
+
await login({
|
|
269
269
|
user,
|
|
270
270
|
token: user?.session?.access_token
|
|
271
271
|
})
|
|
272
|
-
if (openModal?.isGuest && requiredFields?.length === 0) {
|
|
273
|
-
openModal?.isGuest && handlePlaceOrderAsGuest()
|
|
274
|
-
}
|
|
275
272
|
setOpenModal({ ...openModal, signup: false, isGuest: false })
|
|
276
273
|
}
|
|
277
274
|
|
|
@@ -73,7 +73,8 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
73
73
|
generateOtpCode,
|
|
74
74
|
useLoginOtpEmail,
|
|
75
75
|
useLoginOtpCellphone,
|
|
76
|
-
isGuest
|
|
76
|
+
isGuest,
|
|
77
|
+
setCellphoneStartZero
|
|
77
78
|
} = props;
|
|
78
79
|
|
|
79
80
|
const [, { showToast }] = useToast();
|
|
@@ -300,6 +301,11 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
300
301
|
setTabLayouts(_tabLayouts)
|
|
301
302
|
}
|
|
302
303
|
|
|
304
|
+
const handleChangePhoneNumber = (number : any, rawNumber: any) => {
|
|
305
|
+
setPhoneInputData(number)
|
|
306
|
+
setCellphoneStartZero && setCellphoneStartZero(rawNumber?.number && rawNumber?.countryCallingCode ? rawNumber?.number : null)
|
|
307
|
+
}
|
|
308
|
+
|
|
303
309
|
useEffect(() => {
|
|
304
310
|
if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
|
|
305
311
|
if (configs?.security_recaptcha_type?.value === 'v3' &&
|
|
@@ -586,7 +592,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
586
592
|
<View style={{ marginBottom: 28 }}>
|
|
587
593
|
<PhoneInputNumber
|
|
588
594
|
data={phoneInputData}
|
|
589
|
-
handleData={
|
|
595
|
+
handleData={handleChangePhoneNumber}
|
|
590
596
|
textInputProps={{
|
|
591
597
|
returnKeyType: 'next',
|
|
592
598
|
onSubmitEditing: () => passwordRef?.current?.focus?.(),
|
|
@@ -42,6 +42,8 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
42
42
|
})
|
|
43
43
|
const isDisableNumberValidation = parseInt(configs?.validation_phone_number_lib?.value ?? 1, 10)
|
|
44
44
|
const countriesWithSubOptions = ['PR']
|
|
45
|
+
const codesStartsWithZero: any = ['44']
|
|
46
|
+
|
|
45
47
|
const style = StyleSheet.create({
|
|
46
48
|
input: {
|
|
47
49
|
backgroundColor: theme.colors.white,
|
|
@@ -69,13 +71,22 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
69
71
|
useEffect(() => {
|
|
70
72
|
if ((defaultValue && userphoneNumber) || !defaultValue) {
|
|
71
73
|
if (userphoneNumber) {
|
|
72
|
-
const
|
|
74
|
+
const validationsForUK = ['01', '02', '07', '0800', '0808', '0845', '0870', '0871']
|
|
75
|
+
|
|
76
|
+
let isPossibly = false
|
|
77
|
+
let numberWithoutCountryCode = ''
|
|
73
78
|
const callingCode = phoneInput.current?.getCallingCode();
|
|
79
|
+
const cellphone = userphoneNumber.slice(0, 0) + userphoneNumber.slice(1, userphoneNumber.length)
|
|
80
|
+
if (codesStartsWithZero.includes(callingCode)) {
|
|
81
|
+
numberWithoutCountryCode = cellphone.replace(callingCode || '', '')
|
|
82
|
+
const result = validationsForUK.some(areaCode => numberWithoutCountryCode?.startsWith(areaCode))
|
|
83
|
+
isPossibly = result && numberWithoutCountryCode?.length >= 10 && numberWithoutCountryCode?.length < 12
|
|
84
|
+
}
|
|
85
|
+
const checkValid = phoneInput.current?.isValidNumber(userphoneNumber);
|
|
74
86
|
const formattedNumber = phoneInput.current?.getNumberAfterPossiblyEliminatingZero();
|
|
75
87
|
const regex = /^[0-9]*$/
|
|
76
|
-
const cellphone = userphoneNumber.slice(0, 0) + userphoneNumber.slice(1, userphoneNumber.length)
|
|
77
88
|
const validNumber = regex.test(cellphone)
|
|
78
|
-
if (((!checkValid && formattedNumber?.number) || !validNumber) && !!isDisableNumberValidation) {
|
|
89
|
+
if (((!checkValid && formattedNumber?.number && !isPossibly) || !validNumber) && !!isDisableNumberValidation) {
|
|
79
90
|
handleData && handleData({
|
|
80
91
|
...data,
|
|
81
92
|
error: t('INVALID_ERROR_PHONE_NUMBER', 'The Phone Number field is invalid')
|
|
@@ -89,6 +100,9 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
89
100
|
country_phone_code: callingCode,
|
|
90
101
|
cellphone: !isDisableNumberValidation ? cellphone.slice(callingCode?.length) : formattedNumber?.number
|
|
91
102
|
}
|
|
103
|
+
}, {
|
|
104
|
+
countryCallingCode: callingCode,
|
|
105
|
+
number: numberWithoutCountryCode,
|
|
92
106
|
})
|
|
93
107
|
} else {
|
|
94
108
|
handleData && handleData({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import { View, Animated, StyleSheet, TouchableOpacity } from 'react-native'
|
|
3
|
-
import { useUtils, useLanguage, useOrder } from 'ordering-components/native'
|
|
3
|
+
import { useUtils, useLanguage, useOrder, ProductItemAccordion as ProductItemAccordionController } from 'ordering-components/native'
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
6
6
|
import RNPickerSelect from 'react-native-picker-select'
|
|
@@ -24,7 +24,7 @@ import { OIcon, OText, OAlert, OModal } from '../shared'
|
|
|
24
24
|
|
|
25
25
|
import { ProductItemAccordionParams } from '../../types'
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const ProductItemAccordionUI = (props: ProductItemAccordionParams) => {
|
|
28
28
|
|
|
29
29
|
const {
|
|
30
30
|
isDisabledEdit,
|
|
@@ -36,6 +36,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
36
36
|
onDeleteProduct,
|
|
37
37
|
onEditProduct,
|
|
38
38
|
isFromCheckout,
|
|
39
|
+
productInfo
|
|
39
40
|
} = props
|
|
40
41
|
|
|
41
42
|
const theme = useTheme();
|
|
@@ -46,6 +47,14 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
46
47
|
const hideProductDummyLogo = theme?.business_view?.components?.products?.components?.product?.components?.dummy?.hidden
|
|
47
48
|
const hideProductCommentHide = isFromCheckout && theme?.checkout?.components?.cart?.components?.product?.components?.comments?.hidden
|
|
48
49
|
|
|
50
|
+
const styles = StyleSheet.create({
|
|
51
|
+
productImage: {
|
|
52
|
+
borderRadius: 7.6,
|
|
53
|
+
width: 48,
|
|
54
|
+
height: 48
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
49
58
|
const pickerStyle = StyleSheet.create({
|
|
50
59
|
inputAndroid: {
|
|
51
60
|
width: 45,
|
|
@@ -91,24 +100,6 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
91
100
|
const [isServiceOpen, setIsServiceOpen] = useState(false)
|
|
92
101
|
const [productQuantityState, setProductQuantityState] = useState<any>(product.quantity.toString())
|
|
93
102
|
|
|
94
|
-
const productInfo = () => {
|
|
95
|
-
if (isCartProduct) {
|
|
96
|
-
const ingredients = JSON.parse(JSON.stringify(Object.values(product.ingredients ?? {})))
|
|
97
|
-
let options = JSON.parse(JSON.stringify(Object.values(product.options ?? {})))
|
|
98
|
-
|
|
99
|
-
options = options.map((option: any) => {
|
|
100
|
-
option.suboptions = Object.values(option.suboptions ?? {})
|
|
101
|
-
return option
|
|
102
|
-
})
|
|
103
|
-
return {
|
|
104
|
-
...productInfo,
|
|
105
|
-
ingredients,
|
|
106
|
-
options
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return product
|
|
110
|
-
}
|
|
111
|
-
|
|
112
103
|
const handleEditProduct = (curProduct: any) => {
|
|
113
104
|
if (!curProduct?.calendar_event) {
|
|
114
105
|
onEditProduct && onEditProduct(curProduct)
|
|
@@ -154,8 +145,8 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
154
145
|
isValid={product?.valid ?? true}
|
|
155
146
|
onPress={
|
|
156
147
|
(!product?.valid_menu && isCartProduct) ||
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
!(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment)
|
|
149
|
+
? null : () => setActiveState(!isActive)
|
|
159
150
|
}
|
|
160
151
|
>
|
|
161
152
|
<View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>
|
|
@@ -246,7 +237,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
246
237
|
<View style={{ display: 'flex', flexDirection: 'column', flex: 1, alignItems: 'flex-end', maxWidth: 100 }}>
|
|
247
238
|
<View style={{ flexDirection: 'row' }}>
|
|
248
239
|
<OText size={12} lineHeight={18} weight={'400'}>{parsePrice(product.total || product.price)}</OText>
|
|
249
|
-
{(productInfo
|
|
240
|
+
{(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment) && (
|
|
250
241
|
<MaterialCommunityIcon name='chevron-down' size={18} />
|
|
251
242
|
)}
|
|
252
243
|
</View>
|
|
@@ -290,17 +281,17 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
290
281
|
<View style={{ display: isActive ? 'flex' : 'none', paddingStart: isFromCheckout ? 100 : 40, marginTop: isFromCheckout ? -80 : -30 }}>
|
|
291
282
|
<Animated.View>
|
|
292
283
|
<AccordionContent>
|
|
293
|
-
{productInfo
|
|
284
|
+
{productInfo.ingredients.length > 0 && productInfo.ingredients.some((ingredient: any) => !ingredient.selected) && (
|
|
294
285
|
<ProductOptionsList>
|
|
295
286
|
<OText size={10} color={theme.colors.textSecondary}>{t('INGREDIENTS', 'Ingredients')}</OText>
|
|
296
|
-
{productInfo
|
|
287
|
+
{productInfo.ingredients.map((ingredient: any, i) => !ingredient.selected && (
|
|
297
288
|
<OText size={10} color={theme.colors.textThird} key={ingredient.id + i} style={{ marginLeft: 10 }}>{t('NO', 'No')} {ingredient.name}</OText>
|
|
298
289
|
))}
|
|
299
290
|
</ProductOptionsList>
|
|
300
291
|
)}
|
|
301
|
-
{productInfo
|
|
292
|
+
{productInfo.options.length > 0 && (
|
|
302
293
|
<ProductOptionsList>
|
|
303
|
-
{productInfo
|
|
294
|
+
{productInfo.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => (
|
|
304
295
|
<ProductOption key={option.id}>
|
|
305
296
|
<OText size={10} color={theme.colors.textSecondary}>{option.name}</OText>
|
|
306
297
|
{option.suboptions.map((suboption: any) => (
|
|
@@ -350,13 +341,13 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
350
341
|
)
|
|
351
342
|
}
|
|
352
343
|
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
height: 48
|
|
358
|
-
},
|
|
359
|
-
test: {
|
|
360
|
-
overflow: 'hidden',
|
|
344
|
+
export const ProductItemAccordion = (props: any) => {
|
|
345
|
+
const productItemAccordionProps = {
|
|
346
|
+
...props,
|
|
347
|
+
UIComponent: ProductItemAccordionUI
|
|
361
348
|
}
|
|
362
|
-
|
|
349
|
+
|
|
350
|
+
return (
|
|
351
|
+
<ProductItemAccordionController {...productItemAccordionProps} />
|
|
352
|
+
)
|
|
353
|
+
}
|
|
@@ -83,7 +83,8 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
83
83
|
useSignUpFullDetails,
|
|
84
84
|
useSignUpOtpEmail,
|
|
85
85
|
useSignUpOtpCellphone,
|
|
86
|
-
isGuest
|
|
86
|
+
isGuest,
|
|
87
|
+
setCellphoneStartZero
|
|
87
88
|
} = props;
|
|
88
89
|
|
|
89
90
|
const theme = useTheme();
|
|
@@ -366,6 +367,19 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
366
367
|
handleReCaptcha && handleReCaptcha({ code: token, version: recaptchaConfig?.version })
|
|
367
368
|
}
|
|
368
369
|
|
|
370
|
+
const handleChangePhoneNumber = (number : any, rawNumber: any) => {
|
|
371
|
+
setPhoneInputData({
|
|
372
|
+
...phoneInputData,
|
|
373
|
+
...number,
|
|
374
|
+
phone: {
|
|
375
|
+
...phoneInputData.phone,
|
|
376
|
+
...number.phone,
|
|
377
|
+
country_code: phoneInputData.phone.country_code
|
|
378
|
+
}
|
|
379
|
+
})
|
|
380
|
+
setCellphoneStartZero && setCellphoneStartZero(rawNumber?.number && rawNumber?.countryCallingCode ? rawNumber?.number : null)
|
|
381
|
+
}
|
|
382
|
+
|
|
369
383
|
useEffect(() => {
|
|
370
384
|
if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
|
|
371
385
|
if (configs?.security_recaptcha_type?.value === 'v3' &&
|
|
@@ -657,15 +671,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
657
671
|
<View style={{ marginBottom: 25 }}>
|
|
658
672
|
<PhoneInputNumber
|
|
659
673
|
data={phoneInputData}
|
|
660
|
-
handleData={
|
|
661
|
-
...phoneInputData,
|
|
662
|
-
...val,
|
|
663
|
-
phone: {
|
|
664
|
-
...phoneInputData.phone,
|
|
665
|
-
...val.phone,
|
|
666
|
-
country_code: phoneInputData.phone.country_code
|
|
667
|
-
}
|
|
668
|
-
})}
|
|
674
|
+
handleData={handleChangePhoneNumber}
|
|
669
675
|
forwardRef={phoneRef}
|
|
670
676
|
changeCountry={(val: any) => setPhoneInputData({
|
|
671
677
|
...phoneInputData,
|
|
@@ -66,7 +66,7 @@ export const StripeCardsListUI = (props: any) => {
|
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
const hasCardSelected = cardsList?.cards?.some?.((card : any) => card?.id === paySelected?.data?.id)
|
|
68
68
|
setUserHasCards && setUserHasCards(cardsList?.cards?.length > 0 && hasCardSelected)
|
|
69
|
-
}, [cardsList?.cards?.length])
|
|
69
|
+
}, [cardsList?.cards?.length, paySelected])
|
|
70
70
|
|
|
71
71
|
return (
|
|
72
72
|
<>
|
|
@@ -42,7 +42,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
42
42
|
isGuest,
|
|
43
43
|
isOrderTypeValidationField,
|
|
44
44
|
checkoutFields,
|
|
45
|
-
isCheckoutPlace
|
|
45
|
+
isCheckoutPlace,
|
|
46
|
+
setCellphoneStartZero
|
|
46
47
|
} = props;
|
|
47
48
|
|
|
48
49
|
const theme = useTheme();
|
|
@@ -185,7 +186,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
185
186
|
formState.changes?.cellphone === null &&
|
|
186
187
|
((validationFields?.fields?.checkout?.cellphone?.enabled &&
|
|
187
188
|
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
188
|
-
(configs?.verification_phone_required?.value === '1' && !user?.guest_id))
|
|
189
|
+
(configs?.verification_phone_required?.value === '1' && !user?.guest_id))
|
|
189
190
|
) {
|
|
190
191
|
content = content + `${t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone Number is required.',)}\n`
|
|
191
192
|
showToast(ToastType.Error, content);
|
|
@@ -207,7 +208,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
207
208
|
}
|
|
208
209
|
};
|
|
209
210
|
|
|
210
|
-
const handleChangePhoneNumber = (number: any) => {
|
|
211
|
+
const handleChangePhoneNumber = (number: any, rawNumber : any) => {
|
|
211
212
|
setPhoneInputData(number);
|
|
212
213
|
setIsChanged(true)
|
|
213
214
|
let phoneNumber = {
|
|
@@ -220,6 +221,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
220
221
|
value: number.phone.cellphone,
|
|
221
222
|
},
|
|
222
223
|
};
|
|
224
|
+
setCellphoneStartZero && setCellphoneStartZero(rawNumber?.number && rawNumber?.countryCallingCode ? rawNumber?.number : null)
|
|
223
225
|
handleChangeInput(phoneNumber, true);
|
|
224
226
|
};
|
|
225
227
|
|
|
@@ -428,7 +430,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
428
430
|
<OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
|
|
429
431
|
<PhoneInputNumber
|
|
430
432
|
data={phoneInputData}
|
|
431
|
-
handleData={
|
|
433
|
+
handleData={handleChangePhoneNumber}
|
|
432
434
|
changeCountry={(val: any) => changeCountry(val)}
|
|
433
435
|
defaultValue={phoneUpdate ? '' : cellphoneValue()}
|
|
434
436
|
defaultCode={user?.country_code ?? user?.country_phone_code ?? null}
|
|
@@ -25,7 +25,8 @@ export interface LoginParams {
|
|
|
25
25
|
generateOtpCode: (values?: any) => void,
|
|
26
26
|
useLoginOtpEmail?: boolean,
|
|
27
27
|
useLoginOtpCellphone?: boolean,
|
|
28
|
-
useLoginOtp?: boolean
|
|
28
|
+
useLoginOtp?: boolean,
|
|
29
|
+
setCellphoneStartZero?: any
|
|
29
30
|
}
|
|
30
31
|
export interface ProfileParams {
|
|
31
32
|
navigation?: any;
|
|
@@ -131,6 +132,7 @@ export interface SignupParams {
|
|
|
131
132
|
setSignUpTab?: (in1: string) => void;
|
|
132
133
|
setWillVerifyOtpState?: (in1: boolean) => void;
|
|
133
134
|
setOtpState?: (in1: string) => void;
|
|
135
|
+
setCellphoneStartZero?: any
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
export interface PhoneInputParams {
|
|
@@ -453,7 +455,8 @@ export interface ProductItemAccordionParams {
|
|
|
453
455
|
onEditProduct?: (product: any) => void,
|
|
454
456
|
offsetDisabled?: any,
|
|
455
457
|
isFromCheckout?: any,
|
|
456
|
-
isDisabledEdit?: any
|
|
458
|
+
isDisabledEdit?: any,
|
|
459
|
+
productInfo?: any
|
|
457
460
|
}
|
|
458
461
|
export interface ReviewOrderParams {
|
|
459
462
|
order?: { id: number, business_id: number, logo: string, driver: any, products: Array<any>, review: any, user_review: any };
|