ordering-ui-react-native 0.21.51 → 0.21.52

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.51",
3
+ "version": "0.21.52",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { StyleSheet, View, ActivityIndicator } from 'react-native';
2
+ import { StyleSheet, View, ActivityIndicator, TouchableOpacity } from 'react-native';
3
3
  import ToggleSwitch from 'toggle-switch-react-native';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import {
@@ -14,7 +14,7 @@ import { OIcon, OText } from '../shared';
14
14
  import { BusinessControllerParams } from '../../types';
15
15
 
16
16
  export const BusinessControllerUI = (props: BusinessControllerParams) => {
17
- const { businessState, updateBusiness, isUpdateStore, setIsUpdateStore } =
17
+ const { businessState, updateBusiness, isUpdateStore, setIsUpdateStore, navigation } =
18
18
  props;
19
19
 
20
20
  const { loading, business, error } = businessState;
@@ -93,21 +93,18 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
93
93
  <>
94
94
  {business && (
95
95
  <Card key={business?.id}>
96
- <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
97
- <Logo style={styles.logo}>
98
- <OIcon
99
- url={optimizeImage(business?.logo, 'h_300,c_limit')}
100
- src={!business?.logo && theme?.images?.dummies?.businessLogo}
101
- style={styles.icon}
102
- />
103
- </Logo>
104
-
105
- <View
106
- style={{
107
- flex: 1,
108
- flexDirection: 'row',
109
- alignItems: 'flex-start',
110
- }}>
96
+ <View style={{ flexDirection: 'row', flex: 1 }}>
97
+ <TouchableOpacity
98
+ style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}
99
+ onPress={() => navigation && business?.slug && navigation.navigate('BusinessProductListing', { slug: business?.slug })}
100
+ >
101
+ <Logo style={styles.logo}>
102
+ <OIcon
103
+ url={optimizeImage(business?.logo, 'h_300,c_limit')}
104
+ src={!business?.logo && theme?.images?.dummies?.businessLogo}
105
+ style={styles.icon}
106
+ />
107
+ </Logo>
111
108
  <Information>
112
109
  <View style={styles.header}>
113
110
  <OText style={styles.title} numberOfLines={1}>
@@ -123,7 +120,12 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
123
120
  {business?.zipcode}
124
121
  </OText>
125
122
  </Information>
123
+ </TouchableOpacity>
126
124
 
125
+ <View
126
+ style={{
127
+ alignItems: 'flex-start',
128
+ }}>
127
129
  {loading && isUpdateStore ? (
128
130
  <ActivityIndicator size="small" color={theme.colors.primary} />
129
131
  ) : (
@@ -99,27 +99,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
99
99
  const [slaSettingTime, setSlaSettingTime] = useState(6000)
100
100
  const [currentDeliveryType, setCurrentDeliveryType] = useState('Delivery')
101
101
  const [search, setSearch] = useState(defaultSearchList)
102
- const [selectedTabStatus, setSelectedTabStatus] = useState<any>([])
103
- const [openedSelect, setOpenedSelect] = useState('')
104
-
105
- const HEIGHT_SCREEN = orientationState?.dimensions?.height
106
- const IS_PORTRAIT = orientationState.orientation === PORTRAIT
107
-
108
- const preorderTypeList = [
109
- { key: null, name: t('SLA', 'SLA\'s') },
110
- { key: 'in_time', name: t('OK', 'Ok') },
111
- { key: 'at_risk', name: t('AT_RISK', 'At Risk') },
112
- { key: 'delayed', name: t('DELAYED', 'Delayed') }
113
- ]
114
-
115
- const defaultOrderTypes = [
116
- { key: 1, name: t('DELIVERY', 'Delivery') },
117
- { key: 2, name: t('PICKUP', 'Pickup') },
118
- { key: 3, name: t('EAT_IN', 'Eat in') },
119
- { key: 4, name: t('CURBSIDE', 'Curbside') },
120
- { key: 5, name: t('DRIVE_THRU', 'Drive thru') }
121
- ]
122
-
123
102
  const deliveryStatus = [
124
103
  {
125
104
  key: t('OK', 'Ok'),
@@ -143,6 +122,26 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
143
122
  backColor: '#E63757'
144
123
  }
145
124
  ]
125
+ const [selectedTabStatus, setSelectedTabStatus] = useState<any>(deliveryStatus)
126
+ const [openedSelect, setOpenedSelect] = useState('')
127
+
128
+ const HEIGHT_SCREEN = orientationState?.dimensions?.height
129
+ const IS_PORTRAIT = orientationState.orientation === PORTRAIT
130
+
131
+ const preorderTypeList = [
132
+ { key: null, name: t('SLA', 'SLA\'s') },
133
+ { key: 'in_time', name: t('OK', 'Ok') },
134
+ { key: 'at_risk', name: t('AT_RISK', 'At Risk') },
135
+ { key: 'delayed', name: t('DELAYED', 'Delayed') }
136
+ ]
137
+
138
+ const defaultOrderTypes = [
139
+ { key: 1, name: t('DELIVERY', 'Delivery') },
140
+ { key: 2, name: t('PICKUP', 'Pickup') },
141
+ { key: 3, name: t('EAT_IN', 'Eat in') },
142
+ { key: 4, name: t('CURBSIDE', 'Curbside') },
143
+ { key: 5, name: t('DRIVE_THRU', 'Drive thru') }
144
+ ]
146
145
 
147
146
  const styles = StyleSheet.create({
148
147
  header: {
@@ -384,10 +383,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
384
383
  setTags({ values: [] })
385
384
  }, [currentTabSelected])
386
385
 
387
- useEffect(() => {
388
- setSelectedTabStatus(deliveryStatus)
389
- }, [])
390
-
391
386
  return (
392
387
  <>
393
388
  <View style={styles.header}>
@@ -100,12 +100,13 @@ export const OrderItem = React.memo((props: any) => {
100
100
  });
101
101
 
102
102
  const getDelayMinutes = (order: any) => {
103
- const cdtToutc = moment(order?.delivery_datetime).utc().format('YYYY-MM-DD HH:mm:ss')
103
+ const offset = 300
104
+ const cdtToutc = moment(order?.delivery_datetime).add(offset, 'minutes').format('YYYY-MM-DD HH:mm:ss')
104
105
  const _delivery = order?.delivery_datetime_utc
105
- ? parseDate(order?.delivery_datetime_utc)
106
+ ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD HH:mm:ss' })
106
107
  : parseDate(cdtToutc)
107
108
  const _eta = order?.eta_time
108
- const diffTimeAsSeconds = moment(_delivery, 'YYYY-MM-DD hh:mm A').add(_eta, 'minutes').diff(moment().utc(), 'seconds')
109
+ const diffTimeAsSeconds = moment(_delivery).add(_eta, 'minutes').diff(moment().utc(), 'seconds')
109
110
  return Math.ceil(diffTimeAsSeconds / 60)
110
111
  }
111
112
 
@@ -127,12 +128,6 @@ export const OrderItem = React.memo((props: any) => {
127
128
  return finalTaget
128
129
  }
129
130
 
130
- const getStatusClassName = (minutes: number) => {
131
- if (isNaN(Number(minutes))) return 'in_time'
132
- const delayTime = configState?.configs?.order_deadlines_delayed_time?.value
133
- return minutes > 0 ? 'in_time' : Math.abs(minutes) <= delayTime ? 'at_risk' : 'delayed'
134
- }
135
-
136
131
  useEffect(() => {
137
132
  const slaSettings = configState?.configs?.order_deadlines_enabled?.value === '1'
138
133
  setAllowColumns({
@@ -152,15 +147,7 @@ export const OrderItem = React.memo((props: any) => {
152
147
  <Card key={order.id}>
153
148
  {!!allowColumns?.slaBar && (
154
149
  <Timestatus
155
- style={{
156
- backgroundColor: getStatusClassName(getDelayMinutes(order)) === 'in_time'
157
- ? '#00D27A'
158
- : getStatusClassName(getDelayMinutes(order)) === 'at_risk'
159
- ? '#FFC700'
160
- : getStatusClassName(getDelayMinutes(order)) === 'delayed'
161
- ? '#E63757'
162
- : ''
163
- }}
150
+ timeState={order?.time_status}
164
151
  />
165
152
  )}
166
153
  <Logo style={styles.logo}>
@@ -214,11 +201,11 @@ export const OrderItem = React.memo((props: any) => {
214
201
  <OText
215
202
  style={styles.date}
216
203
  color={
217
- getStatusClassName(getDelayMinutes(order)) === 'in_time'
204
+ order?.time_status === 'in_time'
218
205
  ? '#00D27A'
219
- : getStatusClassName(getDelayMinutes(order)) === 'at_risk'
206
+ : order?.time_status === 'at_risk'
220
207
  ? '#FFC700'
221
- : getStatusClassName(getDelayMinutes(order)) === 'delayed'
208
+ : order?.time_status === 'delayed'
222
209
  ? '#E63757'
223
210
  : ''}
224
211
  >
@@ -8,7 +8,7 @@ import { AcceptOrRejectOrder as AcceptOrRejectOrderStyle } from './styles';
8
8
 
9
9
  function OrderListPropsAreEqual(prevProps: any, nextProps: any) {
10
10
  return JSON.stringify(prevProps.order) === JSON.stringify(nextProps.order) &&
11
- JSON.stringify(prevProps._order) === JSON.stringify(nextProps._order) &&
11
+ JSON.stringify(prevProps._order) === JSON.stringify(nextProps._order) &&
12
12
  JSON.stringify(prevProps.currentOrdenSelected) === JSON.stringify(nextProps.currentOrdenSelected) &&
13
13
  prevProps.currentTabSelected === nextProps.currentTabSelected
14
14
  }
@@ -180,6 +180,7 @@ const StoresListUI = (props: BusinessesListingParams) => {
180
180
  isBusinessOpen={business?.open}
181
181
  setIsUpdateStore={setIsUpdateStore}
182
182
  isUpdateStore={isUpdateStore}
183
+ navigation={navigation}
183
184
  />
184
185
  ))}
185
186
 
@@ -173,6 +173,7 @@ export interface BusinessControllerParams {
173
173
  isBusinessOpen?: boolean;
174
174
  businessWillCloseSoonMinutes?: number;
175
175
  updateBusiness?: (id: any, value: any) => {};
176
+ navigation?: any;
176
177
  }
177
178
  export interface BusinessProductsListingParams {
178
179
  navigation?: any;
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { useSession, useOrder, useLanguage } from 'ordering-components/native'
2
+ import { useSession, useOrder, useLanguage, useConfig } from 'ordering-components/native'
3
3
  import { useTheme } from 'styled-components/native'
4
4
  import { TouchableOpacity, View } from 'react-native'
5
5
  import { OButton, OText } from '../shared';
@@ -27,6 +27,9 @@ export const ActionButton = (props : any) => {
27
27
  const [{ auth }] = useSession()
28
28
  const [orderState] = useOrder()
29
29
  const theme = useTheme()
30
+ const [{ configs }] = useConfig()
31
+ const unaddressedTypes = configs?.unaddressed_order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
32
+ const isAllowUnaddressOrderType = unaddressedTypes.includes(orderState?.options?.type)
30
33
 
31
34
  const saveErrors =
32
35
  orderState.loading ||
@@ -40,7 +43,7 @@ export const ActionButton = (props : any) => {
40
43
  }}>
41
44
  {((productCart &&
42
45
  auth &&
43
- orderState.options?.address_id) || (isSoldOut || maxProductQuantity <= 0)) && (
46
+ (orderState.options?.address_id || isAllowUnaddressOrderType)) || (isSoldOut || maxProductQuantity <= 0)) && (
44
47
  <OButton
45
48
  onClick={() => handleSaveProduct()}
46
49
  imgRightSrc=""
@@ -70,7 +73,7 @@ export const ActionButton = (props : any) => {
70
73
  />
71
74
  )}
72
75
  {auth &&
73
- !orderState.options?.address_id &&
76
+ !orderState.options?.address_id && !isAllowUnaddressOrderType &&
74
77
  (orderState.loading ? (
75
78
  <OButton
76
79
  isDisabled