ordering-ui-react-native 0.14.95 → 0.14.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/src/components/Cart/index.tsx +1 -1
- package/src/components/OrderDetails/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsList/index.tsx +49 -5
- package/themes/original/src/components/BusinessProductsListing/index.tsx +18 -5
- package/themes/original/src/components/Cart/index.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +1 -1
- package/themes/original/src/components/SingleProductCard/index.tsx +5 -12
package/package.json
CHANGED
|
@@ -220,7 +220,7 @@ const CartUI = (props: any) => {
|
|
|
220
220
|
<OSRow>
|
|
221
221
|
<OText numberOfLines={1}>
|
|
222
222
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
223
|
-
({parsePrice(fee?.fixed)} + {fee
|
|
223
|
+
({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
|
|
224
224
|
</OText>
|
|
225
225
|
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
|
|
226
226
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
@@ -535,7 +535,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
535
535
|
<OSRow>
|
|
536
536
|
<OText numberOfLines={1}>
|
|
537
537
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
538
|
-
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
538
|
+
({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
|
|
539
539
|
</OText>
|
|
540
540
|
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
|
|
541
541
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { ProductsList, useLanguage, useUtils, useConfig } from 'ordering-components/native';
|
|
3
3
|
import { SingleProductCard } from '../SingleProductCard';
|
|
4
4
|
import { NotFoundSource } from '../NotFoundSource';
|
|
5
5
|
import { BusinessProductsListParams } from '../../types';
|
|
6
|
-
import { OIcon, OText } from '../shared';
|
|
6
|
+
import { OButton, OIcon, OModal, OText } from '../shared';
|
|
7
7
|
import { ProductsContainer, ErrorMessage, WrapperNotFound } from './styles';
|
|
8
8
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
9
9
|
import { View } from 'react-native';
|
|
10
10
|
import { StyleSheet } from 'react-native';
|
|
11
|
+
import { useTheme } from 'styled-components/native';
|
|
11
12
|
|
|
12
13
|
const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
13
14
|
const {
|
|
@@ -32,8 +33,9 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
32
33
|
const [, t] = useLanguage();
|
|
33
34
|
const [{ optimizeImage }] = useUtils()
|
|
34
35
|
const [{ configs }] = useConfig()
|
|
36
|
+
const theme = useTheme()
|
|
35
37
|
const isUseParentCategory = configs?.use_parent_category?.value === 'true' || configs?.use_parent_category?.value === '1'
|
|
36
|
-
|
|
38
|
+
const [openDescription, setOpenDescription] = useState<any>(null)
|
|
37
39
|
const handleOnLayout = (event: any, categoryId: any) => {
|
|
38
40
|
const _categoriesLayout = { ...categoriesLayout }
|
|
39
41
|
const categoryKey = 'cat_' + categoryId
|
|
@@ -84,8 +86,11 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
84
86
|
|
|
85
87
|
{!category?.id && categories.filter(category => category?.id !== null).map((category, i, _categories) => {
|
|
86
88
|
const products = !isUseParentCategory
|
|
87
|
-
? categoryState?.products?.filter((product
|
|
88
|
-
: categoryState?.products?.filter((product
|
|
89
|
+
? categoryState?.products?.filter((product: any) => product?.category_id === category?.id) ?? []
|
|
90
|
+
: categoryState?.products?.filter((product: any) => category?.children?.some((cat: any) => cat.category_id === product?.category_id)) ?? []
|
|
91
|
+
|
|
92
|
+
const shortCategoryDescription = category?.description?.length > 80 ? `${category?.description?.substring(0, 80)}...` : category?.description
|
|
93
|
+
|
|
89
94
|
return (
|
|
90
95
|
<React.Fragment key={'cat_' + category.id}>
|
|
91
96
|
{products.length > 0 && (
|
|
@@ -106,6 +111,28 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
106
111
|
{category.name}
|
|
107
112
|
</OText>
|
|
108
113
|
</View>
|
|
114
|
+
{!!category?.description && (
|
|
115
|
+
<View style={{ position: 'relative' }}>
|
|
116
|
+
<OText size={12} weight={'500'} mBottom={5}>
|
|
117
|
+
{shortCategoryDescription}
|
|
118
|
+
{category?.description?.length > 80 && (
|
|
119
|
+
<OButton
|
|
120
|
+
style={{ height: 15, paddingRight: 0, paddingLeft: 0, borderWidth: 0 }}
|
|
121
|
+
text={t('SEE_MORE', 'See more')}
|
|
122
|
+
parentStyle={{ padding: 0 }}
|
|
123
|
+
onClick={() => setOpenDescription(category)}
|
|
124
|
+
bgColor='transparent'
|
|
125
|
+
textStyle={{
|
|
126
|
+
fontSize: 12,
|
|
127
|
+
borderBottomWidth: 1,
|
|
128
|
+
borderBottomColor: theme.colors.primary,
|
|
129
|
+
color: theme.colors.primary
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
133
|
+
</OText>
|
|
134
|
+
</View>
|
|
135
|
+
)}
|
|
109
136
|
<>
|
|
110
137
|
{products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
|
|
111
138
|
<SingleProductCard
|
|
@@ -188,6 +215,23 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
188
215
|
<OText>{e}</OText>
|
|
189
216
|
</ErrorMessage>
|
|
190
217
|
))}
|
|
218
|
+
<OModal
|
|
219
|
+
open={!!openDescription}
|
|
220
|
+
title={openDescription?.name}
|
|
221
|
+
onClose={() => setOpenDescription(null)}
|
|
222
|
+
>
|
|
223
|
+
<View style={{ padding: 20 }}>
|
|
224
|
+
{!!openDescription?.image && (
|
|
225
|
+
<OIcon
|
|
226
|
+
url={optimizeImage(openDescription?.image, 'h_100,c_limit')}
|
|
227
|
+
width={240}
|
|
228
|
+
height={240}
|
|
229
|
+
style={{ borderRadius: 7.6 }}
|
|
230
|
+
/>
|
|
231
|
+
)}
|
|
232
|
+
<OText>{openDescription?.description}</OText>
|
|
233
|
+
</View>
|
|
234
|
+
</OModal>
|
|
191
235
|
</ProductsContainer>
|
|
192
236
|
);
|
|
193
237
|
};
|
|
@@ -96,11 +96,24 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
const onProductClick = (product: any) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
const cartProduct = currentCart?.products?.find((cproduct: any) => cproduct?.id === product?.id)
|
|
100
|
+
if (cartProduct) {
|
|
101
|
+
onRedirect('ProductDetails', {
|
|
102
|
+
businessId: business.id,
|
|
103
|
+
isCartProduct: true,
|
|
104
|
+
productCart: cartProduct,
|
|
105
|
+
businessSlug: business?.slug,
|
|
106
|
+
categoryId: cartProduct?.category_id,
|
|
107
|
+
productId: cartProduct?.id,
|
|
108
|
+
})
|
|
109
|
+
} else {
|
|
110
|
+
onRedirect('ProductDetails', {
|
|
111
|
+
product: product,
|
|
112
|
+
businessSlug: business.slug,
|
|
113
|
+
businessId: business.id,
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
const handleCancel = () => {
|
|
@@ -252,7 +252,7 @@ const CartUI = (props: any) => {
|
|
|
252
252
|
<OSRow>
|
|
253
253
|
<OText size={12} lineHeight={18} numberOfLines={1}>
|
|
254
254
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
255
|
-
({parsePrice(fee?.fixed)} + {fee
|
|
255
|
+
({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
|
|
256
256
|
</OText>
|
|
257
257
|
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
|
|
258
258
|
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
@@ -895,7 +895,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
895
895
|
<OSRow>
|
|
896
896
|
<OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
|
|
897
897
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
898
|
-
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
898
|
+
({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
|
|
899
899
|
</OText>
|
|
900
900
|
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
|
|
901
901
|
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
@@ -77,25 +77,18 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
|
77
77
|
const editMode = typeof product?.code !== 'undefined';
|
|
78
78
|
|
|
79
79
|
const removeToBalance = editMode ? product?.quantity : 0;
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
const totalBalance = (productCart?.quantity || 0) - removeToBalance;
|
|
80
|
+
const cartProducts: any = Object.values(orderState.carts).reduce((products: any, _cart: any) => [...products, ..._cart?.products], [])
|
|
81
|
+
const productBalance = cartProducts.reduce((sum: any, _product: any) => sum + (_product.id === product?.id ? _product.quantity : 0), 0)
|
|
82
|
+
|
|
83
|
+
const totalBalance = (productBalance || 0) - removeToBalance
|
|
85
84
|
|
|
86
85
|
const maxCartProductConfig =
|
|
87
86
|
(stateConfig.configs.max_product_amount
|
|
88
87
|
? parseInt(stateConfig.configs.max_product_amount)
|
|
89
88
|
: 100) - totalBalance;
|
|
90
89
|
|
|
91
|
-
const productBalance =
|
|
92
|
-
(cart?.products?.reduce(
|
|
93
|
-
(sum: any, _product: any) =>
|
|
94
|
-
sum + (product && _product.id === product?.id ? _product.quantity : 0),
|
|
95
|
-
0,
|
|
96
|
-
) || 0) - removeToBalance;
|
|
97
90
|
let maxCartProductInventory =
|
|
98
|
-
(product?.inventoried ? product?.quantity : undefined) -
|
|
91
|
+
(product?.inventoried ? product?.quantity : undefined) - totalBalance;
|
|
99
92
|
maxCartProductInventory = !isNaN(maxCartProductInventory)
|
|
100
93
|
? maxCartProductInventory
|
|
101
94
|
: maxCartProductConfig;
|