ordering-ui-react-native 0.17.6-release → 0.17.7-release
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
CHANGED
|
@@ -7,6 +7,7 @@ import { CCContainer, CCNotCarts, CCList, CheckoutAction, ChCartsTotal } from '.
|
|
|
7
7
|
import { Cart } from '../Cart';
|
|
8
8
|
import { OButton, OText } from '../shared';
|
|
9
9
|
import Spinner from 'react-native-loading-spinner-overlay';
|
|
10
|
+
import { NotFoundSource } from '../NotFoundSource';
|
|
10
11
|
|
|
11
12
|
export const CartContent = (props: any) => {
|
|
12
13
|
const {
|
|
@@ -31,37 +32,37 @@ export const CartContent = (props: any) => {
|
|
|
31
32
|
?.reduce((total: any, cart: any) => { return total + (cart?.delivery_price_with_discount) }, 0)
|
|
32
33
|
|
|
33
34
|
const handleCheckoutRedirect = () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
if (cartsAvailable.length === 1) {
|
|
36
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
37
|
+
screen: 'CheckoutPage',
|
|
38
|
+
cartUuid: cartsAvailable[0]?.uuid,
|
|
39
|
+
businessLogo: cartsAvailable[0]?.business?.logo,
|
|
40
|
+
businessName: cartsAvailable[0]?.business?.name,
|
|
41
|
+
cartTotal: cartsAvailable[0]?.total
|
|
42
|
+
})
|
|
43
|
+
} else {
|
|
44
|
+
const groupKeys: any = {}
|
|
45
|
+
cartsAvailable.forEach((_cart: any) => {
|
|
46
|
+
groupKeys[_cart?.group?.uuid]
|
|
47
|
+
? groupKeys[_cart?.group?.uuid] += 1
|
|
48
|
+
: groupKeys[_cart?.group?.uuid ?? 'null'] = 1
|
|
49
|
+
})
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
if (
|
|
52
|
+
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
53
|
+
Object.keys(groupKeys).length > 1
|
|
54
|
+
) {
|
|
55
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
55
56
|
screen: 'MultiCheckout',
|
|
56
57
|
checkCarts: true
|
|
57
58
|
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
} else {
|
|
60
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
61
|
+
screen: 'MultiCheckout',
|
|
62
|
+
cartUuid: cartsAvailable[0]?.group?.uuid
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
return (
|
|
@@ -71,7 +72,7 @@ export const CartContent = (props: any) => {
|
|
|
71
72
|
{isOrderStateCarts && carts?.length > 0 && (
|
|
72
73
|
<>
|
|
73
74
|
{carts.map((cart: any, i: number) => (
|
|
74
|
-
<CCList key={i} style={{ overflow: 'visible' }}>
|
|
75
|
+
<CCList nestedScrollEnabled={true} key={i} style={{ overflow: 'visible' }}>
|
|
75
76
|
{cart.products.length > 0 && (
|
|
76
77
|
<>
|
|
77
78
|
<Cart
|
|
@@ -145,21 +146,12 @@ export const CartContent = (props: any) => {
|
|
|
145
146
|
)}
|
|
146
147
|
{(!carts || carts?.length === 0) && (
|
|
147
148
|
<CCNotCarts>
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
borderColor={theme.colors.primary}
|
|
155
|
-
textStyle={{
|
|
156
|
-
color: theme.colors.white,
|
|
157
|
-
fontSize: 14,
|
|
158
|
-
paddingRight: 0
|
|
159
|
-
}}
|
|
160
|
-
style={{ height: 35, marginVertical: 20, borderRadius: 8 }}
|
|
161
|
-
imgRightSrc={null}
|
|
162
|
-
onClick={() => onNavigationRedirect('BusinessList')}
|
|
149
|
+
<NotFoundSource
|
|
150
|
+
hideImage
|
|
151
|
+
btnStyle={{ borderRadius: 8 }}
|
|
152
|
+
content={t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
|
|
153
|
+
btnTitle={t('START_SHOPPING', 'Start shopping')}
|
|
154
|
+
onClickButton={() => onNavigationRedirect('BusinessList')}
|
|
163
155
|
/>
|
|
164
156
|
</CCNotCarts>
|
|
165
157
|
)}
|
|
@@ -96,14 +96,13 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
96
96
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
97
97
|
: configs?.driver_tip_options?.value || []
|
|
98
98
|
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const loyalBusinessIds = creditPointPlan?.businesses?.filter((b: any) => b.accumulates).map((item: any) => item.business_id) ?? []
|
|
102
|
-
const creditPointPlanOnBusiness = businessIds.every((bid: any) => loyalBusinessIds.includes(bid)) && creditPointPlan
|
|
99
|
+
const creditPointGeneralPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
|
|
100
|
+
const loyalBusinessAvailable = creditPointGeneralPlan?.businesses?.filter((b: any) => b.accumulates) ?? []
|
|
103
101
|
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
const accumulationRateBusiness = (businessId: number) => {
|
|
103
|
+
const value = loyalBusinessAvailable?.find((loyal: any) => loyal.business_id === businessId)?.accumulation_rate ?? 0
|
|
104
|
+
return value || (creditPointGeneralPlan?.accumulation_rate ?? 0)
|
|
105
|
+
}
|
|
107
106
|
|
|
108
107
|
const getIncludedTaxes = (cart: any) => {
|
|
109
108
|
if (cart?.taxes === null || !cart?.taxes) {
|
|
@@ -115,12 +114,13 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
const
|
|
119
|
-
creditPointPlanOnBusiness?.accumulation_rate
|
|
117
|
+
const clearAmount = (value: any) => parseFloat((Math.trunc(value * 100) / 100).toFixed(configs.format_number_decimal_length?.value ?? 2))
|
|
120
118
|
|
|
121
|
-
const loyaltyRewardValue = (
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
const loyaltyRewardValue = openCarts.reduce((sum: any, cart: any) => sum + clearAmount((cart?.subtotal + getIncludedTaxes(cart)) * accumulationRateBusiness(cart?.business_id)), 0)
|
|
120
|
+
|
|
121
|
+
const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
|
|
122
|
+
const [phoneUpdate, setPhoneUpdate] = useState(false);
|
|
123
|
+
const [userErrors, setUserErrors] = useState<any>([]);
|
|
124
124
|
|
|
125
125
|
const handleMomentClick = () => {
|
|
126
126
|
if (isPreOrder) {
|
|
@@ -405,7 +405,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
405
405
|
</OText>
|
|
406
406
|
<OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
|
|
407
407
|
</View>
|
|
408
|
-
{!!loyaltyRewardValue &&
|
|
408
|
+
{!!loyaltyRewardValue && (
|
|
409
409
|
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'flex-end' }}>
|
|
410
410
|
<OText size={12} color={theme.colors.textNormal}>
|
|
411
411
|
{t('REWARD_LOYALTY_POINT', 'Reward :amount: on loyalty points').replace(':amount:', loyaltyRewardValue)}
|
|
@@ -82,9 +82,8 @@ const OrderSummaryUI = (props: any) => {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
).toFixed(configs.format_number_decimal_length?.value ?? 2), 10)
|
|
85
|
+
const clearAmount = (value: any) => parseFloat((Math.trunc(value * 100) / 100).toFixed(configs.format_number_decimal_length?.value ?? 2))
|
|
86
|
+
const loyaltyRewardValue = clearAmount((cart?.subtotal + getIncludedTaxes()) * loyaltyRewardRate)
|
|
88
87
|
|
|
89
88
|
const handleDeleteClick = (product: any) => {
|
|
90
89
|
removeProduct(product, cart)
|
|
@@ -316,7 +315,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
316
315
|
{parsePrice(cart?.balance >= 0 ? cart?.balance : 0)}
|
|
317
316
|
</OText>
|
|
318
317
|
</OSTable>
|
|
319
|
-
{!!loyaltyRewardValue &&
|
|
318
|
+
{!!loyaltyRewardValue && (
|
|
320
319
|
<OSTable style={{ justifyContent: 'flex-end' }}>
|
|
321
320
|
<OText size={12} color={theme.colors.textNormal}>
|
|
322
321
|
{t('REWARD_LOYALTY_POINT', 'Reward :amount: on loyalty points').replace(':amount:', loyaltyRewardValue)}
|