ordering-ui-react-native 0.23.57 → 0.23.59
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 +8 -7
- package/themes/original/src/components/LoginForm/index.tsx +8 -2
- package/themes/original/src/components/MomentOption/index.tsx +2 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +4 -1
- package/themes/original/src/components/PhoneInputNumber/index.tsx +17 -3
- package/themes/original/src/components/SignupForm/index.tsx +16 -10
- package/themes/original/src/components/StripeCardsList/index.tsx +7 -1
- package/themes/original/src/components/UserFormDetails/index.tsx +6 -4
- package/themes/original/src/types/index.tsx +3 -1
package/package.json
CHANGED
|
@@ -175,9 +175,12 @@ const CheckoutUI = (props: any) => {
|
|
|
175
175
|
const [showTitle, setShowTitle] = useState(false)
|
|
176
176
|
const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
|
|
177
177
|
const [isGiftCardCart, setIsGiftCardCart] = useState(!cart?.business_id)
|
|
178
|
+
const [userHasCards, setUserHasCards] = useState(false)
|
|
178
179
|
const containerRef = useRef<any>()
|
|
179
180
|
const cardsMethods = ['credomatic']
|
|
180
181
|
const stripePaymethods: any = ['stripe', 'stripe_connect', 'stripe_redirect']
|
|
182
|
+
const cardsPaymethods: any = ['stripe', 'stripe_connect']
|
|
183
|
+
|
|
181
184
|
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
|
|
182
185
|
|
|
183
186
|
const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field: any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
|
|
@@ -226,8 +229,8 @@ const CheckoutUI = (props: any) => {
|
|
|
226
229
|
validateCommentsCartField ||
|
|
227
230
|
validateDriverTipField ||
|
|
228
231
|
validateCouponField ||
|
|
229
|
-
validateZipcodeCard
|
|
230
|
-
|
|
232
|
+
validateZipcodeCard ||
|
|
233
|
+
(!userHasCards && cardsPaymethods.includes(paymethodSelected?.gateway))
|
|
231
234
|
|
|
232
235
|
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
233
236
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
@@ -261,14 +264,11 @@ const CheckoutUI = (props: any) => {
|
|
|
261
264
|
ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
|
|
262
265
|
}
|
|
263
266
|
|
|
264
|
-
const handleSuccessSignup = (user: any) => {
|
|
265
|
-
login({
|
|
267
|
+
const handleSuccessSignup = async (user: any) => {
|
|
268
|
+
await login({
|
|
266
269
|
user,
|
|
267
270
|
token: user?.session?.access_token
|
|
268
271
|
})
|
|
269
|
-
if (openModal?.isGuest && requiredFields?.length === 0) {
|
|
270
|
-
openModal?.isGuest && handlePlaceOrderAsGuest()
|
|
271
|
-
}
|
|
272
272
|
setOpenModal({ ...openModal, signup: false, isGuest: false })
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -868,6 +868,7 @@ const CheckoutUI = (props: any) => {
|
|
|
868
868
|
openUserModal={setIsOpen}
|
|
869
869
|
paymethodClicked={paymethodClicked}
|
|
870
870
|
setPaymethodClicked={setPaymethodClicked}
|
|
871
|
+
setUserHasCards={setUserHasCards}
|
|
871
872
|
/>
|
|
872
873
|
</ChPaymethods>
|
|
873
874
|
</ChSection>
|
|
@@ -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?.(),
|
|
@@ -377,7 +377,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
377
377
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
378
378
|
/>
|
|
379
379
|
)}
|
|
380
|
-
{(preorderMinimumDays === 0 && preorderLeadTime === 0) || !cateringPreorder && (
|
|
380
|
+
{((preorderMinimumDays === 0 && preorderLeadTime === 0) || !cateringPreorder) && (
|
|
381
381
|
<WrapSelectOption
|
|
382
382
|
onPress={() => _handleAsap()}
|
|
383
383
|
disabled={orderState.loading} style={{ alignItems: 'flex-start' }}>
|
|
@@ -510,4 +510,4 @@ export const MomentOption = (props: any) => {
|
|
|
510
510
|
UIComponent: MomentOptionUI,
|
|
511
511
|
};
|
|
512
512
|
return <MomentOptionController {...momentOptionProps} />;
|
|
513
|
-
};
|
|
513
|
+
};
|
|
@@ -76,7 +76,8 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
76
76
|
openUserModal,
|
|
77
77
|
paymethodClicked,
|
|
78
78
|
setPaymethodClicked,
|
|
79
|
-
androidAppId
|
|
79
|
+
androidAppId,
|
|
80
|
+
setUserHasCards
|
|
80
81
|
} = props
|
|
81
82
|
|
|
82
83
|
const theme = useTheme();
|
|
@@ -348,6 +349,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
348
349
|
businessId={props.businessId}
|
|
349
350
|
onPaymentChange={onPaymentChange}
|
|
350
351
|
paySelected={props.paySelected}
|
|
352
|
+
setUserHasCards={setUserHasCards}
|
|
351
353
|
/>
|
|
352
354
|
</View>
|
|
353
355
|
)}
|
|
@@ -440,6 +442,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
440
442
|
publicKey={isOpenMethod?.paymethod?.credentials.publishable}
|
|
441
443
|
publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
|
|
442
444
|
paySelected={props.paySelected}
|
|
445
|
+
setUserHasCards={setUserHasCards}
|
|
443
446
|
/>
|
|
444
447
|
</View>
|
|
445
448
|
)}
|
|
@@ -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({
|
|
@@ -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,
|
|
@@ -32,7 +32,8 @@ export const StripeCardsListUI = (props: any) => {
|
|
|
32
32
|
gateway,
|
|
33
33
|
paySelected,
|
|
34
34
|
newCardAdded,
|
|
35
|
-
addNewCardAsDefault
|
|
35
|
+
addNewCardAsDefault,
|
|
36
|
+
setUserHasCards
|
|
36
37
|
} = props;
|
|
37
38
|
|
|
38
39
|
const theme = useTheme();
|
|
@@ -62,6 +63,11 @@ export const StripeCardsListUI = (props: any) => {
|
|
|
62
63
|
}
|
|
63
64
|
}, [JSON.stringify(newCardAdded)])
|
|
64
65
|
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const hasCardSelected = cardsList?.cards?.some?.((card : any) => card?.id === paySelected?.data?.id)
|
|
68
|
+
setUserHasCards && setUserHasCards(cardsList?.cards?.length > 0 && hasCardSelected)
|
|
69
|
+
}, [cardsList?.cards?.length, paySelected])
|
|
70
|
+
|
|
65
71
|
return (
|
|
66
72
|
<>
|
|
67
73
|
{token && !cardsList.loading && cardsList.cards && cardsList.cards.length === 0 && (
|
|
@@ -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 {
|