ordering-ui-react-native 0.21.54-test → 0.21.56-test
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 +2 -2
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +12 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +7 -4
- package/themes/original/src/components/BusinessInformation/index.tsx +0 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +22 -402
- package/themes/original/src/components/Checkout/index.tsx +5 -1
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +1 -1
- package/themes/original/src/components/LastOrder/index.tsx +2 -1
- package/themes/original/src/components/LastOrders/index.tsx +2 -1
- package/themes/original/src/components/MultiCheckout/index.tsx +138 -16
- package/themes/original/src/components/OrderProgress/index.tsx +2 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +3 -1
- package/themes/original/src/components/ProductForm/index.tsx +1 -1
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
ToastType,
|
|
11
11
|
MultiCheckout as MultiCheckoutController
|
|
12
12
|
} from 'ordering-components/native'
|
|
13
|
-
import { View, StyleSheet, Platform } from 'react-native'
|
|
13
|
+
import { View, StyleSheet, Platform, ScrollView } from 'react-native'
|
|
14
14
|
import { useTheme } from 'styled-components/native';
|
|
15
15
|
import { Container } from '../../layouts/Container';
|
|
16
16
|
import NavBar from '../NavBar';
|
|
17
|
-
import { OText, OIcon, OModal } from '../shared';
|
|
17
|
+
import { OText, OIcon, OModal, OButton } from '../shared';
|
|
18
18
|
import { getTypesText } from '../../utils';
|
|
19
19
|
import { UserDetails } from '../UserDetails'
|
|
20
20
|
import { AddressDetails } from '../AddressDetails'
|
|
@@ -26,6 +26,8 @@ import { DriverTips } from '../DriverTips'
|
|
|
26
26
|
import { CouponControl } from '../CouponControl';
|
|
27
27
|
import { DriverTipsContainer } from '../Cart/styles'
|
|
28
28
|
import { OSTable, OSCoupon } from '../OrderSummary/styles';
|
|
29
|
+
import { SignupForm } from '../SignupForm'
|
|
30
|
+
import { LoginForm } from '../LoginForm'
|
|
29
31
|
|
|
30
32
|
import {
|
|
31
33
|
ChContainer,
|
|
@@ -74,7 +76,11 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
74
76
|
paddingLeft: 40,
|
|
75
77
|
paddingRight: 40
|
|
76
78
|
},
|
|
77
|
-
wrapperNavbar: { paddingHorizontal: 40 }
|
|
79
|
+
wrapperNavbar: { paddingHorizontal: 40 },
|
|
80
|
+
detailWrapper: {
|
|
81
|
+
paddingHorizontal: 40,
|
|
82
|
+
width: '100%'
|
|
83
|
+
},
|
|
78
84
|
})
|
|
79
85
|
|
|
80
86
|
const [, { showToast }] = useToast();
|
|
@@ -83,7 +89,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
83
89
|
const [{ parsePrice, parseDate }] = useUtils();
|
|
84
90
|
const [{ options, carts, loading }, { confirmCart }] = useOrder();
|
|
85
91
|
const [validationFields] = useValidationFields();
|
|
86
|
-
const [{ user }] = useSession()
|
|
92
|
+
const [{ user }, { login }] = useSession()
|
|
87
93
|
|
|
88
94
|
const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
|
|
89
95
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
@@ -134,6 +140,11 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
134
140
|
const [phoneUpdate, setPhoneUpdate] = useState(false);
|
|
135
141
|
const [userErrors, setUserErrors] = useState<any>([]);
|
|
136
142
|
const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
|
|
143
|
+
const [allowedGuest, setAllowedGuest] = useState(false)
|
|
144
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
145
|
+
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
146
|
+
const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
|
|
147
|
+
const [openModal, setOpenModal] = useState({ login: false, signup: false, isGuest: false })
|
|
137
148
|
const [methodPaySupported, setMethodPaySupported] = useState({ enabled: false, message: null, loading: true })
|
|
138
149
|
const methodsPay = ['global_google_pay', 'global_apple_pay']
|
|
139
150
|
const isDisablePlaceOrderButton = cartGroup?.loading || (!(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) && cartGroup?.result?.balance > 0) ||
|
|
@@ -151,11 +162,12 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
151
162
|
setUserErrors([])
|
|
152
163
|
const errors = []
|
|
153
164
|
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
|
|
165
|
+
const _requiredFields: any = []
|
|
154
166
|
|
|
155
167
|
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
156
168
|
if (field?.required && !notFields.includes(field.code)) {
|
|
157
169
|
if (!user[field?.code]) {
|
|
158
|
-
|
|
170
|
+
_requiredFields.push(field?.code)
|
|
159
171
|
}
|
|
160
172
|
}
|
|
161
173
|
})
|
|
@@ -166,8 +178,9 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
166
178
|
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
167
179
|
configs?.verification_phone_required?.value === '1')
|
|
168
180
|
) {
|
|
169
|
-
|
|
181
|
+
_requiredFields.push('cellphone')
|
|
170
182
|
}
|
|
183
|
+
setRequiredFields(_requiredFields)
|
|
171
184
|
|
|
172
185
|
if (phoneUpdate) {
|
|
173
186
|
errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
|
|
@@ -181,10 +194,19 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
181
194
|
}
|
|
182
195
|
|
|
183
196
|
const handlePlaceOrder = (confirmPayment?: any) => {
|
|
184
|
-
if (
|
|
197
|
+
if (stripePaymethods.includes(paymethodSelected?.gateway) && user?.guest_id) {
|
|
198
|
+
setOpenModal({ ...openModal, signup: true, isGuest: true })
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!userErrors.length && (!requiredFields?.length || allowedGuest)) {
|
|
185
203
|
handleGroupPlaceOrder && handleGroupPlaceOrder(confirmPayment)
|
|
186
204
|
return
|
|
187
205
|
}
|
|
206
|
+
if (requiredFields?.length) {
|
|
207
|
+
setIsOpen(true)
|
|
208
|
+
return
|
|
209
|
+
}
|
|
188
210
|
let stringError = ''
|
|
189
211
|
Object.values(userErrors).map((item: any, i: number) => {
|
|
190
212
|
stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
|
|
@@ -193,6 +215,24 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
193
215
|
setIsUserDetailsEdit(true)
|
|
194
216
|
}
|
|
195
217
|
|
|
218
|
+
const handlePlaceOrderAsGuest = () => {
|
|
219
|
+
setIsOpen(false)
|
|
220
|
+
handleGroupPlaceOrder && handleGroupPlaceOrder()
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const handleSuccessSignup = (user: any) => {
|
|
224
|
+
login({
|
|
225
|
+
user,
|
|
226
|
+
token: user?.session?.access_token
|
|
227
|
+
})
|
|
228
|
+
openModal?.isGuest && handlePlaceOrderAsGuest()
|
|
229
|
+
setOpenModal({ ...openModal, signup: false, isGuest: false })
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const handleSuccessLogin = (user: any) => {
|
|
233
|
+
if (user) setOpenModal({ ...openModal, login: false })
|
|
234
|
+
}
|
|
235
|
+
|
|
196
236
|
useEffect(() => {
|
|
197
237
|
if (validationFields && validationFields?.fields?.checkout) {
|
|
198
238
|
checkValidationFields()
|
|
@@ -285,15 +325,45 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
285
325
|
|
|
286
326
|
<ChSection>
|
|
287
327
|
<ChUserDetails>
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
328
|
+
{(user?.guest_id && !allowedGuest) ? (
|
|
329
|
+
<View>
|
|
330
|
+
<OText size={14} numberOfLines={1} ellipsizeMode='tail' color={theme.colors.textNormal}>
|
|
331
|
+
{t('CUSTOMER_DETAILS', 'Customer details')}
|
|
332
|
+
</OText>
|
|
333
|
+
<OButton
|
|
334
|
+
text={t('SIGN_UP', 'Sign up')}
|
|
335
|
+
textStyle={{ color: theme.colors.white }}
|
|
336
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
337
|
+
onClick={() => setOpenModal({ ...openModal, signup: true })}
|
|
338
|
+
/>
|
|
339
|
+
<OButton
|
|
340
|
+
text={t('LOGIN', 'Login')}
|
|
341
|
+
textStyle={{ color: theme.colors.primary }}
|
|
342
|
+
bgColor={theme.colors.white}
|
|
343
|
+
borderColor={theme.colors.primary}
|
|
344
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
345
|
+
onClick={() => setOpenModal({ ...openModal, login: true })}
|
|
346
|
+
/>
|
|
347
|
+
<OButton
|
|
348
|
+
text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
|
|
349
|
+
textStyle={{ color: theme.colors.black }}
|
|
350
|
+
bgColor={theme.colors.white}
|
|
351
|
+
borderColor={theme.colors.black}
|
|
352
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
353
|
+
onClick={() => setAllowedGuest(true)}
|
|
354
|
+
/>
|
|
355
|
+
</View>
|
|
356
|
+
) : (
|
|
357
|
+
<UserDetails
|
|
358
|
+
isUserDetailsEdit={isUserDetailsEdit}
|
|
359
|
+
useValidationFields
|
|
360
|
+
useDefualtSessionManager
|
|
361
|
+
useSessionUser
|
|
362
|
+
isCheckout
|
|
363
|
+
phoneUpdate={phoneUpdate}
|
|
364
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
365
|
+
/>
|
|
366
|
+
)}
|
|
297
367
|
</ChUserDetails>
|
|
298
368
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
299
369
|
</ChSection>
|
|
@@ -484,6 +554,58 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
484
554
|
</OText>
|
|
485
555
|
)}
|
|
486
556
|
</ChContainer>
|
|
557
|
+
<OModal
|
|
558
|
+
open={openModal.signup}
|
|
559
|
+
onClose={() => setOpenModal({ ...openModal, signup: false, isGuest: false })}
|
|
560
|
+
>
|
|
561
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
562
|
+
<SignupForm
|
|
563
|
+
handleSuccessSignup={handleSuccessSignup}
|
|
564
|
+
isGuest
|
|
565
|
+
signupButtonText={t('SIGNUP', 'Signup')}
|
|
566
|
+
useSignupByEmail
|
|
567
|
+
useChekoutFileds
|
|
568
|
+
/>
|
|
569
|
+
</ScrollView>
|
|
570
|
+
</OModal>
|
|
571
|
+
<OModal
|
|
572
|
+
open={openModal.login}
|
|
573
|
+
onClose={() => setOpenModal({ ...openModal, login: false })}
|
|
574
|
+
>
|
|
575
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
576
|
+
<LoginForm
|
|
577
|
+
handleSuccessLogin={handleSuccessLogin}
|
|
578
|
+
isGuest
|
|
579
|
+
loginButtonText={t('LOGIN', 'Login')}
|
|
580
|
+
loginButtonBackground={theme.colors.primary}
|
|
581
|
+
/>
|
|
582
|
+
</ScrollView>
|
|
583
|
+
</OModal>
|
|
584
|
+
<OModal
|
|
585
|
+
open={isOpen}
|
|
586
|
+
onClose={() => setIsOpen(false)}
|
|
587
|
+
>
|
|
588
|
+
<View style={styles.detailWrapper}>
|
|
589
|
+
<UserDetails
|
|
590
|
+
isUserDetailsEdit
|
|
591
|
+
useValidationFields
|
|
592
|
+
useDefualtSessionManager
|
|
593
|
+
useSessionUser
|
|
594
|
+
isCheckout
|
|
595
|
+
isEdit
|
|
596
|
+
phoneUpdate={phoneUpdate}
|
|
597
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
598
|
+
requiredFields={requiredFields}
|
|
599
|
+
hideUpdateButton
|
|
600
|
+
handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
|
|
601
|
+
onClose={() => {
|
|
602
|
+
setIsOpen(false)
|
|
603
|
+
handlePlaceOrder()
|
|
604
|
+
}}
|
|
605
|
+
setIsOpen={setIsOpen}
|
|
606
|
+
/>
|
|
607
|
+
</View>
|
|
608
|
+
</OModal>
|
|
487
609
|
</Container>
|
|
488
610
|
|
|
489
611
|
<FloatingButton
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
useLanguage,
|
|
12
12
|
ToastType,
|
|
13
13
|
useToast,
|
|
14
|
+
useSession
|
|
14
15
|
} from 'ordering-components/native';
|
|
15
16
|
import { useTheme } from 'styled-components/native';
|
|
16
17
|
import { PaymentOptionCash } from '../PaymentOptionCash';
|
|
@@ -78,6 +79,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
78
79
|
|
|
79
80
|
const theme = useTheme();
|
|
80
81
|
const [, { showToast }] = useToast();
|
|
82
|
+
const [{ user }] = useSession()
|
|
81
83
|
const { confirmApplePayPayment } = useApplePay()
|
|
82
84
|
|
|
83
85
|
const getPayIcon = (method: string) => {
|
|
@@ -120,7 +122,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
120
122
|
const paymethodsFieldRequired = ['paypal', 'apple_pay', 'global_apple_pay']
|
|
121
123
|
|
|
122
124
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
123
|
-
if (cart?.balance > 0) {
|
|
125
|
+
if (cart?.balance > 0 || !!user?.guest_id) {
|
|
124
126
|
if (paymethodsFieldRequired.includes(paymethod?.gateway) && requiredFields.length > 0) {
|
|
125
127
|
openUserModal && openUserModal(true)
|
|
126
128
|
setPaymethodClicked({
|
|
@@ -505,7 +505,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
505
505
|
<TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
|
|
506
506
|
{actionStatus?.loading ? (
|
|
507
507
|
<Placeholder Animation={Fade}>
|
|
508
|
-
<PlaceholderLine
|
|
508
|
+
<PlaceholderLine height={20} />
|
|
509
509
|
</Placeholder>
|
|
510
510
|
) : (
|
|
511
511
|
<OText color={theme.colors.primary} size={13} style={{ textAlign: 'center' }}>{t('AS_GUEST_USER', 'As guest user')}</OText>
|