ordering-ui-react-native 0.16.74-release → 0.16.75-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/AddressForm/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +6 -0
- package/themes/original/src/components/ServiceForm/index.tsx +24 -1
- package/themes/original/src/components/SignupForm/index.tsx +16 -11
- package/themes/original/src/components/UserFormDetails/index.tsx +44 -6
- package/themes/original/src/types/index.tsx +4 -1
- package/themes/original/src/utils/index.tsx +5 -0
package/package.json
CHANGED
|
@@ -362,7 +362,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
362
362
|
if (
|
|
363
363
|
orderState.loading &&
|
|
364
364
|
!addressesList &&
|
|
365
|
-
orderState
|
|
365
|
+
orderState?.options?.address &&
|
|
366
366
|
auth &&
|
|
367
367
|
!afterSignup
|
|
368
368
|
) {
|
|
@@ -370,7 +370,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
370
370
|
? navigation.navigate('BottomTab')
|
|
371
371
|
: navigation.navigate('Business');
|
|
372
372
|
}
|
|
373
|
-
}, [orderState
|
|
373
|
+
}, [orderState?.options?.address]);
|
|
374
374
|
|
|
375
375
|
useEffect(() => {
|
|
376
376
|
if (alertState.open && alertState?.key !== 'ERROR_MAX_LIMIT_LOCATION') {
|
|
@@ -206,6 +206,11 @@ const CheckoutUI = (props: any) => {
|
|
|
206
206
|
setIsUserDetailsEdit(true)
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
const handlePlaceOrderAsGuest = () => {
|
|
210
|
+
setIsOpen(false)
|
|
211
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder()
|
|
212
|
+
}
|
|
213
|
+
|
|
209
214
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
210
215
|
setShowGateway({ closedByUser: false, open: true })
|
|
211
216
|
setWebviewPaymethod(paymethod)
|
|
@@ -734,6 +739,7 @@ const CheckoutUI = (props: any) => {
|
|
|
734
739
|
togglePhoneUpdate={togglePhoneUpdate}
|
|
735
740
|
requiredFields={requiredFields}
|
|
736
741
|
hideUpdateButton
|
|
742
|
+
handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
|
|
737
743
|
onClose={() => {
|
|
738
744
|
setIsOpen(false)
|
|
739
745
|
handlePlaceOrder(null, true)
|
|
@@ -11,6 +11,8 @@ import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
|
11
11
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
12
12
|
import { ServiceFormParams } from '../../types'
|
|
13
13
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
14
|
+
import uuid from 'react-native-uuid';
|
|
15
|
+
import { orderTypeList } from '../../utils'
|
|
14
16
|
|
|
15
17
|
import {
|
|
16
18
|
ProductForm as ProductFormController,
|
|
@@ -45,7 +47,9 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
45
47
|
maxProductQuantity,
|
|
46
48
|
onClose,
|
|
47
49
|
professionalListState,
|
|
48
|
-
isCartProduct
|
|
50
|
+
isCartProduct,
|
|
51
|
+
actionStatus,
|
|
52
|
+
handleCreateGuestUser
|
|
49
53
|
} = props
|
|
50
54
|
|
|
51
55
|
const theme = useTheme()
|
|
@@ -65,6 +69,9 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
65
69
|
const [isOpen, setIsOpen] = useState(false)
|
|
66
70
|
const [currentProfessional, setCurrentProfessional] = useState<any>(null)
|
|
67
71
|
|
|
72
|
+
const guestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
|
|
73
|
+
const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
|
|
74
|
+
|
|
68
75
|
const dropdownRef = useRef<any>(null)
|
|
69
76
|
|
|
70
77
|
const styles = StyleSheet.create({
|
|
@@ -148,6 +155,11 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
148
155
|
)
|
|
149
156
|
}
|
|
150
157
|
|
|
158
|
+
const handleUpdateGuest = () => {
|
|
159
|
+
const guestToken = uuid.v4()
|
|
160
|
+
if (guestToken) handleCreateGuestUser({ guest_token: guestToken })
|
|
161
|
+
}
|
|
162
|
+
|
|
151
163
|
const customDayHeaderStylesCallback = () => {
|
|
152
164
|
return {
|
|
153
165
|
textStyle: {
|
|
@@ -571,6 +583,17 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
571
583
|
}}
|
|
572
584
|
/>
|
|
573
585
|
)}
|
|
586
|
+
{!auth && guestCheckoutEnabled && orderTypeEnabled && (
|
|
587
|
+
<TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
|
|
588
|
+
{actionStatus?.loading ? (
|
|
589
|
+
<Placeholder Animation={Fade}>
|
|
590
|
+
<PlaceholderLine width={60} height={20} />
|
|
591
|
+
</Placeholder>
|
|
592
|
+
) : (
|
|
593
|
+
<OText color={theme.colors.primary} size={13}>{t('WITH_GUEST_USER', 'With Guest user')}</OText>
|
|
594
|
+
)}
|
|
595
|
+
</TouchableOpacity>
|
|
596
|
+
)}
|
|
574
597
|
</ButtonWrapper>
|
|
575
598
|
</Container>
|
|
576
599
|
)}
|
|
@@ -83,7 +83,8 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
83
83
|
signUpTab,
|
|
84
84
|
useSignUpFullDetails,
|
|
85
85
|
useSignUpOtpEmail,
|
|
86
|
-
useSignUpOtpCellphone
|
|
86
|
+
useSignUpOtpCellphone,
|
|
87
|
+
isGuest
|
|
87
88
|
} = props;
|
|
88
89
|
|
|
89
90
|
const theme = useTheme();
|
|
@@ -465,15 +466,19 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
465
466
|
|
|
466
467
|
return (
|
|
467
468
|
<View>
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
469
|
+
{isGuest ? (
|
|
470
|
+
<OText style={{ textAlign: 'center', marginBottom: 10 }} size={18}>{t('SIGNUP', 'Signup')}</OText>
|
|
471
|
+
) : (
|
|
472
|
+
<NavBar
|
|
473
|
+
title={t('SIGNUP', 'Signup')}
|
|
474
|
+
titleAlign={'center'}
|
|
475
|
+
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
476
|
+
showCall={false}
|
|
477
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
478
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
479
|
+
titleStyle={{ marginLeft: 0, marginRight: 0 }}
|
|
480
|
+
/>
|
|
481
|
+
)}
|
|
477
482
|
<FormSide>
|
|
478
483
|
{((Number(useSignUpFullDetails) + Number(useSignUpOtpEmail) + Number(useSignUpOtpCellphone)) > 1) && (
|
|
479
484
|
<SignupWith>
|
|
@@ -893,7 +898,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
893
898
|
</View>
|
|
894
899
|
)
|
|
895
900
|
}
|
|
896
|
-
{configs && Object.keys(configs).length > 0 && (
|
|
901
|
+
{configs && Object.keys(configs).length > 0 && !isGuest && (
|
|
897
902
|
(((configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') && configs?.facebook_id?.value && facebookLoginEnabled) ||
|
|
898
903
|
((configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled) ||
|
|
899
904
|
((configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled)) &&
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Platform, StyleSheet, TouchableOpacity } from 'react-native';
|
|
2
|
+
import { Platform, StyleSheet, TouchableOpacity, ScrollView } from 'react-native';
|
|
3
3
|
import { useSession, useLanguage, ToastType, useToast, useConfig } from 'ordering-components/native';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
import { useForm, Controller } from 'react-hook-form';
|
|
6
|
+
import { SignupForm } from '../SignupForm'
|
|
6
7
|
|
|
7
8
|
import { UDForm, UDLoader, UDWrapper, WrapperPhone } from './styles';
|
|
8
9
|
|
|
9
|
-
import { OText, OButton, OInput } from '../shared';
|
|
10
|
+
import { OText, OButton, OInput, OModal } from '../shared';
|
|
10
11
|
|
|
11
12
|
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
12
13
|
import { sortInputFields } from '../../utils';
|
|
@@ -27,6 +28,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
27
28
|
phoneUpdate,
|
|
28
29
|
hideUpdateButton,
|
|
29
30
|
setWillVerifyOtpState,
|
|
31
|
+
handlePlaceOrderAsGuest,
|
|
32
|
+
isCheckout
|
|
30
33
|
} = props;
|
|
31
34
|
|
|
32
35
|
const theme = useTheme();
|
|
@@ -68,10 +71,11 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
68
71
|
const [, { showToast }] = useToast();
|
|
69
72
|
const { handleSubmit, control, errors, setValue } = useForm();
|
|
70
73
|
|
|
71
|
-
const [{ user }] = useSession();
|
|
74
|
+
const [{ user }, { login }] = useSession();
|
|
72
75
|
const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
|
|
73
76
|
const [isValid, setIsValid] = useState(false)
|
|
74
77
|
const [isChanged, setIsChanged] = useState(false)
|
|
78
|
+
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
75
79
|
const [phoneInputData, setPhoneInputData] = useState({
|
|
76
80
|
error: '',
|
|
77
81
|
phone: {
|
|
@@ -82,6 +86,14 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
82
86
|
|
|
83
87
|
const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
|
|
84
88
|
|
|
89
|
+
const handleSuccessSignup = (user: any) => {
|
|
90
|
+
login({
|
|
91
|
+
user,
|
|
92
|
+
token: user?.session?.access_token
|
|
93
|
+
})
|
|
94
|
+
handlePlaceOrderAsGuest && handlePlaceOrderAsGuest()
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
const getInputRules = (field: any) => {
|
|
86
98
|
const rules: any = {
|
|
87
99
|
required: isRequiredField(field.code)
|
|
@@ -187,6 +199,11 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
187
199
|
handleChangeInput(countryCode, true);
|
|
188
200
|
}
|
|
189
201
|
|
|
202
|
+
const handleClickBtn = () => {
|
|
203
|
+
if (!user?.guest_id) handleSubmit(onSubmit)
|
|
204
|
+
else setIsModalOpen(true)
|
|
205
|
+
}
|
|
206
|
+
|
|
190
207
|
useEffect(() => {
|
|
191
208
|
if (Object.keys(errors).length > 0) {
|
|
192
209
|
const list = Object.values(errors);
|
|
@@ -423,17 +440,38 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
423
440
|
text={
|
|
424
441
|
formState.loading
|
|
425
442
|
? t('UPDATING', 'Updating...')
|
|
426
|
-
:
|
|
443
|
+
: ((isCheckout && !!user?.guest_id)
|
|
444
|
+
? t('SIGN_UP_AND_PLACE_ORDER', 'Sign up and place order')
|
|
445
|
+
: t('CONTINUE', 'Continue'))
|
|
427
446
|
}
|
|
428
447
|
bgColor={theme.colors.white}
|
|
429
448
|
textStyle={{ color: theme.colors.primary, fontSize: 14 }}
|
|
430
449
|
borderColor={theme.colors.primary}
|
|
431
|
-
isDisabled={formState.loading || !isValid}
|
|
450
|
+
isDisabled={!user?.guest_id && (formState.loading || !isValid)}
|
|
432
451
|
imgRightSrc={null}
|
|
433
452
|
style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
|
|
434
|
-
onClick={
|
|
453
|
+
onClick={handleClickBtn}
|
|
435
454
|
/>
|
|
436
455
|
)}
|
|
456
|
+
{isCheckout && !!user?.guest_id && (
|
|
457
|
+
<TouchableOpacity style={{ marginTop: 10 }} onPress={() => handlePlaceOrderAsGuest()}>
|
|
458
|
+
<OText color={theme.colors.primary} style={{ textAlign: 'center' }}>{t('PLACE_ORDER_AS_GUEST', 'Place order as guest')}</OText>
|
|
459
|
+
</TouchableOpacity>
|
|
460
|
+
)}
|
|
461
|
+
<OModal
|
|
462
|
+
open={isModalOpen}
|
|
463
|
+
onClose={() => setIsModalOpen(false)}
|
|
464
|
+
>
|
|
465
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%'}}>
|
|
466
|
+
<SignupForm
|
|
467
|
+
handleSuccessSignup={handleSuccessSignup}
|
|
468
|
+
isGuest
|
|
469
|
+
signupButtonText={t('SIGNUP', 'Signup')}
|
|
470
|
+
useSignupByEmail
|
|
471
|
+
useChekoutFileds
|
|
472
|
+
/>
|
|
473
|
+
</ScrollView>
|
|
474
|
+
</OModal>
|
|
437
475
|
</>
|
|
438
476
|
);
|
|
439
477
|
};
|
|
@@ -118,6 +118,7 @@ export interface SignupParams {
|
|
|
118
118
|
useSignUpOtpEmail?: boolean;
|
|
119
119
|
useSignUpOtpCellphone?: boolean;
|
|
120
120
|
willVerifyOtpState?: boolean;
|
|
121
|
+
isGuest?: any;
|
|
121
122
|
numOtpInputs?: number;
|
|
122
123
|
handleChangePromotions: () => void;
|
|
123
124
|
handleChangeInput?: (in1: any, in2: any) => void;
|
|
@@ -760,7 +761,9 @@ export interface ServiceFormParams {
|
|
|
760
761
|
professionalList: any,
|
|
761
762
|
productObject?: any,
|
|
762
763
|
professionalListState?: any,
|
|
763
|
-
isCartProduct?: any
|
|
764
|
+
isCartProduct?: any,
|
|
765
|
+
actionStatus?: any,
|
|
766
|
+
handleCreateGuestUser?: any
|
|
764
767
|
}
|
|
765
768
|
|
|
766
769
|
export interface ProfessionalFilterParams {
|
|
@@ -10,6 +10,11 @@ const theme = useTheme()
|
|
|
10
10
|
|
|
11
11
|
export const flatArray = (arr: any) => [].concat(...arr)
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* List of order type
|
|
15
|
+
*/
|
|
16
|
+
export const orderTypeList = ['delivery', 'pickup', 'eatin', 'curbside', 'drivethru', 'seatdelivery']
|
|
17
|
+
|
|
13
18
|
/**
|
|
14
19
|
* Function to return the traduction depending of a key 't'
|
|
15
20
|
* @param {string} key for traduction
|