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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.17.6-release",
3
+ "version": "0.17.7-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -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
- if (cartsAvailable.length === 1) {
35
- onNavigationRedirect('CheckoutNavigator', {
36
- screen: 'CheckoutPage',
37
- cartUuid: cartsAvailable[0]?.uuid,
38
- businessLogo: cartsAvailable[0]?.business?.logo,
39
- businessName: cartsAvailable[0]?.business?.name,
40
- cartTotal: cartsAvailable[0]?.total
41
- })
42
- } else {
43
- const groupKeys: any = {}
44
- cartsAvailable.forEach((_cart: any) => {
45
- groupKeys[_cart?.group?.uuid]
46
- ? groupKeys[_cart?.group?.uuid] += 1
47
- : groupKeys[_cart?.group?.uuid ?? 'null'] = 1
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
- if (
51
- (Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
52
- Object.keys(groupKeys).length > 1
53
- ) {
54
- onNavigationRedirect('CheckoutNavigator', {
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
- } else {
59
- onNavigationRedirect('CheckoutNavigator', {
60
- screen: 'MultiCheckout',
61
- cartUuid: cartsAvailable[0]?.group?.uuid
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
- <OText size={24} style={{ textAlign: 'center' }}>
149
- {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
150
- </OText>
151
- <OButton
152
- text={t('START_SHOPPING', 'Start shopping')}
153
- bgColor={theme.colors.primary}
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 creditPointPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
100
- const businessIds = openCarts.map((cart: any) => cart.business_id)
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 [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
105
- const [phoneUpdate, setPhoneUpdate] = useState(false);
106
- const [userErrors, setUserErrors] = useState<any>([]);
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 subtotalAmount = openCarts.reduce((sum: any, cart: any) => sum + (cart?.subtotal + getIncludedTaxes(cart)), 0) *
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 = (creditPointPlanOnBusiness?.accumulation_rate
122
- ? (Math.trunc(subtotalAmount * 100) / 100).toFixed(configs.format_number_decimal_length?.value ?? 2)
123
- : 0)
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 && isFinite(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 loyaltyRewardValue = ((
86
- Math.trunc(((cart?.subtotal + getIncludedTaxes()) * loyaltyRewardRate) * 100) / 100
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 && isFinite(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)}