ordering-ui-react-native 0.18.44 → 0.18.46

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.44",
3
+ "version": "0.18.46",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -58,14 +58,16 @@ const NewOrderNotificationUI = (props: any) => {
58
58
  const handlePlayNotificationSound = (eventObj: any = null) => {
59
59
  setCurrentEvent(eventObj)
60
60
  let times = 1
61
- if (times < SOUND_LOOP) {
62
- _timeout = setInterval(() => {
63
- notificationSound.play(success => success && (times = times + 1))
64
- if (times === SOUND_LOOP) {
65
- clearInterval(_timeout)
66
- }
67
- }, 2500)
68
- }
61
+ _timeout = setInterval(() => {
62
+ if (times <= SOUND_LOOP) {
63
+ notificationSound.play()
64
+ times++
65
+ } else {
66
+ clearInterval(_timeout)
67
+ times = 1
68
+ return
69
+ }
70
+ }, 2500)
69
71
  }
70
72
 
71
73
  const handleEventNotification = async (evtType: number, value: any) => {
@@ -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)}
@@ -12,7 +12,7 @@ export const OrderEta = (props: any) => {
12
12
  const [estimatedDeliveryTime, setEstimatedDeliveryTime] = useState(null)
13
13
 
14
14
  const getEstimatedDeliveryTime = () => {
15
- let _estimatedTime
15
+ let _estimatedTime = null
16
16
  let totalEta = 0
17
17
  const _delivery = order?.delivery_datetime_utc
18
18
  ? order?.delivery_datetime_utc
@@ -40,7 +40,8 @@ export const OrderEta = (props: any) => {
40
40
  } else {
41
41
  _estimatedTime = moment.utc(_delivery).add(order?.eta_time, 'minutes')
42
42
  }
43
- _estimatedTime = outputFormat ? moment(_estimatedTime).format(outputFormat) : parseDate(_estimatedTime, { utc: false })
43
+ if (order?.delivered_in) { _estimatedTime = moment.utc(_delivery).add(order?.delivered_in, 'minutes')}
44
+ _estimatedTime = outputFormat ? moment(_estimatedTime).local().format(outputFormat) : parseDate(_estimatedTime, { utc: false })
44
45
  setEstimatedDeliveryTime(_estimatedTime)
45
46
  }
46
47
 
@@ -83,9 +83,8 @@ const OrderSummaryUI = (props: any) => {
83
83
  }
84
84
  }
85
85
 
86
- const loyaltyRewardValue = ((
87
- Math.trunc(((cart?.subtotal + getIncludedTaxes()) * loyaltyRewardRate) * 100) / 100
88
- ).toFixed(configs.format_number_decimal_length?.value ?? 2), 10)
86
+ const clearAmount = (value: any) => parseFloat((Math.trunc(value * 100) / 100).toFixed(configs.format_number_decimal_length?.value ?? 2))
87
+ const loyaltyRewardValue = clearAmount((cart?.subtotal + getIncludedTaxes()) * loyaltyRewardRate)
89
88
 
90
89
  const handleDeleteClick = (product: any) => {
91
90
  removeProduct(product, cart)
@@ -317,7 +316,7 @@ const OrderSummaryUI = (props: any) => {
317
316
  {parsePrice(cart?.balance >= 0 ? cart?.balance : 0)}
318
317
  </OText>
319
318
  </OSTable>
320
- {!!loyaltyRewardValue && isFinite(loyaltyRewardValue) && (
319
+ {!!loyaltyRewardValue && (
321
320
  <OSTable style={{ justifyContent: 'flex-end' }}>
322
321
  <OText size={12} color={theme.colors.textNormal}>
323
322
  {t('REWARD_LOYALTY_POINT', 'Reward :amount: on loyalty points').replace(':amount:', loyaltyRewardValue)}
@@ -67,7 +67,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
67
67
 
68
68
  return (
69
69
  <View>
70
- <Container onPress={() => handleSuboptionClick()}>
70
+ <Container onPress={!(option?.with_half_option || option?.allow_suboption_quantity) ? () => handleSuboptionClick() : null}>
71
71
  <IconControl disabled={disabled} onPress={() => handleSuboptionClick()}>
72
72
  {((option?.min === 0 && option?.max === 1) || option?.max > 1) ? (
73
73
  state?.selected ? (
@@ -393,7 +393,7 @@ const SignupFormUI = (props: SignupParams) => {
393
393
  vibrateApp()
394
394
  return
395
395
  }
396
- formState.result?.result && showToast(ToastType.Error, formState.result?.result[0]);
396
+ formState.result?.result && showToast(ToastType.Error, t(`${formState.result?.result[0]}`, 'Phone number already used'));
397
397
  formState.result?.result && vibrateApp()
398
398
  setIsLoadingVerifyModal(false);
399
399
  }
@@ -39,7 +39,7 @@ const StripeCardsListUI = (props: any) => {
39
39
  }
40
40
 
41
41
  useEffect(() => {
42
- if (!cardsList?.loading && cardsList?.cards?.length === 0) {
42
+ if (!cardsList && !cardsList?.loading && cardsList?.cards?.length === 0) {
43
43
  setAddCardOpen(true)
44
44
  }
45
45
  }, [cardsList?.loading])