ordering-ui-react-native 0.21.79 → 0.21.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.21.79",
3
+ "version": "0.21.81",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -16,7 +16,8 @@ import {
16
16
  useApi,
17
17
  useEvent,
18
18
  useLanguage,
19
- useSession
19
+ useSession,
20
+ useConfig
20
21
  } from 'ordering-components/native'
21
22
 
22
23
  import { OIcon, OText } from '../shared'
@@ -95,9 +96,14 @@ const NewOrderNotificationUI = (props: any) => {
95
96
  const [events] = useEvent()
96
97
  const [{ user, token }] = useSession()
97
98
  const [ordering] = useApi()
99
+ const [{ configs }] = useConfig()
98
100
  const { getCurrentLocation } = useLocation()
99
101
  const [currentEvent, setCurrentEvent] = useState<any>(null)
100
102
 
103
+ const orderStatus = !!isBusinessApp
104
+ ? configs?.notification_business_states?.value.split('|').map((value: any) => Number(value)) || []
105
+ : configs?.notification_driver_states?.value.split('|').map((value: any) => Number(value)) || []
106
+
101
107
  const handleEventNotification = async (evtType: number, value: any) => {
102
108
  if (value?.driver) {
103
109
  try {
@@ -105,18 +111,26 @@ const NewOrderNotificationUI = (props: any) => {
105
111
  await fetch(`${ordering.root}/users/${user.id}/locations`, {
106
112
  method: 'POST',
107
113
  body: JSON.stringify({
108
- location: JSON.stringify({ location: `{lat: ${location.latitude}, lng: ${location.longitude}}` })
114
+ location: JSON.stringify({
115
+ location: `{
116
+ lat: ${location.latitude},
117
+ lng: ${location.longitude}
118
+ }`
119
+ })
109
120
  }),
110
- headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
121
+ headers: {
122
+ 'Content-Type': 'application/json',
123
+ Authorization: `Bearer ${token}`
124
+ }
111
125
  })
112
126
  } catch { }
113
127
  const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
114
128
  const assignedSecondsDiff = duration.asSeconds()
115
- if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
129
+ if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status && orderStatus.includes(value.status)) {
116
130
  setCurrentEvent({ evt: 2, orderId: value?.id ?? value?.order_id })
117
131
  }
118
132
  }
119
- if ((evtType === 3 && (value.status !== 8 || !value?.driver) && !value.uuid) || value?.author_id === user.id) return
133
+ if (!orderStatus.includes(value.status) || value?.author_id === user.id) return
120
134
  setCurrentEvent({
121
135
  evt: evtType,
122
136
  orderId: value?.driver
@@ -50,6 +50,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
50
50
  const theme = useTheme();
51
51
  const [, t] = useLanguage();
52
52
  const [{ parseDate }] = useUtils();
53
+ const paymethodsLength = order?.payment_events?.filter((item: any) => item.event === 'payment')?.length
53
54
 
54
55
  const styles = StyleSheet.create({
55
56
  icons: {
@@ -120,6 +121,15 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
120
121
  ? t('CURBSIDE', 'Curbside')
121
122
  : t('DRIVER_THRU', 'Driver thru')
122
123
 
124
+ const handlePaymethodsListString = () => {
125
+ const paymethodsList = order?.payment_events?.filter((item: any) => item.event === 'payment').map((paymethod: any) => {
126
+ return paymethod?.wallet_event
127
+ ? walletName[paymethod?.wallet_event?.wallet?.type]?.name
128
+ : t(paymethod?.paymethod?.gateway?.toUpperCase(), paymethod?.paymethod?.name)
129
+ })
130
+ return paymethodsList.join(', ')
131
+ }
132
+
123
133
  return (
124
134
  <>
125
135
  {!props.isCustomView && (
@@ -283,20 +293,10 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
283
293
  )}
284
294
  <OText>
285
295
  <OText size={13} weight='bold'>
286
- {`${t('PAYMENT_METHODS', 'Payment methods')}: `}
296
+ {`${t(paymethodsLength > 1 ? 'PAYMENT_METHODS' : 'PAYMENT_METHOD', paymethodsLength > 1 ? 'Payment methods' : 'Payment method')}: `}
287
297
  </OText>
288
298
  {order?.payment_events?.length > 0 ? (
289
- <OText size={13}>
290
- {order?.payment_events?.map((event: any, idx: number) => {
291
- return event?.wallet_event
292
- ? idx < order?.payment_events?.length - 1
293
- ? `${walletName[event?.wallet_event?.wallet?.type]?.name} - `
294
- : walletName[event?.wallet_event?.wallet?.type]?.name
295
- : idx < order?.payment_events?.length - 1
296
- ? `${t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)} - `
297
- : t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)
298
- })}
299
- </OText>
299
+ <OText size={13}>{`${handlePaymethodsListString()}`}</OText>
300
300
  ) : (
301
301
  <OText size={13}>{t(order?.paymethod?.gateway?.toUpperCase(), order?.paymethod?.name)}</OText>
302
302
  )}