ordering-ui-react-native 0.18.79 → 0.18.81

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.79",
3
+ "version": "0.18.81",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -312,14 +312,15 @@ const ChatUI = (props: MessagesParams) => {
312
312
  quality: 1
313
313
  },
314
314
  (response: any) => {
315
- if (response.didCancel) {
315
+ const image = response.assets[0];
316
+ if (image.didCancel) {
316
317
  console.log('User cancelled image picker');
317
- } else if (response.errorMessage) {
318
- console.log('ImagePicker Error: ', response.errorMessage);
319
- showToast(ToastType.Error, response.errorMessage);
318
+ } else if (image.errorMessage) {
319
+ console.log('ImagePicker Error: ', image.errorMessage);
320
+ showToast(ToastType.Error, image.errorMessage);
320
321
  } else {
321
- if (response.uri) {
322
- const url = `data:${response.type};base64,${response.base64}`;
322
+ if (image.uri) {
323
+ const url = `data:${image.type};base64,${image.base64}`;
323
324
  setImage && setImage(url);
324
325
  } else {
325
326
  showToast(ToastType.Error, t('IMAGE_NOT_FOUND', 'Image not found'));
@@ -48,6 +48,7 @@ const NewOrderNotificationUI = (props: any) => {
48
48
  const notificationSound = new Sound(theme.sounds.notification, '', () => { });
49
49
 
50
50
  let _timeout: any = null
51
+ let times = 0
51
52
 
52
53
  const handleCloseEvents = () => {
53
54
  notificationSound.stop()
@@ -57,14 +58,19 @@ const NewOrderNotificationUI = (props: any) => {
57
58
 
58
59
  const handlePlayNotificationSound = (eventObj: any = null) => {
59
60
  setCurrentEvent(eventObj)
60
- let times = 1
61
+ if (times > 0) {
62
+ if (times === 3) {
63
+ times = 0
64
+ return
65
+ }
66
+ return
67
+ }
61
68
  _timeout = setInterval(() => {
62
- if (times <= SOUND_LOOP) {
69
+ if (times < SOUND_LOOP) {
63
70
  notificationSound.play()
64
71
  times++
65
72
  } else {
66
73
  clearInterval(_timeout)
67
- times = 1
68
74
  return
69
75
  }
70
76
  }, 2500)
@@ -89,10 +95,10 @@ const NewOrderNotificationUI = (props: any) => {
89
95
  }
90
96
  }
91
97
  if (evtType === 3 || value.author_id === user.id) return
92
- handlePlayNotificationSound({
98
+ setTimeout(() => handlePlayNotificationSound({
93
99
  evt: evtType,
94
100
  orderId: value?.driver ? value?.order_id : evtList[evtType].event === 'messages' ? value?.order?.id : value?.id
95
- })
101
+ }), 1000)
96
102
  }
97
103
 
98
104
  useEffect(() => {
@@ -611,11 +611,11 @@ export const OrderContentComponent = (props: OrderContent) => {
611
611
  ? walletName[event?.wallet_event?.wallet?.type]?.name
612
612
  : t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)}
613
613
  </OText>
614
- {event?.data?.charge_id && (
614
+ {/* {event?.data?.charge_id && (
615
615
  <OText>
616
616
  {`${t('CODE', 'Code')}: ${event?.data?.charge_id}`}
617
617
  </OText>
618
- )}
618
+ )} */}
619
619
  </View>
620
620
  <OText>
621
621
  {(event?.paymethod?.gateway === 'cash' && order?.cash)
@@ -3,6 +3,8 @@ import {
3
3
  useLanguage,
4
4
  useConfig,
5
5
  useUtils,
6
+ useToast,
7
+ ToastType,
6
8
  MultiCartsPaymethodsAndWallets as MultiCartsPaymethodsAndWalletsController
7
9
  } from 'ordering-components/native'
8
10
  import { useTheme } from 'styled-components/native'
@@ -45,7 +47,8 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
45
47
  const [, t] = useLanguage()
46
48
  const [{ configs }] = useConfig()
47
49
  const [{ parsePrice }] = useUtils()
48
- const { confirmApplePayPayment } = useApplePay()
50
+ const [, { showToast }] = useToast();
51
+ const { confirmApplePayPayment } = useApplePay()
49
52
 
50
53
  const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
51
54
 
@@ -91,20 +94,38 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
91
94
  }
92
95
 
93
96
  useEffect(() => {
94
- if (methodsPay.includes(paymethodSelected?.gateway)) {
95
- if (typeof paymethodSelected?.paymethod_data === 'string'){
96
- const sourceId = JSON.parse(paymethodSelected?.paymethod_data)?.source_id
97
+ if (methodsPay.includes(paymethodSelected?.gateway)) {
98
+ if (typeof paymethodSelected?.paymethod_data === 'string') {
99
+ const sourceId = JSON.parse(paymethodSelected?.paymethod_data)?.source_id
97
100
  sourceId && handlePlaceOrder(confirmApplePayPayment)
98
101
  }
99
- }
100
- }, [JSON.stringify(paymethodSelected)])
102
+ }
103
+ }, [JSON.stringify(paymethodSelected)])
104
+
105
+ useEffect(() => {
106
+ if (cartTotal === 0) {
107
+ handlePaymethodDataChange(null)
108
+ handleSelectPaymethod(null)
109
+ }
110
+ }, [cartTotal])
111
+
112
+ const handleChangePaymethod = (paymethod: any) => {
113
+ if (cartTotal > 0) {
114
+ handleSelectPaymethod(paymethod)
115
+ return
116
+ }
117
+ showToast(
118
+ ToastType.Error,
119
+ t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
120
+ ;
121
+ }
101
122
 
102
123
  const renderPaymethods = ({ item }: any) => {
103
124
  return (
104
125
  <>
105
126
  {item?.gateway === 'global_apple_pay' ? (
106
127
  <TouchableOpacity
107
- onPress={() => handleSelectPaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
128
+ onPress={() => handleChangePaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
108
129
  >
109
130
  <OIcon
110
131
  src={getPayIcon(item.gateway)}
@@ -115,7 +136,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
115
136
  </TouchableOpacity>
116
137
  ) : (
117
138
  <TouchableOpacity
118
- onPress={() => handleSelectPaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
139
+ onPress={() => handleChangePaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
119
140
  >
120
141
  <PMItem
121
142
  key={item.id}
@@ -208,9 +229,9 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
208
229
  handleSource={handlePaymethodDataChange}
209
230
  onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
210
231
  setMethodPaySupported={setMethodPaySupported}
211
- methodPaySupported={methodPaySupported}
212
- placeByMethodPay={placeByMethodPay}
213
- setPlaceByMethodPay={setPlaceByMethodPay}
232
+ methodPaySupported={methodPaySupported}
233
+ placeByMethodPay={placeByMethodPay}
234
+ setPlaceByMethodPay={setPlaceByMethodPay}
214
235
  methodsPay={methodsPay}
215
236
  paymethod={paymethodSelected?.paymethod?.gateway}
216
237
  cartTotal={cartTotal}
@@ -1018,7 +1018,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1018
1018
  )} */}
1019
1019
  </View>
1020
1020
  <OText>
1021
- -{parsePrice(event.amount, { isTruncable: true })}
1021
+ {configs.currency_position?.value === 'left'
1022
+ ? `${configs.format_number_currency?.value} -${parseNumber(event.amount, { isTruncable: true })}`
1023
+ : `-${parsePrice(event.amount, { isTruncable: true })}`}
1022
1024
  </OText>
1023
1025
  </View>
1024
1026
  ))}
@@ -126,6 +126,12 @@ const PaymentOptionsUI = (props: any) => {
126
126
  ;
127
127
  }
128
128
 
129
+ useEffect(() => {
130
+ if (cart?.balance === 0) {
131
+ handlePaymethodClick(null)
132
+ }
133
+ }, [cart?.balance])
134
+
129
135
  useEffect(() => {
130
136
  if (paymethodsList.paymethods.length === 1) {
131
137
  handlePaymethodClick && handlePaymethodClick(paymethodsList.paymethods[0])
@@ -339,7 +345,7 @@ const PaymentOptionsUI = (props: any) => {
339
345
  onPaymentChange={onPaymentChange}
340
346
  payType={isOpenMethod?.paymethod?.name}
341
347
  onSelectCard={handlePaymethodDataChange}
342
- addCardOpen={addCardOpen}
348
+ addCardOpen={addCardOpen}
343
349
  setAddCardOpen={setAddCardOpen}
344
350
  onCancel={() => handlePaymethodClick(null)}
345
351
  paymethodSelected={paymethodSelected?.data?.id}