ordering-ui-react-native 0.23.96 → 0.23.98
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/index.tsx +214 -218
- package/themes/original/src/components/Checkout/index.tsx +27 -10
- package/themes/original/src/components/Help/functions.tsx +76 -0
- package/themes/original/src/components/Help/index.tsx +74 -29
- package/themes/original/src/components/Help/styles.tsx +4 -1
- package/themes/original/src/components/HelpOptions/index.tsx +44 -0
- package/themes/original/src/components/MultiCheckout/index.tsx +22 -10
- package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
- package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
- package/themes/original/src/components/PaymentOptions/index.tsx +10 -1
- package/themes/original/src/types/index.tsx +699 -699
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
- package/themes/original/src/components/HelpGuide/index.tsx +0 -68
- package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
- package/themes/original/src/components/HelpOrder/index.tsx +0 -71
- package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Platform, RefreshControl, View } from 'react-native'
|
|
3
|
+
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
|
|
4
|
+
import { useTheme } from 'styled-components/native'
|
|
5
5
|
import { useLanguage } from 'ordering-components/native'
|
|
6
|
+
|
|
7
|
+
import { HelpParams } from '../../types'
|
|
8
|
+
import { CmsContent } from './functions'
|
|
9
|
+
import { HelpSubItem, LastOrdersContainer } from './styles'
|
|
10
|
+
import { Container } from '../../layouts/Container'
|
|
11
|
+
|
|
12
|
+
import { OText, OIcon } from '../shared'
|
|
13
|
+
import { NotFoundSource } from '../NotFoundSource'
|
|
6
14
|
import NavBar from '../NavBar'
|
|
7
|
-
import { OText } from '../shared'
|
|
8
15
|
import { LastOrders } from '../LastOrders'
|
|
9
|
-
import { Container } from '../../layouts/Container'
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
17
|
+
const HelpUI = (props: HelpParams) => {
|
|
18
|
+
const { cmsState, navigation } = props
|
|
19
|
+
|
|
20
|
+
const { items, loading, error, pages } = cmsState
|
|
15
21
|
|
|
16
|
-
export const Help = (props: HelpParams) => {
|
|
17
|
-
const {
|
|
18
|
-
navigation
|
|
19
|
-
} = props
|
|
20
22
|
const [, t] = useLanguage()
|
|
21
23
|
const theme = useTheme()
|
|
22
|
-
|
|
24
|
+
|
|
25
|
+
const [refreshing] = useState(false)
|
|
23
26
|
const [refresh, setRefresh] = useState(false)
|
|
24
27
|
|
|
28
|
+
const HelpItem = ({ item }: any) => {
|
|
29
|
+
const currentItem = pages.find((p: any) => p.id === item.id)
|
|
30
|
+
return (
|
|
31
|
+
<HelpSubItem
|
|
32
|
+
activeOpacity={0.7}
|
|
33
|
+
onPress={() => onRedirect('HelpOptions', { item: currentItem })}
|
|
34
|
+
>
|
|
35
|
+
<OText size={14} style={{ width: '90%' }}>
|
|
36
|
+
{item.name}
|
|
37
|
+
</OText>
|
|
38
|
+
<OIcon
|
|
39
|
+
width={15}
|
|
40
|
+
src={theme.images.general.chevron_right}
|
|
41
|
+
/>
|
|
42
|
+
</HelpSubItem>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
const goToBack = () => navigation?.canGoBack() && navigation.goBack()
|
|
26
47
|
const onRedirect = (route: string, params?: any) => {
|
|
27
48
|
navigation.navigate(route, params)
|
|
@@ -49,22 +70,36 @@ export const Help = (props: HelpParams) => {
|
|
|
49
70
|
showCall={false}
|
|
50
71
|
btnStyle={{ paddingLeft: 0 }}
|
|
51
72
|
/>
|
|
52
|
-
<
|
|
53
|
-
|
|
73
|
+
<OText
|
|
74
|
+
size={20}
|
|
75
|
+
weight={'bold'}
|
|
76
|
+
style={{ marginBottom: 20 }}
|
|
54
77
|
>
|
|
55
|
-
|
|
56
|
-
</
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
{t('ALL_THE_THEMES', 'All the themes')}
|
|
79
|
+
</OText>
|
|
80
|
+
{!loading && !error && items.map((item: any) => (
|
|
81
|
+
<HelpItem
|
|
82
|
+
key={item.id}
|
|
83
|
+
item={item}
|
|
84
|
+
/>
|
|
85
|
+
))}
|
|
86
|
+
{loading && (
|
|
87
|
+
<Placeholder Animation={Fade}>
|
|
88
|
+
<View style={{ flexDirection: 'column' }}>
|
|
89
|
+
{[...Array(5)].map((_, i) => (
|
|
90
|
+
<HelpSubItem key={i}>
|
|
91
|
+
<PlaceholderLine key={i} height={30} width={90} noMargin />
|
|
92
|
+
</HelpSubItem>
|
|
93
|
+
))}
|
|
94
|
+
</View>
|
|
95
|
+
</Placeholder>
|
|
96
|
+
)}
|
|
97
|
+
{!loading && !!error && (
|
|
98
|
+
<NotFoundSource
|
|
99
|
+
simple
|
|
100
|
+
content={error}
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
68
103
|
<LastOrdersContainer>
|
|
69
104
|
<OText size={18} weight={600}>{t('LAST_ORDERS', 'Last Orders')}</OText>
|
|
70
105
|
<LastOrders {...props} onRedirect={onRedirect} refresh={refresh} setRefresh={setRefresh} />
|
|
@@ -72,3 +107,13 @@ export const Help = (props: HelpParams) => {
|
|
|
72
107
|
</Container>
|
|
73
108
|
)
|
|
74
109
|
}
|
|
110
|
+
|
|
111
|
+
export const Help = (props: HelpParams) => {
|
|
112
|
+
const helpProps = {
|
|
113
|
+
...props,
|
|
114
|
+
UIComponent: HelpUI
|
|
115
|
+
}
|
|
116
|
+
return (
|
|
117
|
+
<CmsContent {...helpProps} />
|
|
118
|
+
)
|
|
119
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import styled from 'styled-components/native'
|
|
2
2
|
|
|
3
3
|
export const HelpSubItem = styled.TouchableOpacity`
|
|
4
|
-
border-bottom-color:
|
|
4
|
+
border-bottom-color: ${(props: any) => props.theme.colors.border};
|
|
5
5
|
border-bottom-width: 1px;
|
|
6
6
|
padding-vertical: 15px;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
align-items: center;
|
|
7
10
|
`
|
|
8
11
|
|
|
9
12
|
export const LastOrdersContainer = styled.View`
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Dimensions, Platform } from 'react-native'
|
|
3
|
+
import { WebView } from 'react-native-webview'
|
|
4
|
+
import { useLanguage } from 'ordering-components/native'
|
|
5
|
+
|
|
6
|
+
import { Container } from '../../layouts/Container'
|
|
7
|
+
import { NotFoundSource } from '../NotFoundSource'
|
|
8
|
+
import NavBar from '../NavBar'
|
|
9
|
+
|
|
10
|
+
const HEIGHT_SCREEN = Dimensions.get('screen').height
|
|
11
|
+
|
|
12
|
+
export const HelpOptions = (props: any) => {
|
|
13
|
+
const { item, goToBack } = props
|
|
14
|
+
const [, t] = useLanguage()
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Container
|
|
18
|
+
pt={Platform.OS === 'ios' ? 20 : 10}
|
|
19
|
+
noPadding
|
|
20
|
+
>
|
|
21
|
+
<NavBar
|
|
22
|
+
title={t('HELP', 'Help')}
|
|
23
|
+
titleAlign={'center'}
|
|
24
|
+
onActionLeft={goToBack}
|
|
25
|
+
showCall={false}
|
|
26
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
27
|
+
/>
|
|
28
|
+
{!!item?.body && (
|
|
29
|
+
<WebView
|
|
30
|
+
originWhitelist={['*']}
|
|
31
|
+
automaticallyAdjustContentInsets={false}
|
|
32
|
+
source={{ html: item.body }}
|
|
33
|
+
style={{ flex: 1, height: HEIGHT_SCREEN }}
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
36
|
+
{!item?.body && (
|
|
37
|
+
<NotFoundSource
|
|
38
|
+
simple
|
|
39
|
+
content={t('NO_CONTENT_TO_SHOW', 'Nothing to show')}
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
42
|
+
</Container>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -103,6 +103,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
103
103
|
const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
|
|
104
104
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
105
105
|
const isMultiDriverTips = configs?.checkout_multi_business_enabled?.value === '1'
|
|
106
|
+
const isGuestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
|
|
106
107
|
const walletCarts = (Object.values(carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && cart?.wallets) || null) || []
|
|
107
108
|
const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
|
|
108
109
|
const cartsToShow = openCarts?.length > 0 ? openCarts : cartsInvalid
|
|
@@ -123,7 +124,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
123
124
|
|
|
124
125
|
const creditPointGeneralPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
|
|
125
126
|
const loyalBusinessAvailable = creditPointGeneralPlan?.businesses?.filter((b: any) => b.accumulates) ?? []
|
|
126
|
-
const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field
|
|
127
|
+
const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field: any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
|
|
127
128
|
|
|
128
129
|
const accumulationRateBusiness = (businessId: number) => {
|
|
129
130
|
const value = loyalBusinessAvailable?.find((loyal: any) => loyal.business_id === businessId)?.accumulation_rate ?? 0
|
|
@@ -162,7 +163,8 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
162
163
|
const isDisablePlaceOrderButton = cartGroup?.loading || placing || (!(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) && cartGroup?.result?.balance > 0) ||
|
|
163
164
|
(paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data) ||
|
|
164
165
|
walletCarts.length > 0
|
|
165
|
-
|| (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) || openCarts?.length === 0
|
|
166
|
+
|| (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) || openCarts?.length === 0 ||
|
|
167
|
+
(!isGuestCheckoutEnabled && !!user?.guest_id)
|
|
166
168
|
|
|
167
169
|
const handleMomentClick = () => {
|
|
168
170
|
if (isPreOrder) {
|
|
@@ -428,14 +430,16 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
428
430
|
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
429
431
|
onClick={() => setOpenModal({ ...openModal, login: true })}
|
|
430
432
|
/>
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
433
|
+
{isGuestCheckoutEnabled && (
|
|
434
|
+
<OButton
|
|
435
|
+
text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
|
|
436
|
+
textStyle={{ color: theme.colors.black }}
|
|
437
|
+
bgColor={theme.colors.white}
|
|
438
|
+
borderColor={theme.colors.black}
|
|
439
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
440
|
+
onClick={() => setAllowedGuest(true)}
|
|
441
|
+
/>
|
|
442
|
+
)}
|
|
439
443
|
</View>
|
|
440
444
|
) : (
|
|
441
445
|
<UserDetails
|
|
@@ -643,6 +647,14 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
643
647
|
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
644
648
|
</OText>
|
|
645
649
|
)}
|
|
650
|
+
{(!isGuestCheckoutEnabled && !!user?.guest_id) && (
|
|
651
|
+
<OText
|
|
652
|
+
color={theme.colors.error}
|
|
653
|
+
size={12}
|
|
654
|
+
>
|
|
655
|
+
{t('LOGIN_SIGN_UP_COMPLETE_ORDER', 'Login/Sign up to complete your order.')}
|
|
656
|
+
</OText>
|
|
657
|
+
)}
|
|
646
658
|
</ChContainer>
|
|
647
659
|
<OModal
|
|
648
660
|
open={openModal.signup}
|
|
@@ -5,48 +5,49 @@ import { NotFoundSourceParams } from '../../types'
|
|
|
5
5
|
import { useTheme } from 'styled-components/native';
|
|
6
6
|
import Foundation from 'react-native-vector-icons/Foundation'
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
NotFound,
|
|
9
|
+
NotFoundImage
|
|
10
10
|
} from './styles'
|
|
11
11
|
|
|
12
12
|
export const NotFoundSource = (props: NotFoundSourceParams) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
const {
|
|
14
|
+
hideImage,
|
|
15
|
+
content,
|
|
16
|
+
btnTitle,
|
|
17
|
+
btnStyle,
|
|
18
|
+
conditioned,
|
|
19
|
+
onClickButton,
|
|
20
|
+
simple
|
|
21
|
+
} = props
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
const theme = useTheme();
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
25
|
+
return (
|
|
26
|
+
<NotFound simple={simple}>
|
|
27
|
+
{!hideImage && !simple && (
|
|
28
|
+
<NotFoundImage>
|
|
29
|
+
<Foundation
|
|
30
|
+
name='page-search'
|
|
31
|
+
color={theme.colors.primary}
|
|
32
|
+
size={60}
|
|
33
|
+
style={{ marginBottom: 10 }}
|
|
34
|
+
/>
|
|
35
|
+
</NotFoundImage>
|
|
36
|
+
)}
|
|
37
|
+
{content && conditioned && <OText color={theme.colors.disabled} size={16} style={{ textAlign: 'center' }}>{content}</OText>}
|
|
38
|
+
{content && !conditioned && <OText color={theme.colors.disabled} size={16} style={{ textAlign: 'center' }}>{content}</OText>}
|
|
39
|
+
{!onClickButton && props.children && (
|
|
40
|
+
props.children
|
|
41
|
+
)}
|
|
42
|
+
{onClickButton && (
|
|
43
|
+
<View style={{ marginTop: 10, width: '100%' }}>
|
|
44
|
+
<OButton
|
|
45
|
+
style={{ width: '100%', height: 50, ...btnStyle }}
|
|
46
|
+
onClick={() => onClickButton()}
|
|
47
|
+
text={btnTitle}
|
|
48
|
+
/>
|
|
49
|
+
</View>
|
|
50
|
+
)}
|
|
51
|
+
</NotFound>
|
|
52
|
+
)
|
|
52
53
|
}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import styled from 'styled-components/native'
|
|
1
|
+
import styled, { css } from 'styled-components/native'
|
|
2
2
|
|
|
3
3
|
export const NotFound = styled.View`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
${(props: any) => props.simple
|
|
5
|
+
? css`
|
|
6
|
+
background-color: ${(props: any) => props.theme.colors?.white};
|
|
7
|
+
border-radius: 10px;
|
|
8
|
+
padding: 15px;
|
|
9
|
+
padding-horizontal: 20px;
|
|
10
|
+
border: 1px ${(props: any) => props.theme.colors?.border};
|
|
11
|
+
` : css`
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: auto;
|
|
18
|
+
margin: auto auto;
|
|
19
|
+
padding: 10px;
|
|
20
|
+
`}
|
|
12
21
|
`
|
|
13
22
|
|
|
14
23
|
export const NotFoundImage = styled.View`
|
|
@@ -48,6 +48,8 @@ const stripeDirectMethods = ['stripe_direct']
|
|
|
48
48
|
const webViewPaymentGateway: any = ['paypal', 'square']
|
|
49
49
|
const multiCheckoutMethods = ['global_google_pay', 'global_apple_pay']
|
|
50
50
|
const cardsPaymethods = ['credomatic']
|
|
51
|
+
const guestNotSupportedMethods = ['stripe', 'stripe_connect', 'stripe_redirect']
|
|
52
|
+
const popupMethods = [...guestNotSupportedMethods, 'stripe_direct', 'paypal']
|
|
51
53
|
|
|
52
54
|
const PaymentOptionsUI = (props: any) => {
|
|
53
55
|
const {
|
|
@@ -77,7 +79,9 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
77
79
|
paymethodClicked,
|
|
78
80
|
setPaymethodClicked,
|
|
79
81
|
androidAppId,
|
|
80
|
-
setUserHasCards
|
|
82
|
+
setUserHasCards,
|
|
83
|
+
guestDisabledError,
|
|
84
|
+
handleOpenGuestSignup
|
|
81
85
|
} = props
|
|
82
86
|
|
|
83
87
|
const theme = useTheme();
|
|
@@ -125,6 +129,11 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
125
129
|
const paymethodsFieldRequired = ['paypal', 'apple_pay', 'global_apple_pay']
|
|
126
130
|
|
|
127
131
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
132
|
+
const _guestNotSupportedMethods = guestDisabledError ? popupMethods : guestNotSupportedMethods
|
|
133
|
+
if (handleOpenGuestSignup && _guestNotSupportedMethods.includes(paymethod?.gateway) && !!user?.guest_id) {
|
|
134
|
+
handleOpenGuestSignup()
|
|
135
|
+
return
|
|
136
|
+
}
|
|
128
137
|
if (cart?.balance > 0 || !!user?.guest_id) {
|
|
129
138
|
if (paymethodsFieldRequired.includes(paymethod?.gateway) && requiredFields.length > 0) {
|
|
130
139
|
openUserModal && openUserModal(true)
|