ordering-ui-react-native 0.18.25 → 0.18.27

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.18.25",
3
+ "version": "0.18.27",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -191,7 +191,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
191
191
  setCanOpenUpselling(false)
192
192
  const cartsAvailable: any = Object.values(orderState?.carts)
193
193
  ?.filter((_cart: any) => _cart?.valid && _cart?.status !== 2 && _cart?.products?.length)
194
- ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== cart.uuid : _c)
194
+ ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== cart?.uuid : _c)
195
195
  if (cartsAvailable.length === 1 || !isCheckoutMultiBusinessEnabled) {
196
196
  const cart = isCheckoutMultiBusinessEnabled ? cartsAvailable[0] : currentCart
197
197
 
@@ -74,6 +74,7 @@ const CartUI = (props: any) => {
74
74
  const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
75
75
  const businessId = business?.business_id ?? null
76
76
  const placeSpotTypes = [4]
77
+ const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
77
78
  const hideCartComments = theme?.business_view?.components?.cart?.components?.comments?.hidden
78
79
  const hideCartDiscount = theme?.business_view?.components?.cart?.components?.discount?.hidden
79
80
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
@@ -116,7 +117,7 @@ const CartUI = (props: any) => {
116
117
 
117
118
  const cartsAvailable: any = Object.values(orderState?.carts)
118
119
  ?.filter((_cart: any) => _cart?.valid && _cart?.status !== 2 && _cart?.products?.length)
119
- ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== cart.uuid : _c)
120
+ ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== individualCart?.uuid : _c)
120
121
  if (cartsAvailable.length === 1 || !isMultiCheckout) {
121
122
  const cart = isMultiCheckout ? cartsAvailable[0] : individualCart
122
123
  onNavigationRedirect('CheckoutNavigator', {
@@ -383,7 +384,7 @@ const CartUI = (props: any) => {
383
384
  </OSTable>
384
385
  ))
385
386
  }
386
- {orderState?.options?.type === 1 && cart?.delivery_price > 0 && cart?.delivery_price_with_discount >= 0 && !hideDeliveryFee && (
387
+ {orderState?.options?.type === 1 && cart?.delivery_price > 0 && cart?.delivery_price_with_discount >= 0 && !hideDeliveryFee && isChewLayout && (
387
388
  <OSTable>
388
389
  <OText size={12} lineHeight={18}>{t('DELIVERY_FEE_AFTER_DISCOUNT', 'Delivery Fee After Discount')}</OText>
389
390
  <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price_with_discount)}</OText>
@@ -166,6 +166,9 @@ const CheckoutUI = (props: any) => {
166
166
  const hideBusinessMap = theme?.checkout?.components?.business?.components?.map?.hidden
167
167
  const hideCustomerDetails = theme?.checkout?.components?.customer?.hidden
168
168
 
169
+ const creditPointPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
170
+ const creditPointPlanOnBusiness = creditPointPlan?.businesses?.find((b: any) => b.business_id === cart?.business_id && b.accumulates)
171
+
169
172
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
170
173
  const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
171
174
  if (item?.type === 1)
@@ -729,7 +732,10 @@ const CheckoutUI = (props: any) => {
729
732
  placeSpotTypes={placeSpotTypes}
730
733
  businessConfigs={businessConfigs}
731
734
  maxDate={maxDate}
732
- loyaltyRewardRate={loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')?.accumulation_rate ?? 0}
735
+ loyaltyRewardRate={
736
+ creditPointPlanOnBusiness?.accumulation_rate ??
737
+ (!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
738
+ }
733
739
  />
734
740
  </>
735
741
  )}
@@ -739,7 +745,7 @@ const CheckoutUI = (props: any) => {
739
745
 
740
746
  {!cartState.loading && cart && (
741
747
  <View>
742
- <ChErrors style={{ marginBottom: 10 }}>
748
+ <ChErrors style={{ marginBottom: 30 }}>
743
749
  {!cart?.valid_address && cart?.status !== 2 && (
744
750
  <OText
745
751
  color={theme.colors.error}
@@ -766,7 +772,7 @@ const CheckoutUI = (props: any) => {
766
772
  {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
767
773
  </OText>
768
774
  )}
769
- {!cart?.valid_preorder && (
775
+ {cart?.valid_preorder !== undefined && !cart?.valid_preorder && (
770
776
  <OText
771
777
  color={theme.colors.error}
772
778
  size={12}
@@ -60,7 +60,7 @@ const MultiCheckoutUI = (props: any) => {
60
60
  handleSelectWallet,
61
61
  handlePaymethodDataChange,
62
62
  cartUuid,
63
- rewardRate,
63
+ loyaltyPlansState,
64
64
  totalCartsFee,
65
65
  cartGroup,
66
66
  onNavigationRedirectReplace
@@ -92,7 +92,13 @@ const MultiCheckoutUI = (props: any) => {
92
92
  ? JSON.parse(configs?.driver_tip_options?.value) || []
93
93
  : configs?.driver_tip_options?.value || []
94
94
 
95
- const loyaltyRewardValue = Math.round(openCarts.reduce((sum: any, cart: any) => sum + cart?.subtotal, 0) / rewardRate)
95
+ const creditPointPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
96
+ const businessIds = openCarts.map((cart: any) => cart.business_id)
97
+ const loyalBusinessIds = creditPointPlan?.businesses?.filter((b: any) => b.accumulates).map((item: any) => item.business_id)
98
+ const creditPointPlanOnBusiness = businessIds.every((bid: any) => loyalBusinessIds.includes(bid)) && creditPointPlan
99
+
100
+ const loyaltyRewardValue = creditPointPlanOnBusiness?.accumulation_rate
101
+ ? Math.round(openCarts.reduce((sum: any, cart: any) => sum + cart?.subtotal, 0) / creditPointPlanOnBusiness?.accumulation_rate) : 0
96
102
 
97
103
  const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
98
104
  const [phoneUpdate, setPhoneUpdate] = useState(false);