ordering-ui-react-native 0.17.77 → 0.17.79
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/business/src/components/OrderDetails/OrderContentComponent.tsx +29 -14
- package/themes/business/src/components/shared/OLink.tsx +9 -2
- package/themes/business/src/components/shared/OText.tsx +6 -1
- package/themes/original/src/components/BusinessProductsListing/index.tsx +29 -1
- package/themes/original/src/components/FloatingButton/index.tsx +10 -13
- package/themes/original/src/components/MyOrders/index.tsx +2 -2
- package/themes/original/src/components/OrdersOption/index.tsx +2 -2
- package/themes/original/src/types/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
1
|
+
import React, { useState, useCallback } from 'react'
|
|
2
2
|
|
|
3
|
-
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { Platform, StyleSheet, View, TouchableOpacity } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { OButton, OText, OLink, OModal } from '../shared'
|
|
6
6
|
import {
|
|
@@ -44,6 +44,9 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
44
44
|
const [{ configs }] = useConfig();
|
|
45
45
|
const [openReviewModal, setOpenReviewModal] = useState(false)
|
|
46
46
|
|
|
47
|
+
const [isReadMore, setIsReadMore] = useState(false)
|
|
48
|
+
const [lengthMore, setLengthMore] = useState(false)
|
|
49
|
+
|
|
47
50
|
const pastOrderStatuses = [1, 2, 5, 6, 10, 11, 12, 16, 17]
|
|
48
51
|
|
|
49
52
|
const walletName: any = {
|
|
@@ -95,6 +98,10 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
95
98
|
return /^\d+$/.test(str);
|
|
96
99
|
}
|
|
97
100
|
|
|
101
|
+
const onTextLayout = useCallback((e: any) => {
|
|
102
|
+
setLengthMore(e.nativeEvent.lines.length >= 3); //to check the text is more than 2 lines or not
|
|
103
|
+
},[]);
|
|
104
|
+
|
|
98
105
|
return (
|
|
99
106
|
<OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
|
|
100
107
|
{isOrderGroup && (
|
|
@@ -298,18 +305,26 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
298
305
|
)}
|
|
299
306
|
|
|
300
307
|
{!!order?.customer?.address && (
|
|
301
|
-
|
|
302
|
-
<
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
308
|
+
<>
|
|
309
|
+
<View style={styles.linkWithIcons}>
|
|
310
|
+
<OLink
|
|
311
|
+
PressStyle={{ ...styles.linkWithIcons, marginBottom: 0 }}
|
|
312
|
+
url={Platform.select({
|
|
313
|
+
ios: `maps:0,0?q=${order?.customer?.address}`,
|
|
314
|
+
android: `geo:0,0?q=${order?.customer?.address}`,
|
|
315
|
+
})}
|
|
316
|
+
onTextLayout={onTextLayout}
|
|
317
|
+
numberOfLines={isReadMore ? 20 : 2}
|
|
318
|
+
shorcut={order?.customer?.address}
|
|
319
|
+
TextStyle={styles.textLink}
|
|
320
|
+
/>
|
|
321
|
+
</View>
|
|
322
|
+
{lengthMore && (
|
|
323
|
+
<TouchableOpacity onPress={() => setIsReadMore(!isReadMore)}>
|
|
324
|
+
<OText size={12} color={theme.colors.statusOrderBlue}>{isReadMore ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
|
|
325
|
+
</TouchableOpacity>
|
|
326
|
+
)}
|
|
327
|
+
</>
|
|
313
328
|
)}
|
|
314
329
|
|
|
315
330
|
{!!order?.customer?.internal_number && (
|
|
@@ -13,10 +13,11 @@ interface Props {
|
|
|
13
13
|
type?: string;
|
|
14
14
|
hasButton?: boolean;
|
|
15
15
|
numberOfLines?: number;
|
|
16
|
+
onTextLayout?: (e : any) => void;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const OLink = (props: Props): React.ReactElement => {
|
|
19
|
-
const { url, shorcut, color, PressStyle, TextStyle, type, hasButton, numberOfLines } = props;
|
|
20
|
+
const { url, shorcut, color, PressStyle, TextStyle, type, hasButton, numberOfLines, onTextLayout } = props;
|
|
20
21
|
const [, t] = useLanguage();
|
|
21
22
|
|
|
22
23
|
const handleAlert = () =>
|
|
@@ -78,7 +79,9 @@ const OLink = (props: Props): React.ReactElement => {
|
|
|
78
79
|
style={TextStyle}
|
|
79
80
|
numberOfLines={numberOfLines ?? 1}
|
|
80
81
|
ellipsizeMode="tail"
|
|
81
|
-
color={color}
|
|
82
|
+
color={color}
|
|
83
|
+
onTextLayout={onTextLayout}
|
|
84
|
+
>
|
|
82
85
|
{shorcut}
|
|
83
86
|
</OText>
|
|
84
87
|
)}
|
|
@@ -86,4 +89,8 @@ const OLink = (props: Props): React.ReactElement => {
|
|
|
86
89
|
);
|
|
87
90
|
};
|
|
88
91
|
|
|
92
|
+
OLink.defaultProps = {
|
|
93
|
+
onTextLayout: (e: any) => {}
|
|
94
|
+
};
|
|
95
|
+
|
|
89
96
|
export default OLink;
|
|
@@ -42,15 +42,20 @@ interface Props {
|
|
|
42
42
|
adjustsFontSizeToFit?: boolean;
|
|
43
43
|
textDecorationLine?: string;
|
|
44
44
|
lineHeight?: number;
|
|
45
|
+
onTextLayout?: (e : any) => void;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
const OText = (props: Props): React.ReactElement => {
|
|
48
49
|
return (
|
|
49
|
-
<SText {...props} style={[props.style, { lineHeight: props.lineHeight }]}>
|
|
50
|
+
<SText {...props} style={[props.style, { lineHeight: props.lineHeight }]} onTextLayout={props.onTextLayout}>
|
|
50
51
|
{props.children}
|
|
51
52
|
{props.space && ' '}
|
|
52
53
|
</SText>
|
|
53
54
|
);
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
OText.defaultProps = {
|
|
58
|
+
onTextLayout: (e: any) => {}
|
|
59
|
+
};
|
|
60
|
+
|
|
56
61
|
export default OText;
|
|
@@ -184,6 +184,35 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
const handleUpsellingPage = () => {
|
|
187
|
+
setOpenUpselling(false)
|
|
188
|
+
setCanOpenUpselling(false)
|
|
189
|
+
const cartSelectedHasGroup = currentCart?.group?.uuid
|
|
190
|
+
const cartFilterValidation = (cart: any) => cart?.valid && cart?.status !== 2
|
|
191
|
+
const cartsGroupLength = cartSelectedHasGroup ? Object.values(orderState.carts).filter((_cart: any) => _cart?.group?.uuid === cartSelectedHasGroup && cartFilterValidation(_cart))?.length : 0
|
|
192
|
+
if (cartsGroupLength > 1 && isCheckoutMultiBusinessEnabled) {
|
|
193
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
194
|
+
screen: 'MultiCheckout',
|
|
195
|
+
cartUuid: currentCart?.group?.uuid
|
|
196
|
+
})
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
const cartGroupsCount: any = {}
|
|
200
|
+
Object.values(orderState.carts).filter(_cart => cartFilterValidation(_cart))?.forEach((_cart: any) => {
|
|
201
|
+
if (cartGroupsCount[_cart?.group?.uuid]) {
|
|
202
|
+
cartGroupsCount[_cart?.group?.uuid] += 1
|
|
203
|
+
} else {
|
|
204
|
+
cartGroupsCount[_cart?.group?.uuid] = 1
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
let groupForTheCart
|
|
208
|
+
const groupForAddCartArray = Object.keys(cartGroupsCount).filter(cartGroupUuid => cartGroupsCount[cartGroupUuid] > 0 && cartGroupsCount[cartGroupUuid] < 5)
|
|
209
|
+
const max = Math.max(...groupForAddCartArray.map(uuid => cartGroupsCount[uuid]))
|
|
210
|
+
const indexes = groupForAddCartArray.filter(uuid => cartGroupsCount[uuid] === max)
|
|
211
|
+
if (indexes?.length > 1) {
|
|
212
|
+
groupForTheCart = indexes.find(uuid => uuid !== 'undefined')
|
|
213
|
+
} else {
|
|
214
|
+
groupForTheCart = indexes[0]
|
|
215
|
+
}
|
|
187
216
|
if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
|
|
188
217
|
onRedirect('CheckoutNavigator', {
|
|
189
218
|
screen: 'MultiCheckout'
|
|
@@ -531,7 +560,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
531
560
|
btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
|
|
532
561
|
btnRightValue={parsePrice(currentCart?.total)}
|
|
533
562
|
disabled={subtotalWithTaxes < currentCart?.minimum || openUpselling}
|
|
534
|
-
hideButton={isCheckoutMultiBusinessEnabled}
|
|
535
563
|
handleClick={() => setOpenUpselling(true)}
|
|
536
564
|
/>
|
|
537
565
|
</View>
|
|
@@ -22,8 +22,7 @@ const FloatingButtonUI = (props: FloatingButtonParams) => {
|
|
|
22
22
|
disabled,
|
|
23
23
|
isSecondaryBtn,
|
|
24
24
|
handleEmpty,
|
|
25
|
-
iosBottom
|
|
26
|
-
hideButton
|
|
25
|
+
iosBottom
|
|
27
26
|
} = props;
|
|
28
27
|
|
|
29
28
|
const [, t] = useLanguage();
|
|
@@ -78,17 +77,15 @@ const FloatingButtonUI = (props: FloatingButtonParams) => {
|
|
|
78
77
|
</View>
|
|
79
78
|
)}
|
|
80
79
|
</View>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
</Button>
|
|
91
|
-
)}
|
|
80
|
+
<Button
|
|
81
|
+
style={[isSecondaryBtn ? styles.secondaryBtn : styles.primaryBtn]}
|
|
82
|
+
onPress={handleButtonClick}
|
|
83
|
+
disabled={disabled}
|
|
84
|
+
>
|
|
85
|
+
<OText color={isSecondaryBtn ? theme.colors.textSecondary : theme.colors.white} lineHeight={24} size={14} weight={'400'}>
|
|
86
|
+
{btnText}
|
|
87
|
+
</OText>
|
|
88
|
+
</Button>
|
|
92
89
|
</Container>
|
|
93
90
|
);
|
|
94
91
|
};
|
|
@@ -23,7 +23,7 @@ export const MyOrders = (props: any) => {
|
|
|
23
23
|
const [isEmptyBusinesses, setIsEmptyBusinesses] = useState(false)
|
|
24
24
|
const [businessOrderIds, setBusinessOrderIds] = useState([])
|
|
25
25
|
const [ordersLength, setOrdersLength] = useState({
|
|
26
|
-
activeOrdersLength:
|
|
26
|
+
activeOrdersLength: null,
|
|
27
27
|
previousOrdersLength: 0,
|
|
28
28
|
});
|
|
29
29
|
const [selectedOption, setSelectedOption] = useState(!hideOrders ? 'orders' : 'business')
|
|
@@ -143,7 +143,7 @@ export const MyOrders = (props: any) => {
|
|
|
143
143
|
)}
|
|
144
144
|
{selectedOption === 'orders' && (
|
|
145
145
|
<>
|
|
146
|
-
{ordersLength?.activeOrdersLength
|
|
146
|
+
{ordersLength?.activeOrdersLength !== 0 && (
|
|
147
147
|
<View style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
|
|
148
148
|
<OrdersOption
|
|
149
149
|
{...props}
|
|
@@ -192,14 +192,14 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
192
192
|
useEffect(() => {
|
|
193
193
|
if (loading) return
|
|
194
194
|
|
|
195
|
-
const updateOrders =
|
|
195
|
+
const updateOrders = _orders.filter((order: any) => orderStatus.includes(order.status))
|
|
196
196
|
|
|
197
197
|
if (activeOrders) {
|
|
198
198
|
setOrdersLength && setOrdersLength({ ...ordersLength, activeOrdersLength: updateOrders?.length })
|
|
199
199
|
} else if (!preOrders) {
|
|
200
200
|
setOrdersLength && setOrdersLength({ ...ordersLength, previousOrdersLength: updateOrders?.length })
|
|
201
201
|
}
|
|
202
|
-
}, [
|
|
202
|
+
}, [_orders, activeOrders, preOrders])
|
|
203
203
|
|
|
204
204
|
useEffect(() => {
|
|
205
205
|
if (refreshOrders) {
|
|
@@ -251,6 +251,7 @@ export interface BusinessProductsListingParams {
|
|
|
251
251
|
handleChangeProfessionalSelected?: any;
|
|
252
252
|
handleUpdateProfessionals?: any;
|
|
253
253
|
onBusinessClick?: any;
|
|
254
|
+
onNavigationRedirect?: any;
|
|
254
255
|
}
|
|
255
256
|
export interface BusinessBasicInformationParams {
|
|
256
257
|
navigation?: any;
|
|
@@ -533,7 +534,6 @@ export interface FloatingButtonParams {
|
|
|
533
534
|
handleClick?: any;
|
|
534
535
|
handleEmpty?: any;
|
|
535
536
|
iosBottom?: number
|
|
536
|
-
hideButton?: boolean
|
|
537
537
|
}
|
|
538
538
|
export interface MomentOptionParams {
|
|
539
539
|
navigation: any;
|