ordering-ui-react-native 0.15.5 → 0.15.7-release

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.
Files changed (129) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessTypeFilter/index.tsx +12 -2
  4. package/src/components/BusinessTypeFilter/styles.tsx +1 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +0 -1
  7. package/src/components/Home/index.tsx +3 -5
  8. package/src/components/LanguageSelector/index.tsx +66 -97
  9. package/src/components/LanguageSelector/styles.tsx +4 -17
  10. package/src/components/Messages/index.tsx +38 -30
  11. package/src/components/MomentOption/index.tsx +3 -1
  12. package/src/components/OrderDetails/index.tsx +25 -4
  13. package/src/components/PaymentOptions/index.tsx +9 -16
  14. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  15. package/src/components/ProductForm/index.tsx +1 -1
  16. package/src/components/ProductForm/styles.tsx +1 -0
  17. package/src/components/StripeElementsForm/index.tsx +27 -48
  18. package/src/components/UserProfileForm/index.tsx +35 -1
  19. package/src/components/VerifyPhone/styles.tsx +1 -2
  20. package/src/config.json +0 -2
  21. package/src/pages/Checkout.tsx +1 -1
  22. package/src/types/index.tsx +2 -9
  23. package/src/utils/index.tsx +2 -1
  24. package/themes/business/index.tsx +2 -0
  25. package/themes/business/src/components/Chat/index.tsx +32 -31
  26. package/themes/business/src/components/Home/index.tsx +128 -55
  27. package/themes/business/src/components/Home/styles.tsx +8 -1
  28. package/themes/business/src/components/NewOrderNotification/index.tsx +59 -98
  29. package/themes/business/src/components/OrderDetails/Business.tsx +1 -0
  30. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +27 -0
  31. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +85 -17
  32. package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
  33. package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
  34. package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
  35. package/themes/business/src/components/OrdersOption/index.tsx +70 -116
  36. package/themes/business/src/components/OrdersOption/styles.tsx +2 -5
  37. package/themes/business/src/components/PreviousOrders/index.tsx +82 -23
  38. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  39. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  40. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  41. package/themes/kiosk/src/components/BusinessController/index.tsx +27 -6
  42. package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
  43. package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +51 -24
  44. package/themes/kiosk/src/components/Cart/index.tsx +1 -1
  45. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  46. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  47. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  48. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  49. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +7 -5
  50. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  51. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  52. package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
  53. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  54. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  55. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  56. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  58. package/themes/kiosk/src/components/ProductForm/index.tsx +174 -126
  59. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  60. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  61. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  62. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  63. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  64. package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
  65. package/themes/original/index.tsx +177 -0
  66. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  67. package/themes/original/src/components/AddressList/index.tsx +28 -2
  68. package/themes/original/src/components/BusinessBasicInformation/index.tsx +100 -45
  69. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  70. package/themes/original/src/components/BusinessController/index.tsx +32 -21
  71. package/themes/original/src/components/BusinessListingSearch/index.tsx +7 -3
  72. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  73. package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
  74. package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
  75. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -3
  76. package/themes/original/src/components/BusinessProductsListing/index.tsx +23 -30
  77. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  78. package/themes/original/src/components/BusinessesListing/index.tsx +40 -53
  79. package/themes/original/src/components/Cart/index.tsx +40 -9
  80. package/themes/original/src/components/CartContent/index.tsx +2 -2
  81. package/themes/original/src/components/Checkout/index.tsx +58 -33
  82. package/themes/original/src/components/Checkout/styles.tsx +7 -0
  83. package/themes/original/src/components/CouponControl/index.tsx +1 -0
  84. package/themes/original/src/components/DriverTips/index.tsx +1 -1
  85. package/themes/original/src/components/ForgotPasswordForm/index.tsx +8 -12
  86. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
  87. package/themes/original/src/components/Home/index.tsx +1 -1
  88. package/themes/original/src/components/LoginForm/index.tsx +156 -70
  89. package/themes/original/src/components/LoginForm/styles.tsx +6 -1
  90. package/themes/original/src/components/Messages/index.tsx +52 -45
  91. package/themes/original/src/components/Messages/styles.tsx +1 -3
  92. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  93. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  94. package/themes/original/src/components/OrderDetails/index.tsx +104 -126
  95. package/themes/original/src/components/OrderDetails/styles.tsx +3 -1
  96. package/themes/original/src/components/OrderProgress/index.tsx +4 -4
  97. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  98. package/themes/original/src/components/OrderSummary/index.tsx +34 -1
  99. package/themes/original/src/components/OrdersOption/index.tsx +15 -46
  100. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  101. package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
  102. package/themes/original/src/components/PaymentOptions/index.tsx +24 -25
  103. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -8
  104. package/themes/original/src/components/PlaceSpot/index.tsx +114 -0
  105. package/themes/original/src/components/PlaceSpot/styles.tsx +11 -0
  106. package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
  107. package/themes/original/src/components/ProductForm/index.tsx +35 -16
  108. package/themes/original/src/components/ProductForm/styles.tsx +2 -2
  109. package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
  110. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  111. package/themes/original/src/components/SignupForm/index.tsx +173 -154
  112. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
  113. package/themes/original/src/components/TaxInformation/index.tsx +17 -7
  114. package/themes/original/src/components/UpsellingProducts/index.tsx +6 -6
  115. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  116. package/themes/original/src/components/UserFormDetails/index.tsx +2 -14
  117. package/themes/original/src/components/UserProfile/index.tsx +16 -16
  118. package/themes/original/src/components/UserProfileForm/index.tsx +8 -6
  119. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  120. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  121. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  122. package/themes/original/src/components/shared/index.tsx +2 -0
  123. package/themes/original/src/config/constants.tsx +6 -6
  124. package/themes/original/src/types/index.tsx +63 -23
  125. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  126. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +5 -5
  127. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  128. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  129. package/src/components/StripeMethodForm/index.tsx +0 -168
@@ -1,13 +1,17 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { StyleSheet, TouchableOpacity, View } from 'react-native';
2
+ import { StyleSheet, TouchableOpacity, View, Platform, PlatformIOSStatic } from 'react-native';
3
3
  import { useTheme } from 'styled-components/native';
4
4
  import moment from 'moment'
5
- import { useLanguage, useUtils } from 'ordering-components/native';
5
+ import { useLanguage, useUtils, useConfig } from 'ordering-components/native';
6
6
  import { OButton, OIcon, OText } from '../shared';
7
7
  import {
8
8
  Card, Logo, Information, MyOrderOptions, NotificationIcon, AcceptOrRejectOrder, Timestatus
9
9
  } from './styles';
10
10
  import EntypoIcon from 'react-native-vector-icons/Entypo'
11
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
12
+ import DeviceInfo from 'react-native-device-info';
13
+
14
+ const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
11
15
 
12
16
  export const PreviousOrders = (props: any) => {
13
17
  const {
@@ -17,25 +21,44 @@ export const PreviousOrders = (props: any) => {
17
21
  handleClickOrder,
18
22
  isLogisticOrder,
19
23
  handleClickLogisticOrder,
20
- slaSettingTime
24
+ slaSettingTime,
25
+ currentTabSelected,
26
+ currentOrdenSelected
21
27
  } = props;
22
28
  const [, t] = useLanguage();
23
29
  const [{ parseDate, optimizeImage }] = useUtils();
30
+ const [configState] = useConfig()
24
31
  const theme = useTheme();
25
- const [currentTime, setCurrentTime] = useState()
32
+ const [, setCurrentTime] = useState()
33
+ const [allowColumns, setAllowColumns] = useState({
34
+ timer: true,
35
+ slaBar: true,
36
+ })
37
+
38
+ const [orientationState] = useDeviceOrientation();
39
+
40
+ const IS_PORTRAIT = orientationState.orientation === PORTRAIT
41
+
42
+ const platformIOS = Platform as PlatformIOSStatic
43
+ const isIpad = platformIOS.isPad
44
+ const isTablet = DeviceInfo.isTablet();
26
45
 
27
46
  const handlePressOrder = (order: any) => {
28
47
  if (order?.locked && isLogisticOrder) return
29
48
  handleClickOrder && handleClickOrder(order)
30
- onNavigationRedirect &&
31
- onNavigationRedirect('OrderDetails', { order: { ...order, isLogistic: isLogisticOrder }, handleClickLogisticOrder });
49
+ if (props.handleClickEvent) {
50
+ props.handleClickEvent({ ...order, isLogistic: isLogisticOrder })
51
+ } else {
52
+ onNavigationRedirect &&
53
+ onNavigationRedirect('OrderDetails', { order: { ...order, isLogistic: isLogisticOrder }, handleClickLogisticOrder });
54
+ }
32
55
  };
33
56
 
34
57
  const styles = StyleSheet.create({
35
58
  cardButton: {
36
59
  flex: 1,
37
- minHeight: isLogisticOrder ? 50 : 64,
38
- marginBottom: isLogisticOrder ? 0 : 30,
60
+ paddingVertical: (isIpad || isTablet) ? 20 : 0,
61
+ marginBottom: IS_PORTRAIT ? 25 : 0,
39
62
  marginLeft: 3,
40
63
  },
41
64
  icon: {
@@ -76,23 +99,42 @@ export const PreviousOrders = (props: any) => {
76
99
  },
77
100
  });
78
101
 
79
- const getDelayTime = (order: any) => {
102
+ const getDelayMinutes = (order: any) => {
80
103
  // targetMin = delivery_datetime + eta_time - now()
104
+ const offset = 300
105
+ const cdtToutc = moment(order?.delivery_datetime).add(offset, 'minutes').format('YYYY-MM-DD HH:mm:ss')
81
106
  const _delivery = order?.delivery_datetime_utc
107
+ ? parseDate(order?.delivery_datetime_utc)
108
+ : parseDate(cdtToutc)
82
109
  const _eta = order?.eta_time
83
- const tagetedMin = moment(_delivery).add(_eta, 'minutes').diff(moment().utc(), 'minutes')
84
- let day = Math.floor(tagetedMin / 1440)
110
+ const diffTimeAsSeconds = moment(_delivery, 'YYYY-MM-DD hh:mm A').add(_eta, 'minutes').diff(moment().utc(), 'seconds')
111
+ return Math.ceil(diffTimeAsSeconds / 60)
112
+ }
113
+
114
+ const displayDelayedTime = (order: any) => {
115
+ let tagetedMin = getDelayMinutes(order)
116
+ // get day, hour and minutes
117
+ const sign = tagetedMin >= 0 ? '' : '- '
118
+ tagetedMin = Math.abs(tagetedMin)
119
+ let day: string | number = Math.floor(tagetedMin / 1440)
85
120
  const restMinOfTargetedMin = tagetedMin - 1440 * day
86
- let restHours: any = Math.floor(restMinOfTargetedMin / 60)
87
- let restMins: any = restMinOfTargetedMin - 60 * restHours
121
+ let restHours: string | number = Math.floor(restMinOfTargetedMin / 60)
122
+ let restMins: string | number = restMinOfTargetedMin - 60 * restHours
123
+ // make standard time format
124
+ day = day === 0 ? '' : day + 'day '
125
+ restHours = restHours < 10 ? '0' + restHours : restHours
126
+ restMins = restMins < 10 ? '0' + restMins : restMins
88
127
 
89
- if (order?.time_status === 'in_time' || order?.time_status === 'at_risk') day = Math.abs(day)
90
- if (restHours < 10) restHours = ('0' + restHours)
91
- if (restMins < 10) restMins = ('0' + restMins)
92
- const finalTaget = day + 'day ' + restHours + ':' + restMins
128
+ const finalTaget = sign + day + restHours + ':' + restMins
93
129
  return finalTaget
94
130
  }
95
131
 
132
+ const getStatusClassName = (minutes: number) => {
133
+ if (isNaN(Number(minutes))) return 'in_time'
134
+ const delayTime = configState?.configs?.order_deadlines_delayed_time?.value
135
+ return minutes > 0 ? 'in_time' : Math.abs(minutes) <= delayTime ? 'at_risk' : 'delayed'
136
+ }
137
+
96
138
  useEffect(() => {
97
139
  const interval = setInterval(() => {
98
140
  const date: any = Date.now()
@@ -102,6 +144,15 @@ export const PreviousOrders = (props: any) => {
102
144
  return () => clearInterval(interval)
103
145
  }, [])
104
146
 
147
+ useEffect(() => {
148
+ const slaSettings = configState?.configs?.order_deadlines_enabled?.value === '1'
149
+ setAllowColumns({
150
+ ...allowColumns,
151
+ timer: slaSettings,
152
+ slaBar: slaSettings
153
+ })
154
+ }, [configState.loading])
155
+
105
156
  let hash: any = {};
106
157
 
107
158
  return (
@@ -114,8 +165,9 @@ export const PreviousOrders = (props: any) => {
114
165
  return (
115
166
  <View
116
167
  style={{
117
- backgroundColor: order?.locked && isLogisticOrder ? '#ccc' : '#fff',
118
- marginBottom: isLogisticOrder ? 10 : 0
168
+ backgroundColor: currentOrdenSelected === order?.id ? theme.colors.gray100 : order?.locked && isLogisticOrder ? '#ccc' : '#fff',
169
+ marginBottom: isLogisticOrder ? 10 : 0,
170
+ // justifyContent: 'center'
119
171
  }}
120
172
  key={order.id}
121
173
  >
@@ -126,7 +178,9 @@ export const PreviousOrders = (props: any) => {
126
178
  activeOpacity={1}
127
179
  >
128
180
  <Card key={order.id}>
129
- <Timestatus style={{ backgroundColor: order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : '' }} />
181
+ {allowColumns?.slaBar && (
182
+ <Timestatus style={{ backgroundColor: getStatusClassName(getDelayMinutes(order)) === 'in_time' ? '#00D27A' : getStatusClassName(getDelayMinutes(order)) === 'at_risk' ? '#FFC700' : getStatusClassName(getDelayMinutes(order)) === 'delayed' ? '#E63757' : '' }} />
183
+ )}
130
184
  {
131
185
  order.business?.logo && (
132
186
  <Logo style={styles.logo}>
@@ -159,7 +213,7 @@ export const PreviousOrders = (props: any) => {
159
213
  />
160
214
  </NotificationIcon>
161
215
  )}
162
- <View style={{ flexDirection: 'row' }}>
216
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
163
217
  <OText
164
218
  style={styles.date}
165
219
  color={theme.colors.unselectText}
@@ -169,9 +223,14 @@ export const PreviousOrders = (props: any) => {
169
223
  {(order?.order_group_id && order?.order_group && isLogisticOrder ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}` : (t('NO', 'Order No.') + order.id)) + ' · '}
170
224
  {order?.delivery_datetime_utc
171
225
  ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
172
- : parseDate(order?.delivery_datetime, { utc: false })}{' · '}
226
+ : parseDate(order?.delivery_datetime, { utc: false })}
173
227
  </OText>
174
- <OText style={styles.date} color={order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : ''} >{getDelayTime(order)}</OText>
228
+ {((currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && allowColumns?.timer) && (
229
+ <>
230
+ <OText> · </OText>
231
+ <OText style={styles.date} color={getStatusClassName(getDelayMinutes(order)) === 'in_time' ? '#00D27A' : getStatusClassName(getDelayMinutes(order)) === 'at_risk' ? '#FFC700' : getStatusClassName(getDelayMinutes(order)) === 'delayed' ? '#E63757' : ''} >{displayDelayedTime(order)}</OText>
232
+ </>
233
+ )}
175
234
  </View>
176
235
  {!isLogisticOrder && (
177
236
  <MyOrderOptions>
@@ -197,7 +197,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
197
197
  {isFarAway && (
198
198
  <FarAwayMessage style={styles.farAwayMsg}>
199
199
  <Ionicons name='md-warning-outline' style={styles.iconStyle} />
200
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
200
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'Your are far from this address')}</OText>
201
201
  </FarAwayMessage>
202
202
  )}
203
203
  {!auth && (
@@ -410,8 +410,7 @@ const LoginFormUI = (props: LoginParams) => {
410
410
  textInputProps={{
411
411
  returnKeyType: 'next',
412
412
  onSubmitEditing: () => inputRef?.current?.focus?.(),
413
- style: { borderWidth: 0, fontSize: 12 },
414
- maxLength: 10
413
+ style: { borderWidth: 0, fontSize: 12 }
415
414
  }}
416
415
  textWrapStyle={{ borderColor: theme.colors.clear, borderWidth: 0, height: 40, paddingStart: 0 }}
417
416
  />
@@ -155,7 +155,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
155
155
  {isFarAway && (
156
156
  <FarAwayMessage style={styles.farAwayMsg}>
157
157
  <Ionicons name='md-warning-outline' style={styles.iconStyle} />
158
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
158
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'Your are far from this address')}</OText>
159
159
  </FarAwayMessage>
160
160
  )}
161
161
  <View style={styles.wrapperOrderOptions}>
@@ -6,6 +6,7 @@ import {
6
6
  BusinessController as BusinessSingleCard,
7
7
  useUtils,
8
8
  } from 'ordering-components/native';
9
+ import FastImage from 'react-native-fast-image'
9
10
 
10
11
  import { Card, BusinessLogo } from './styles';
11
12
 
@@ -26,6 +27,16 @@ export const BusinessControllerUI = (props: any) => {
26
27
  alignItems: 'center',
27
28
  textAlign: 'center',
28
29
  marginTop: 10
30
+ },
31
+ logoStyle: {
32
+ width: 120,
33
+ height: 120,
34
+ borderRadius: 8,
35
+ borderWidth: 1,
36
+ borderColor: theme.colors.border,
37
+ flexDirection: 'column',
38
+ justifyContent: 'center',
39
+ alignItems: 'center',
29
40
  }
30
41
  });
31
42
 
@@ -39,12 +50,22 @@ export const BusinessControllerUI = (props: any) => {
39
50
  activeOpacity={1}
40
51
  onPress={() => handleBusinessClick(business)}
41
52
  >
42
- <BusinessLogo
43
- source={business?.logo ? {
44
- uri: optimizeImage(business?.logo, 'h_120,c_limit'),
45
- } : theme.images.dummies.businessLogo}
46
- resizeMode='contain'
47
- />
53
+ {business?.logo ? (
54
+ <FastImage
55
+ style={styles.logoStyle}
56
+ source={{
57
+ uri: business?.logo,
58
+ priority: FastImage.priority.high,
59
+ cache:FastImage.cacheControl.web
60
+ }}
61
+ resizeMode={FastImage.resizeMode.contain}
62
+ />
63
+ ) : (
64
+ <BusinessLogo
65
+ source={theme.images.dummies.businessLogo}
66
+ resizeMode='contain'
67
+ />
68
+ )}
48
69
  <OText
49
70
  size={WIDTH_SCREEN * 0.012}
50
71
  numberOfLines={2}
@@ -3,7 +3,7 @@ import styled, { css } from 'styled-components/native';
3
3
  export const Card = styled.TouchableOpacity`
4
4
  display: flex;
5
5
  flex-direction: column;
6
- justify-content: center;
6
+ justify-content: flex-start;
7
7
  align-items: center;
8
8
  margin: 0 15px 20px;
9
9
  width: 120px;
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { View, StyleSheet, ScrollView, TouchableOpacity } from 'react-native'
2
+ import { View, StyleSheet, ScrollView, TouchableOpacity, ImageBackground } from 'react-native'
3
3
  import { BusinessAndProductList, useLanguage } from 'ordering-components/native'
4
4
  import { BusinessProductsListingParams, Business } from '../../types'
5
5
  import { OCard, OText, OIcon } from '../shared'
@@ -7,6 +7,7 @@ import GridContainer from '../../layouts/GridContainer'
7
7
  import Spinner from 'react-native-loading-spinner-overlay';
8
8
  import { LANDSCAPE, useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
9
9
  import styled, { useTheme } from 'styled-components/native';
10
+ import FastImage from 'react-native-fast-image'
10
11
 
11
12
  const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
12
13
  const {navigation, businessState, resetInactivityTimeout, clearInactivityTimeout, bottomSheetVisibility } = props;
@@ -38,7 +39,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
38
39
  },
39
40
  });
40
41
 
41
- const _categories: any = business?.original?.categories;
42
+ const _categories: any = business?.categories;
42
43
  let _promos: any = [];
43
44
  _categories?.forEach((categ: any) => {
44
45
  const _featuredProds = categ?.products?.filter(
@@ -59,17 +60,17 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
59
60
  );
60
61
 
61
62
  const RenderCategories = ({ item, cardStyle, widthScreen }: any) => {
62
- const Category = styled.ImageBackground`
63
- position: relative;
64
- height: 150px;
65
- width: ${(props: any) => props.w * 0.45}px;
66
- border-radius: 10px;
67
- padding: 10px;
68
- display: flex;
69
- flex-direction: column;
70
- justify-content: center;
71
- align-items: center;
72
- `
63
+ const stylesCat = StyleSheet.create({
64
+ categoryStyle: {
65
+ height: 150,
66
+ borderRadius: 10,
67
+ padding: 10,
68
+ flexDirection: 'column',
69
+ justifyContent: 'center',
70
+ alignItems: 'center',
71
+ }
72
+ })
73
+
73
74
  const WrapText = styled.View`
74
75
  height: 90px;
75
76
  display: flex;
@@ -78,6 +79,25 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
78
79
  border-radius: 10px;
79
80
  `
80
81
 
82
+ const Category = (props: any) => {
83
+ const imageProps = {
84
+ style: props.style,
85
+ source: props.source,
86
+ resizeMode: props.resizeMode,
87
+ }
88
+ return (
89
+ props.uri ? (
90
+ <FastImage {...imageProps}>
91
+ {props.children}
92
+ </FastImage>
93
+ ) : (
94
+ <ImageBackground {...imageProps}>
95
+ {props.children}
96
+ </ImageBackground>
97
+ )
98
+ )
99
+ }
100
+
81
101
  return (
82
102
  <TouchableOpacity
83
103
  key={item.id}
@@ -92,11 +112,17 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
92
112
  }}
93
113
  >
94
114
  <Category
95
- style={cardStyle}
96
- source={{uri: item.images}}
97
- resizeMode="cover"
98
- w={widthScreen}
99
- borderRadius={16}
115
+ style={{ ...cardStyle, ...stylesCat.categoryStyle, width: widthScreen * 0.45 }}
116
+ uri={!!item.images}
117
+ source={!!item.images
118
+ ? {
119
+ uri: item.images,
120
+ priority: FastImage.priority.high,
121
+ cache:FastImage.cacheControl.web
122
+ }
123
+ : theme.images.categories.all
124
+ }
125
+ resizeMode={FastImage.resizeMode.cover}
100
126
  >
101
127
  {item?.inventoried && (
102
128
  <View style={styles.soldOut}>
@@ -111,7 +137,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
111
137
  mLeft={0}
112
138
  size={32}
113
139
  numberOfLines={1}
114
- // mBottom={8}
115
140
  style={{...props?.titleStyle}}
116
141
  weight="bold"
117
142
  >
@@ -121,7 +146,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
121
146
  <OText
122
147
  color={theme.colors.white}
123
148
  numberOfLines={1}
124
- // mBottom={4}
125
149
  size={18}
126
150
  style={{...props?.descriptionStyle}}
127
151
  weight="400"
@@ -161,7 +185,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
161
185
  const _renderCategories = (): React.ReactElement => (
162
186
  <>
163
187
  {_renderTitle(t('CATEGORIES', 'Categories'))}
164
- <GridContainer
188
+ <GridContainer
165
189
  style={{
166
190
  paddingLeft: orientationState?.orientation === LANDSCAPE
167
191
  ? bottomSheetVisibility ? orientationState?.dimensions?.width * 0.004 :orientationState?.dimensions?.width * 0.008
@@ -171,9 +195,12 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
171
195
  {_categories && _categories.map((category: any) => (
172
196
  <OCard
173
197
  key={category.id}
198
+ isCentered
199
+ isUri={!!category.image}
174
200
  title={category?.name || ''}
175
- image={{uri: category?.image}}
201
+ image={category.image ? {uri: category.image} : theme.images.categories.all}
176
202
  style={{
203
+ borderRadius: 10,
177
204
  width:
178
205
  orientationState?.orientation === LANDSCAPE
179
206
  ? bottomSheetVisibility ? orientationState?.dimensions?.width * 0.145 :orientationState?.dimensions?.width * 0.16
@@ -183,8 +210,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
183
210
  resetInactivityTimeout()
184
211
  navigation.navigate('Category', {
185
212
  category,
186
- categories: business.original.categories,
187
- businessId: business?.api?.businessId,
213
+ categories: business?.categories,
214
+ businessId: business?.id,
188
215
  businessSlug: business?.slug,
189
216
  clearInactivityTimeout,
190
217
  resetInactivityTimeout,
@@ -379,7 +379,7 @@ const CartUI = (props: any) => {
379
379
  <ProductForm
380
380
  productCart={curProduct}
381
381
  businessSlug={cart?.business?.slug}
382
- businessId={curProduct?.business_id}
382
+ businessId={cart?.business_id}
383
383
  categoryId={curProduct?.category_id}
384
384
  productId={curProduct?.id}
385
385
  onSave={handlerProductAction}
@@ -179,7 +179,7 @@ const CartBottomSheetUI = (props: CartBottomSheetUIProps): React.ReactElement |
179
179
  <ProductForm
180
180
  productCart={curProduct}
181
181
  businessSlug={cart?.business?.slug}
182
- businessId={curProduct?.business_id}
182
+ businessId={cart?.business_id}
183
183
  categoryId={curProduct?.category_id}
184
184
  productId={curProduct?.id}
185
185
  onSave={handlerProductAction}
@@ -5,7 +5,7 @@ export const StyledContainer = styled.ScrollView`
5
5
  zIndex: 1000;
6
6
  width: 100%;
7
7
  background-color: #fff;
8
- padding: 20px 20px 20px 0px;
8
+ padding: 20px 0 0;
9
9
  bottom: 0;
10
10
  shadow-color: #000;
11
11
  shadow-opacity: 0.4;
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { useLanguage } from 'ordering-components/native';
3
-
3
+ import { useCartBottomSheet } from '../../providers/CartBottomSheetProvider';
4
4
  import { CCNotCarts } from './styles';
5
5
 
6
6
  import { Cart } from '../Cart';
@@ -22,6 +22,7 @@ export const CartContent = (props: any) => {
22
22
 
23
23
  const [, t] = useLanguage()
24
24
  const [isCartsLoading, setIsCartsLoading] = useState(false)
25
+ const [, { hideCartBottomSheet }] = useCartBottomSheet();
25
26
 
26
27
  const cartProps = {
27
28
  navigation,
@@ -33,6 +34,15 @@ export const CartContent = (props: any) => {
33
34
  resetInactivityTimeout,
34
35
  }
35
36
 
37
+ useEffect(() => {
38
+ if (!cart && showNotFound) {
39
+ navigation?.canGoBack()
40
+ ? navigation.goBack()
41
+ : props.onNavigationRedirect && props.onNavigationRedirect('Business')
42
+ hideCartBottomSheet()
43
+ }
44
+ }, [cart])
45
+
36
46
  const content = (
37
47
  <>
38
48
  {(isOrderStateCarts && cart) && (
@@ -46,13 +56,13 @@ export const CartContent = (props: any) => {
46
56
  }
47
57
  </>
48
58
  )}
49
- {(!cart && showNotFound) && (
59
+ {/* {(!cart && showNotFound) && (
50
60
  <CCNotCarts>
51
61
  <OText size={24} style={{ textAlign: 'center' }}>
52
62
  {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
53
63
  </OText>
54
64
  </CCNotCarts>
55
- )}
65
+ )} */}
56
66
  <Spinner visible={isCartsLoading} />
57
67
  </>
58
68
  )
@@ -1,6 +1,7 @@
1
1
  import React, { useState } from 'react';
2
- import { View, Animated, TouchableOpacity } from 'react-native';
2
+ import { View, Animated, TouchableOpacity, ImageBackground } from 'react-native';
3
3
  import { useLanguage, useUtils } from 'ordering-components/native';
4
+ import FastImage from 'react-native-fast-image'
4
5
 
5
6
  import {
6
7
  StyledCartItem,
@@ -70,13 +71,24 @@ const CartItem = (props: CartItemProps) => {
70
71
  >
71
72
  <StyledCartItem>
72
73
  <View style={{ flexDirection: 'row' }}>
73
- <OImage
74
- source={{ uri: product?.images || '' }}
75
- height={60}
76
- width={60}
77
- resizeMode="cover"
78
- borderRadius={6}
79
- />
74
+ {product?.images ? (
75
+ <FastImage
76
+ style={{ height: 60, width: 80, borderRadius: 6 }}
77
+ source={{
78
+ uri: product?.images,
79
+ priority: FastImage.priority.normal,
80
+ // cache:FastImage.cacheControl.web
81
+ }}
82
+ resizeMode={FastImage.resizeMode.cover}
83
+ />
84
+ ) : (
85
+ <ImageBackground
86
+ style={{ height: 60, width: 80, borderRadius: 6 }}
87
+ source={theme.images.dummies.product}
88
+ imageStyle={{ borderRadius: 6 }}
89
+ resizeMode='cover'
90
+ />
91
+ )}
80
92
 
81
93
  <View style={{ flexDirection: 'column', justifyContent: 'space-evenly', marginHorizontal: 15, marginTop: 10 }}>
82
94
  <View>
@@ -156,13 +156,17 @@ const CategoriesMenu = (props: any): React.ReactElement => {
156
156
  <OCard
157
157
  key={product.id}
158
158
  title={product?.name}
159
- image={{ uri: product?.images }}
159
+ isUri={!!product.images}
160
+ image={product.images ? {uri: product.images} : theme.images.dummies.product}
161
+ price={parsePrice(product?.price)}
162
+ description={product?.description}
163
+ prevPrice={product?.offer_price > 0 && parsePrice(product?.offer_price)}
160
164
  style={{
165
+ borderRadius: 10,
161
166
  width: orientationState?.orientation === LANDSCAPE
162
167
  ? bottomSheetVisibility ? orientationState?.dimensions?.width * 0.145 :orientationState?.dimensions?.width * 0.16
163
168
  : orientationState?.dimensions?.width * 0.20
164
169
  }}
165
- titleStyle={{marginTop: Platform.OS === 'ios' ? orientationState?.orientation === LANDSCAPE ? orientationState?.dimensions.height * 0.05 : orientationState?.dimensions.width * 0.05 : 0}}
166
170
  onPress={() => {
167
171
  resetInactivityTimeout()
168
172
  if (isDrawer) {
@@ -176,9 +180,6 @@ const CategoriesMenu = (props: any): React.ReactElement => {
176
180
  });
177
181
  }
178
182
  }}
179
- {...(!!product?.description && { description: product?.description } )}
180
- {...(!!product?.price && { price: parsePrice(product?.price) } )}
181
- {...(product?.in_offer && { prevPrice: `$${product?.offer_price}` } )}
182
183
  />
183
184
  ))}
184
185
  </GridContainer>
@@ -212,6 +213,7 @@ const CategoriesMenu = (props: any): React.ReactElement => {
212
213
  businessId={parseInt(businessId, 10)}
213
214
  businessSlug={businessSlug}
214
215
  onSave={() => {
216
+ showCartBottomSheet()
215
217
  setDrawerValues({ isOpen: !drawerState.isOpen, data: null })
216
218
  }}
217
219
  navigation={navigation}