ordering-ui-react-native 0.14.27 → 0.14.28
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 -1
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +49 -31
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +7 -0
- package/themes/original/src/components/BusinessProductsList/index.tsx +3 -3
- package/themes/original/src/components/Cart/index.tsx +2 -0
- package/themes/original/src/components/ProductForm/index.tsx +34 -33
- package/themes/original/src/components/ProductIngredient/index.tsx +5 -4
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ordering-ui-react-native",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.28",
|
|
4
4
|
"description": "Reusable components made in react native",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"author": "ordering.inc",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"react-native-bootsplash": "^3.2.3",
|
|
71
71
|
"react-native-calendar-picker": "^7.1.2",
|
|
72
72
|
"react-native-calendar-strip": "^2.2.5",
|
|
73
|
+
"react-native-color-matrix-image-filters": "^5.2.10",
|
|
73
74
|
"react-native-country-picker-modal": "^2.0.0",
|
|
74
75
|
"react-native-credit-card-input": "^0.4.1",
|
|
75
76
|
"react-native-document-picker": "^5.2.0",
|
|
@@ -9,16 +9,19 @@ import {
|
|
|
9
9
|
BIInfo,
|
|
10
10
|
BIContentInfo,
|
|
11
11
|
BITotal,
|
|
12
|
-
BIActions
|
|
12
|
+
BIActions,
|
|
13
|
+
PriceContainer
|
|
13
14
|
} from './styles';
|
|
14
|
-
import { OAlert, OIcon, OText } from '../shared';
|
|
15
|
+
import { OAlert, OButton, OIcon, OText } from '../shared';
|
|
15
16
|
|
|
16
17
|
export const BusinessItemAccordion = (props: any) => {
|
|
17
18
|
const {
|
|
18
19
|
cart,
|
|
19
20
|
moment,
|
|
20
|
-
|
|
21
|
-
handleClearProducts
|
|
21
|
+
singleBusiness,
|
|
22
|
+
handleClearProducts,
|
|
23
|
+
handleClickCheckout,
|
|
24
|
+
checkoutButtonDisabled
|
|
22
25
|
} = props
|
|
23
26
|
|
|
24
27
|
const [orderState] = useOrder();
|
|
@@ -41,7 +44,7 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
41
44
|
}, [orderState?.carts])
|
|
42
45
|
|
|
43
46
|
return (
|
|
44
|
-
<BIContainer isClosed={isClosed}>
|
|
47
|
+
<BIContainer isClosed={isClosed} checkoutVisible={!isActive && !isClosed && !!isProducts && !checkoutButtonDisabled}>
|
|
45
48
|
<BIHeader
|
|
46
49
|
isClosed={isClosed}
|
|
47
50
|
onPress={() => !isClosed ? setActiveState(!isActive) : isClosed}
|
|
@@ -71,37 +74,39 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
71
74
|
{props.onNavigationRedirect && !isClosed && (
|
|
72
75
|
<>
|
|
73
76
|
<TouchableOpacity onPress={() => props.onNavigationRedirect('Business', { store: cart?.business?.slug })}>
|
|
74
|
-
<OText color={theme.colors.
|
|
77
|
+
<OText color={theme.colors.primary} size={12} lineHeight={18} style={{ textDecorationLine: 'underline' }}>{t('GO_TO_STORE', 'Go to store')}</OText>
|
|
75
78
|
</TouchableOpacity>
|
|
76
|
-
<OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
|
|
77
79
|
</>
|
|
78
80
|
)}
|
|
79
81
|
{!isCartPending && !isClosed && (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
<>
|
|
83
|
+
<OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
|
|
84
|
+
<OAlert
|
|
85
|
+
title={t('DELETE_CART', 'Delete Cart')}
|
|
86
|
+
message={t('QUESTION_DELETE_CART', 'Are you sure to you wants delete the selected cart')}
|
|
87
|
+
onAccept={() => handleClearProducts()}
|
|
88
|
+
>
|
|
89
|
+
<OText size={12} lineHeight={18} color={theme.colors.primary} style={{ textDecorationLine: 'underline' }}>{t('CLEAR_CART', 'Clear cart')}</OText>
|
|
90
|
+
</OAlert>
|
|
91
|
+
</>
|
|
92
|
+
)}
|
|
93
|
+
{props.handleChangeStore && (
|
|
94
|
+
<>
|
|
95
|
+
<OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
|
|
96
|
+
<TouchableOpacity
|
|
97
|
+
onPress={props.handleChangeStore}
|
|
98
|
+
>
|
|
99
|
+
<OText
|
|
100
|
+
size={12}
|
|
101
|
+
lineHeight={18}
|
|
102
|
+
color={theme.colors.textSecondary}
|
|
103
|
+
style={{ textDecorationLine: 'underline' }}
|
|
104
|
+
>
|
|
105
|
+
{t('CHANGE_STORE', 'Change store')}
|
|
106
|
+
</OText>
|
|
107
|
+
</TouchableOpacity>
|
|
108
|
+
</>
|
|
87
109
|
)}
|
|
88
|
-
{props.handleChangeStore && (
|
|
89
|
-
<>
|
|
90
|
-
<OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
|
|
91
|
-
<TouchableOpacity
|
|
92
|
-
onPress={props.handleChangeStore}
|
|
93
|
-
>
|
|
94
|
-
<OText
|
|
95
|
-
size={12}
|
|
96
|
-
lineHeight={18}
|
|
97
|
-
color={theme.colors.textSecondary}
|
|
98
|
-
style={{ textDecorationLine: 'underline' }}
|
|
99
|
-
>
|
|
100
|
-
{t('CHANGE_STORE', 'Change store')}
|
|
101
|
-
</OText>
|
|
102
|
-
</TouchableOpacity>
|
|
103
|
-
</>
|
|
104
|
-
)}
|
|
105
110
|
</View>
|
|
106
111
|
</BIContentInfo>
|
|
107
112
|
</BIInfo>
|
|
@@ -134,6 +139,19 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
134
139
|
)}
|
|
135
140
|
</BIActions>
|
|
136
141
|
</BIHeader>
|
|
142
|
+
{!isActive && !isClosed && !!isProducts && !checkoutButtonDisabled && (
|
|
143
|
+
<PriceContainer>
|
|
144
|
+
<OText>{parsePrice(cart?.total)}</OText>
|
|
145
|
+
<OButton
|
|
146
|
+
onClick={handleClickCheckout}
|
|
147
|
+
textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
|
|
148
|
+
style={{ width: 160, flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
149
|
+
text={t('CHECKOUT', 'Checkout')}
|
|
150
|
+
bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
|
|
151
|
+
borderColor={theme.colors.primary}
|
|
152
|
+
/>
|
|
153
|
+
</PriceContainer>
|
|
154
|
+
)}
|
|
137
155
|
|
|
138
156
|
<BIContent style={{ display: isActive ? 'flex' : 'none' }}>
|
|
139
157
|
{props.children}
|
|
@@ -42,7 +42,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
42
42
|
return (
|
|
43
43
|
<ProductsContainer>
|
|
44
44
|
{category.id &&
|
|
45
|
-
categoryState.products?.map((product: any) => (
|
|
45
|
+
categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any) => (
|
|
46
46
|
<SingleProductCard
|
|
47
47
|
key={'prod_' + product.id}
|
|
48
48
|
isSoldOut={product.inventoried && !product.quantity}
|
|
@@ -63,7 +63,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
63
63
|
{t('FEATURED', 'Featured')}
|
|
64
64
|
</OText>
|
|
65
65
|
<>
|
|
66
|
-
{categoryState.products?.map(
|
|
66
|
+
{categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map(
|
|
67
67
|
(product: any, i: any) =>
|
|
68
68
|
product.featured && (
|
|
69
69
|
<SingleProductCard
|
|
@@ -110,7 +110,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
110
110
|
</OText>
|
|
111
111
|
</View>
|
|
112
112
|
<>
|
|
113
|
-
{products.map((product: any, i: any) => (
|
|
113
|
+
{products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
|
|
114
114
|
<SingleProductCard
|
|
115
115
|
key={i}
|
|
116
116
|
isSoldOut={product.inventoried && !product.quantity}
|
|
@@ -145,6 +145,8 @@ const CartUI = (props: any) => {
|
|
|
145
145
|
handleCartOpen={handleCartOpen}
|
|
146
146
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
147
147
|
handleChangeStore={props.isFranchiseApp ? () => setOpenChangeStore(true) : null}
|
|
148
|
+
handleClickCheckout={() => setOpenUpselling(true)}
|
|
149
|
+
checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
|
|
148
150
|
>
|
|
149
151
|
{cart?.products?.length > 0 && cart?.products.map((product: any) => (
|
|
150
152
|
<ProductItemAccordion
|
|
@@ -12,6 +12,9 @@ import { ProductOption } from '../ProductOption';
|
|
|
12
12
|
import Swiper from 'react-native-swiper'
|
|
13
13
|
import FastImage from 'react-native-fast-image';
|
|
14
14
|
import IconAntDesign from 'react-native-vector-icons/AntDesign';
|
|
15
|
+
import {
|
|
16
|
+
Grayscale
|
|
17
|
+
} from 'react-native-color-matrix-image-filters'
|
|
15
18
|
|
|
16
19
|
import { View, TouchableOpacity, StyleSheet, Dimensions, Platform, AppRegistry, I18nManager } from 'react-native';
|
|
17
20
|
|
|
@@ -149,9 +152,12 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
149
152
|
if (errors[`id:${id}`]) {
|
|
150
153
|
bgColor = 'rgba(255, 0, 0, 0.05)';
|
|
151
154
|
}
|
|
152
|
-
if (
|
|
155
|
+
if (maxProductQuantity <= 0) {
|
|
153
156
|
bgColor = 'hsl(0, 0%, 72%)';
|
|
154
157
|
}
|
|
158
|
+
if (isSoldOut) {
|
|
159
|
+
bgColor = theme.colors.white;
|
|
160
|
+
}
|
|
155
161
|
return bgColor;
|
|
156
162
|
};
|
|
157
163
|
|
|
@@ -316,13 +322,15 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
316
322
|
style={styles.slide1}
|
|
317
323
|
key={i}
|
|
318
324
|
>
|
|
319
|
-
<
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
325
|
+
<Grayscale amount={isSoldOut ? 1 : 0}>
|
|
326
|
+
<FastImage
|
|
327
|
+
style={{ height: '100%' }}
|
|
328
|
+
source={{
|
|
329
|
+
uri: optimizeImage(img, 'h_258,c_limit'),
|
|
330
|
+
priority: FastImage.priority.normal,
|
|
331
|
+
}}
|
|
332
|
+
/>
|
|
333
|
+
</Grayscale>
|
|
326
334
|
</View>
|
|
327
335
|
))}
|
|
328
336
|
</Swiper>
|
|
@@ -346,17 +354,19 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
346
354
|
opacity: index === thumbsSwiper ? 1 : 0.8
|
|
347
355
|
}}
|
|
348
356
|
>
|
|
349
|
-
<
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
<Grayscale amount={isSoldOut ? 1 : 0}>
|
|
358
|
+
<OIcon
|
|
359
|
+
url={img}
|
|
360
|
+
style={{
|
|
361
|
+
borderColor: theme.colors.lightGray,
|
|
362
|
+
borderRadius: 8,
|
|
363
|
+
minHeight: '100%'
|
|
364
|
+
}}
|
|
365
|
+
width={56}
|
|
366
|
+
height={56}
|
|
367
|
+
cover
|
|
368
|
+
/>
|
|
369
|
+
</Grayscale>
|
|
360
370
|
</View>
|
|
361
371
|
</TouchableOpacity>
|
|
362
372
|
|
|
@@ -488,13 +498,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
488
498
|
{t('INGREDIENTS', 'Ingredients')}
|
|
489
499
|
</OText>
|
|
490
500
|
</SectionTitle>
|
|
491
|
-
<WrapperIngredients
|
|
492
|
-
style={{
|
|
493
|
-
backgroundColor:
|
|
494
|
-
isSoldOut || maxProductQuantity <= 0
|
|
495
|
-
? 'hsl(0, 0%, 72%)'
|
|
496
|
-
: theme.colors.white,
|
|
497
|
-
}}>
|
|
501
|
+
<WrapperIngredients>
|
|
498
502
|
{product?.ingredients.map((ingredient: any) => (
|
|
499
503
|
<ProductIngredient
|
|
500
504
|
key={ingredient.id}
|
|
@@ -503,6 +507,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
503
507
|
productCart.ingredients[`id:${ingredient.id}`]
|
|
504
508
|
}
|
|
505
509
|
onChange={handleChangeIngredientState}
|
|
510
|
+
isSoldOut={isSoldOut}
|
|
506
511
|
/>
|
|
507
512
|
))}
|
|
508
513
|
</WrapperIngredients>
|
|
@@ -540,6 +545,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
540
545
|
return (
|
|
541
546
|
<ProductOptionSubOption
|
|
542
547
|
key={suboption.id}
|
|
548
|
+
isSoldOut={isSoldOut}
|
|
543
549
|
onChange={
|
|
544
550
|
handleChangeSuboptionState
|
|
545
551
|
}
|
|
@@ -573,13 +579,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
573
579
|
{t('INGREDIENTS', 'Ingredients')}
|
|
574
580
|
</OText>
|
|
575
581
|
</SectionTitle>
|
|
576
|
-
<WrapperIngredients
|
|
577
|
-
style={{
|
|
578
|
-
backgroundColor:
|
|
579
|
-
isSoldOut || maxProductQuantity <= 0
|
|
580
|
-
? 'hsl(0, 0%, 72%)'
|
|
581
|
-
: theme.colors.white,
|
|
582
|
-
}}>
|
|
582
|
+
<WrapperIngredients>
|
|
583
583
|
{product?.ingredients.map((ingredient: any) => (
|
|
584
584
|
<ProductIngredient
|
|
585
585
|
key={ingredient.id}
|
|
@@ -588,6 +588,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
588
588
|
productCart.ingredients[`id:${ingredient.id}`]
|
|
589
589
|
}
|
|
590
590
|
onChange={handleChangeIngredientState}
|
|
591
|
+
isSoldOut={isSoldOut}
|
|
591
592
|
/>
|
|
592
593
|
))}
|
|
593
594
|
</WrapperIngredients>
|
|
@@ -10,18 +10,19 @@ const ProductIngredientUI = (props: any) => {
|
|
|
10
10
|
const {
|
|
11
11
|
state,
|
|
12
12
|
ingredient,
|
|
13
|
-
toggleSelect
|
|
13
|
+
toggleSelect,
|
|
14
|
+
isSoldOut
|
|
14
15
|
} = props
|
|
15
16
|
|
|
16
17
|
const theme = useTheme();
|
|
17
18
|
|
|
18
19
|
return (
|
|
19
|
-
<Container onPress={() => toggleSelect()}>
|
|
20
|
+
<Container disabled={isSoldOut} onPress={() => toggleSelect()}>
|
|
20
21
|
<View>
|
|
21
|
-
{state?.selected ? (
|
|
22
|
+
{state?.selected && !isSoldOut ? (
|
|
22
23
|
<MaterialCommunityIcon name='checkbox-marked' color={theme.colors.primary} size={24} />
|
|
23
24
|
) : (
|
|
24
|
-
<MaterialCommunityIcon name='checkbox-blank-outline' color=
|
|
25
|
+
<MaterialCommunityIcon name='checkbox-blank-outline' color='#cbcbcb' size={24} />
|
|
25
26
|
)}
|
|
26
27
|
</View>
|
|
27
28
|
<OText mLeft={10}>
|
|
@@ -53,8 +53,8 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
53
53
|
const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
|
-
<Container
|
|
57
|
-
<IconControl onPress={() => handleSuboptionClick()}>
|
|
56
|
+
<Container>
|
|
57
|
+
<IconControl disabled={disabled} onPress={() => handleSuboptionClick()}>
|
|
58
58
|
{((option?.min === 0 && option?.max === 1) || option?.max > 1) ? (
|
|
59
59
|
state?.selected ? (
|
|
60
60
|
<OIcon src={theme.images.general.check_act} color={theme.colors.primary} width={16} />
|
|
@@ -73,30 +73,30 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
73
73
|
</OText>
|
|
74
74
|
</IconControl>
|
|
75
75
|
{showMessage && <OText size={10} mLeft={4} mRight={4} style={{ flex: 1, textAlign: 'center' }} color={theme.colors.primary}>{`${t('OPTIONS_MAX_LIMIT', 'Maximum options to choose')}: ${option?.max}`}</OText>}
|
|
76
|
-
{option?.allow_suboption_quantity && (
|
|
76
|
+
{option?.allow_suboption_quantity && state?.selected && (
|
|
77
77
|
<QuantityControl>
|
|
78
|
-
<Checkbox disabled={state.quantity === 0} onPress={decrement}>
|
|
78
|
+
<Checkbox disabled={disabled || state.quantity === 0} onPress={decrement}>
|
|
79
79
|
<OIcon
|
|
80
80
|
src={theme.images.general.minus}
|
|
81
81
|
width={16}
|
|
82
|
-
color={state.quantity === 0 ? theme.colors.disabled : theme.colors.primary}
|
|
82
|
+
color={state.quantity === 0 || disabled ? theme.colors.disabled : theme.colors.primary}
|
|
83
83
|
/>
|
|
84
84
|
</Checkbox>
|
|
85
85
|
<OText mLeft={5} mRight={5}>
|
|
86
86
|
{state.quantity}
|
|
87
87
|
</OText>
|
|
88
|
-
<Checkbox disabled={disableIncrement} onPress={increment}>
|
|
88
|
+
<Checkbox disabled={disabled || disableIncrement} onPress={increment}>
|
|
89
89
|
<OIcon
|
|
90
90
|
src={theme.images.general.plus}
|
|
91
91
|
width={16}
|
|
92
|
-
color={disableIncrement ? theme.colors.disabled : theme.colors.primary}
|
|
92
|
+
color={disableIncrement || disabled ? theme.colors.disabled : theme.colors.primary}
|
|
93
93
|
/>
|
|
94
94
|
</Checkbox>
|
|
95
95
|
</QuantityControl>
|
|
96
96
|
)}
|
|
97
|
-
{option?.with_half_option && (
|
|
97
|
+
{option?.with_half_option && state?.selected && (
|
|
98
98
|
<PositionControl>
|
|
99
|
-
<Circle onPress={() => changePosition('left')}>
|
|
99
|
+
<Circle disabled={disabled} onPress={() => changePosition('left')}>
|
|
100
100
|
<OIcon
|
|
101
101
|
src={theme.images.general.half_l}
|
|
102
102
|
color={state.selected && state.position === 'left' ? theme.colors.primary : '#cbcbcb'}
|
|
@@ -104,14 +104,14 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
104
104
|
style={styles.inverse}
|
|
105
105
|
/>
|
|
106
106
|
</Circle>
|
|
107
|
-
<Circle onPress={() => changePosition('whole')}>
|
|
107
|
+
<Circle disabled={disabled} onPress={() => changePosition('whole')}>
|
|
108
108
|
<OIcon
|
|
109
109
|
src={theme.images.general.half_f}
|
|
110
110
|
color={state.selected && state.position === 'whole' ? theme.colors.primary : '#cbcbcb'}
|
|
111
111
|
width={16}
|
|
112
112
|
/>
|
|
113
113
|
</Circle>
|
|
114
|
-
<Circle onPress={() => changePosition('right')}>
|
|
114
|
+
<Circle disabled={disabled} onPress={() => changePosition('right')}>
|
|
115
115
|
<OIcon
|
|
116
116
|
src={theme.images.general.half_r}
|
|
117
117
|
color={state.selected && state.position === 'right' ? theme.colors.primary : '#cbcbcb'}
|