ordering-ui-react-native 0.18.3 → 0.18.5
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/BusinessBasicInformation/index.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +1 -1
- package/themes/original/src/components/Checkout/index.tsx +87 -16
- package/themes/original/src/components/Home/index.tsx +11 -2
- package/themes/original/src/components/LoginForm/index.tsx +15 -10
- package/themes/original/src/components/StripeElementsForm/index.tsx +1 -1
- package/themes/original/src/types/index.tsx +1 -0
package/package.json
CHANGED
|
@@ -286,7 +286,7 @@ export const BusinessBasicInformation = (
|
|
|
286
286
|
}
|
|
287
287
|
{...(!loading && {
|
|
288
288
|
source: (header || businessState?.business?.header) ? {
|
|
289
|
-
uri:
|
|
289
|
+
uri: optimizeImage(businessState?.business?.header, 'h_250,c_limit') || header
|
|
290
290
|
} : theme?.images?.dummies?.businessHeader
|
|
291
291
|
})}
|
|
292
292
|
imageStyle={{ opacity: isChewLayout ? 0.5 : 1 }}
|
|
@@ -399,7 +399,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
399
399
|
style={{ marginRight: isChewLayout ? 0 : 10 }}
|
|
400
400
|
/>
|
|
401
401
|
<OText size={12} numberOfLines={1} style={{ flex: 1 }}>
|
|
402
|
-
{orderState?.options?.address?.address}
|
|
402
|
+
{orderState?.options?.address?.address || t('WHAT_IS_YOUR_ADDRESS', 'What\'s your address?')}
|
|
403
403
|
</OText>
|
|
404
404
|
{!isChewLayout && (
|
|
405
405
|
<OIcon
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, Vibration } from 'react-native';
|
|
2
|
+
import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, Vibration, ScrollView } from 'react-native';
|
|
3
3
|
import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
|
|
4
4
|
import Picker from 'react-native-country-picker-modal';
|
|
5
5
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
ToastType,
|
|
17
17
|
} from 'ordering-components/native';
|
|
18
18
|
import { useTheme } from 'styled-components/native';
|
|
19
|
-
import { OText, OIcon, OModal } from '../shared';
|
|
19
|
+
import { OText, OIcon, OModal, OButton } from '../shared';
|
|
20
20
|
|
|
21
21
|
import { AddressDetails } from '../AddressDetails';
|
|
22
22
|
import { PaymentOptions } from '../PaymentOptions';
|
|
@@ -25,6 +25,8 @@ import { NotFoundSource } from '../NotFoundSource';
|
|
|
25
25
|
import { UserDetails } from '../UserDetails';
|
|
26
26
|
import { PaymentOptionWallet } from '../PaymentOptionWallet';
|
|
27
27
|
import { PlaceSpot } from '../PlaceSpot'
|
|
28
|
+
import { SignupForm } from '../SignupForm'
|
|
29
|
+
import { LoginForm } from '../LoginForm'
|
|
28
30
|
|
|
29
31
|
import {
|
|
30
32
|
ChContainer,
|
|
@@ -129,7 +131,7 @@ const CheckoutUI = (props: any) => {
|
|
|
129
131
|
|
|
130
132
|
const [, { showToast }] = useToast();
|
|
131
133
|
const [, t] = useLanguage();
|
|
132
|
-
const [{ user, token }] = useSession();
|
|
134
|
+
const [{ user, token }, { login }] = useSession();
|
|
133
135
|
const [ordering] = useApi()
|
|
134
136
|
const [{ configs }] = useConfig();
|
|
135
137
|
const [{ parsePrice, parseDate }] = useUtils();
|
|
@@ -146,6 +148,8 @@ const CheckoutUI = (props: any) => {
|
|
|
146
148
|
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
147
149
|
const [isOpen, setIsOpen] = useState(false)
|
|
148
150
|
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
151
|
+
const [openModal, setOpenModal] = useState({ login: false, signup: false })
|
|
152
|
+
const [allowedGuest, setAllowedGuest] = useState(false)
|
|
149
153
|
|
|
150
154
|
const placeSpotTypes = [3, 4, 5]
|
|
151
155
|
const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
|
|
@@ -194,8 +198,20 @@ const CheckoutUI = (props: any) => {
|
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
|
|
201
|
+
const handleSuccessSignup = (user: any) => {
|
|
202
|
+
login({
|
|
203
|
+
user,
|
|
204
|
+
token: user?.session?.access_token
|
|
205
|
+
})
|
|
206
|
+
setOpenModal({ ...openModal, signup: false })
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const handleSuccessLogin = (user: any) => {
|
|
210
|
+
if (user) setOpenModal({ ...openModal, login: false })
|
|
211
|
+
}
|
|
212
|
+
|
|
197
213
|
const handlePlaceOrder = (confirmPayment: any, forcePlace: boolean = false) => {
|
|
198
|
-
if (!userErrors.length && !requiredFields?.length || forcePlace) {
|
|
214
|
+
if (!userErrors.length && (!requiredFields?.length || allowedGuest) || forcePlace) {
|
|
199
215
|
Vibration.vibrate()
|
|
200
216
|
handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
|
|
201
217
|
return
|
|
@@ -426,18 +442,46 @@ const CheckoutUI = (props: any) => {
|
|
|
426
442
|
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
427
443
|
</Placeholder>
|
|
428
444
|
) : (
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
445
|
+
(user?.guest_id && !allowedGuest) ? (
|
|
446
|
+
<View>
|
|
447
|
+
<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer details')} />
|
|
448
|
+
<OButton
|
|
449
|
+
text={t('SIGN_UP', 'Sign up')}
|
|
450
|
+
textStyle={{ color: theme.colors.white }}
|
|
451
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
452
|
+
onClick={() => setOpenModal({ ...openModal, signup: true })}
|
|
453
|
+
/>
|
|
454
|
+
<OButton
|
|
455
|
+
text={t('LOGIN', 'Login')}
|
|
456
|
+
textStyle={{ color: theme.colors.primary }}
|
|
457
|
+
bgColor={theme.colors.white}
|
|
458
|
+
borderColor={theme.colors.primary}
|
|
459
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
460
|
+
onClick={() => setOpenModal({ ...openModal, login: true })}
|
|
461
|
+
/>
|
|
462
|
+
<OButton
|
|
463
|
+
text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
|
|
464
|
+
textStyle={{ color: theme.colors.black }}
|
|
465
|
+
bgColor={theme.colors.white}
|
|
466
|
+
borderColor={theme.colors.black}
|
|
467
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
468
|
+
onClick={() => setAllowedGuest(true)}
|
|
469
|
+
/>
|
|
470
|
+
</View>
|
|
471
|
+
) : (
|
|
472
|
+
<UserDetails
|
|
473
|
+
isUserDetailsEdit={isUserDetailsEdit}
|
|
474
|
+
HeaderTitle={<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer Details')} mb={0} />}
|
|
475
|
+
cartStatus={cart?.status}
|
|
476
|
+
businessId={cart?.business_id}
|
|
477
|
+
useValidationFields
|
|
478
|
+
useDefualtSessionManager
|
|
479
|
+
useSessionUser
|
|
480
|
+
isCheckout
|
|
481
|
+
phoneUpdate={phoneUpdate}
|
|
482
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
483
|
+
/>
|
|
484
|
+
)
|
|
441
485
|
)}
|
|
442
486
|
</ChUserDetails>
|
|
443
487
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
@@ -778,6 +822,33 @@ const CheckoutUI = (props: any) => {
|
|
|
778
822
|
/>
|
|
779
823
|
</View>
|
|
780
824
|
</OModal>
|
|
825
|
+
<OModal
|
|
826
|
+
open={openModal.signup}
|
|
827
|
+
onClose={() => setOpenModal({ ...openModal, signup: false })}
|
|
828
|
+
>
|
|
829
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%'}}>
|
|
830
|
+
<SignupForm
|
|
831
|
+
handleSuccessSignup={handleSuccessSignup}
|
|
832
|
+
isGuest
|
|
833
|
+
signupButtonText={t('SIGNUP', 'Signup')}
|
|
834
|
+
useSignupByEmail
|
|
835
|
+
useChekoutFileds
|
|
836
|
+
/>
|
|
837
|
+
</ScrollView>
|
|
838
|
+
</OModal>
|
|
839
|
+
<OModal
|
|
840
|
+
open={openModal.login}
|
|
841
|
+
onClose={() => setOpenModal({ ...openModal, login: false })}
|
|
842
|
+
>
|
|
843
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%'}}>
|
|
844
|
+
<LoginForm
|
|
845
|
+
handleSuccessLogin={handleSuccessLogin}
|
|
846
|
+
isGuest
|
|
847
|
+
loginButtonText={t('LOGIN', 'Login')}
|
|
848
|
+
loginButtonBackground={theme.colors.primary}
|
|
849
|
+
/>
|
|
850
|
+
</ScrollView>
|
|
851
|
+
</OModal>
|
|
781
852
|
</ChContainer>
|
|
782
853
|
</Container>
|
|
783
854
|
{!cartState.loading && cart && cart?.status !== 2 && (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useLanguage, useOrder } from 'ordering-components/native';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useLanguage, useOrder, useConfig } from 'ordering-components/native';
|
|
3
3
|
import { useTheme } from 'styled-components/native';
|
|
4
4
|
import { StyleSheet, View } from 'react-native';
|
|
5
5
|
import { OButton, OIcon, OText } from '../shared';
|
|
@@ -12,8 +12,17 @@ export const Home = (props: any) => {
|
|
|
12
12
|
const { width, height } = useWindowDimensions();
|
|
13
13
|
const [, t] = useLanguage();
|
|
14
14
|
const [orderState] = useOrder();
|
|
15
|
+
const [{ configs }] = useConfig()
|
|
15
16
|
|
|
16
17
|
const theme = useTheme();
|
|
18
|
+
const unaddressedTypes = configs?.unaddressed_order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
|
|
19
|
+
const isAllowUnaddressOrderType = unaddressedTypes.includes(orderState?.options?.type)
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (isAllowUnaddressOrderType) {
|
|
23
|
+
onNavigationRedirect('BusinessList')
|
|
24
|
+
}
|
|
25
|
+
}, [isAllowUnaddressOrderType])
|
|
17
26
|
|
|
18
27
|
return (
|
|
19
28
|
<View style={styles.container}>
|
|
@@ -72,6 +72,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
72
72
|
generateOtpCode,
|
|
73
73
|
useLoginOtpEmail,
|
|
74
74
|
useLoginOtpCellphone,
|
|
75
|
+
isGuest
|
|
75
76
|
} = props;
|
|
76
77
|
|
|
77
78
|
const [, { showToast }] = useToast();
|
|
@@ -378,15 +379,19 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
378
379
|
|
|
379
380
|
return (
|
|
380
381
|
<Container>
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
382
|
+
{isGuest ? (
|
|
383
|
+
<OText style={{ textAlign: 'center', marginBottom: 10 }} size={18}>{t('LOGIN', 'Login')}</OText>
|
|
384
|
+
) : (
|
|
385
|
+
<NavBar
|
|
386
|
+
title={t('LOGIN', 'Login')}
|
|
387
|
+
titleAlign={'center'}
|
|
388
|
+
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
389
|
+
showCall={false}
|
|
390
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
391
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
392
|
+
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
393
|
+
/>
|
|
394
|
+
)}
|
|
390
395
|
<FormSide>
|
|
391
396
|
{(Number(useLoginByEmail) + Number(useLoginByCellphone) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
|
|
392
397
|
<LoginWith>
|
|
@@ -733,7 +738,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
733
738
|
{configs && Object.keys(configs).length > 0 ? (
|
|
734
739
|
(((configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') && configs?.facebook_id?.value && facebookLoginEnabled) ||
|
|
735
740
|
((configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled) ||
|
|
736
|
-
((configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled)) &&
|
|
741
|
+
((configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled)) && !isGuest &&
|
|
737
742
|
(
|
|
738
743
|
<>
|
|
739
744
|
<View
|
|
@@ -177,7 +177,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
177
177
|
<View style={{ flex: 1 }}>
|
|
178
178
|
<StripeProvider
|
|
179
179
|
publishableKey={publicKey}
|
|
180
|
-
merchantIdentifier={
|
|
180
|
+
merchantIdentifier={merchantId}
|
|
181
181
|
urlScheme={merchantId}
|
|
182
182
|
>
|
|
183
183
|
{methodsPay?.includes(paymethod) ? (
|