ordering-ui-react-native 0.16.20 → 0.16.23

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.16.20",
3
+ "version": "0.16.23",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -247,17 +247,17 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
247
247
  let isToFollow = false;
248
248
  let isBusinessMarker = false;
249
249
 
250
- if (order?.status === 7 || order?.status === 8) {
250
+ if (order?.status === 7 || order?.status === 8 || order?.status === 18) {
251
251
  const markerBusiness = 'Business';
252
252
  isBusinessMarker = true;
253
253
  locationMarker = locations.find(
254
254
  (location: any) => location.type === markerBusiness,
255
255
  );
256
256
 
257
- if (order?.status === 8) {
257
+ if (order?.status === 8 || order?.status === 18) {
258
258
  isToFollow = true;
259
259
  }
260
- } else if (order?.status === 3 || order?.status === 9) {
260
+ } else if (order?.status === 3 || order?.status === 9 || order?.status === 19 || order?.status === 23) {
261
261
  const markerCustomer = 'Customer';
262
262
  isToFollow = true;
263
263
  isBusinessMarker = false;
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
- import { PanResponder, TouchableOpacity, View } from 'react-native';
2
+ import { PanResponder, Platform, TouchableOpacity, View } from 'react-native';
3
3
  import {
4
4
  useLanguage,
5
5
  useOrder,
@@ -120,6 +120,7 @@ const BusinessMenu = (props:any): React.ReactElement => {
120
120
  }}
121
121
  >
122
122
  <Container nopadding nestedScrollEnabled>
123
+ {Platform.OS === 'android' && (<View style={{ paddingTop: 20 }} />)}
123
124
  <NavBar
124
125
  title={t('MENU_V21', 'Menu')}
125
126
  onActionLeft={goToBack}
@@ -56,9 +56,10 @@ const CartItem = (props: CartItemProps) => {
56
56
  return product
57
57
  }
58
58
  const isProductIngredients = productInfo()?.ingredients.length > 0 || productInfo()?.options.length > 0 || product?.comment
59
- const getFormattedSubOptionName = ({ quantity, name, position, price }: { quantity: number, name: string, position: string, price: number }) => {
59
+ const getFormattedSubOptionName = ({ quantity, name, position, price }: { quantity: number, name: string, position: string, price: any }) => {
60
60
  const pos = position ? `(${position})` : ''
61
- return `${quantity} x ${name} ${pos} +${price}`
61
+ const str = `${quantity} x ${name} ${pos}`
62
+ return price ? `${str} ${price}` : str
62
63
  }
63
64
 
64
65
  return (
@@ -184,7 +185,7 @@ const CartItem = (props: CartItemProps) => {
184
185
  quantity: suboption.quantity,
185
186
  name: suboption.name,
186
187
  position: (suboption.position !== 'whole') ? t(suboption.position.toUpperCase(), suboption.position) : '',
187
- price: parsePrice(suboption.price)
188
+ price: suboption.price > 0 && `+${parsePrice(suboption.price)}`
188
189
  })}
189
190
  </OText>
190
191
  </ProductSubOption>
@@ -141,6 +141,7 @@ const CategoriesMenu = (props: any): React.ReactElement => {
141
141
  }}
142
142
  >
143
143
  <Container nopadding nestedScrollEnabled>
144
+ {Platform.OS === 'android' && (<View style={{ paddingTop: 20 }} />)}
144
145
  <NavBar
145
146
  title={categories[curIndexCateg].name}
146
147
  onActionLeft={goToBack}
@@ -53,5 +53,6 @@ const styles = StyleSheet.create({
53
53
  },
54
54
  shadowOpacity: 0.21,
55
55
  shadowRadius: 5,
56
+ elevation: 16
56
57
  }
57
58
  })
@@ -19,12 +19,12 @@ export const WrapperFloatBtn = styled.View`
19
19
  top: 10%;
20
20
  right: ${(props: any) => props.outside ? 11 : 58}%;
21
21
  z-index: 20002;
22
- elevation: 11;
22
+ elevation: 17;
23
23
  `;
24
24
 
25
25
  export const IconControl = styled.TouchableOpacity`
26
26
  background-color: ${(props: any) => props.theme.colors.white};
27
27
  padding: 10px;
28
28
  border-radius: 8px;
29
- elevation: 11;
29
+ elevation: 17;
30
30
  `;
@@ -46,7 +46,9 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
46
46
  filters,
47
47
  businessTypes,
48
48
  setFilters,
49
- brandList
49
+ brandList,
50
+ handleUpdateBusinessList,
51
+ handleUpdateProducts
50
52
  } = props
51
53
 
52
54
  const screenHeight = Dimensions.get('window').height;
@@ -264,6 +266,7 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
264
266
  business={business}
265
267
  isBusinessOpen={business.open}
266
268
  handleCustomClick={() => onBusinessClick(business)}
269
+ handleUpdateBusinessList={handleUpdateBusinessList}
267
270
  orderType={orderState?.options?.type}
268
271
  style={{ width: 320, marginRight: (businessesSearchList.loading || i !== businessesSearchList.businesses?.length - 1) ? 20 : 0 }}
269
272
  />
@@ -384,6 +387,7 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
384
387
  businessId={business?.id}
385
388
  onProductClick={() => { }}
386
389
  productAddedToCartLength={0}
390
+ handleUpdateProducts={(productId: number, changes: any) => handleUpdateProducts(productId, category?.id, business?.id, changes)}
387
391
  style={{ width: 320, marginRight: i === category?.products?.length - 1 ? 0 : 20 }}
388
392
  />
389
393
  )))}
@@ -171,9 +171,9 @@ const CheckoutUI = (props: any) => {
171
171
  }
172
172
  }
173
173
 
174
- const handlePlaceOrder = () => {
174
+ const handlePlaceOrder = (confirmPayment) => {
175
175
  if (!userErrors.length) {
176
- handlerClickPlaceOrder && handlerClickPlaceOrder()
176
+ handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
177
177
  return
178
178
  }
179
179
  let stringError = ''
@@ -18,4 +18,5 @@ export const Tab = styled.TouchableOpacity`
18
18
  export const Container = styled.View`
19
19
  padding-horizontal: 40px;
20
20
  padding-bottom: 20px;
21
+ padding-top: 30px;
21
22
  `
@@ -14,6 +14,7 @@ import { Container, WrappButton } from './styles'
14
14
  import { OButton } from '../shared';
15
15
  import { BusinessController } from '../BusinessController';
16
16
  import { SingleProductCard } from '../SingleProductCard';
17
+ import moment from 'moment';
17
18
 
18
19
 
19
20
  const FavoriteListUI = (props: FavoriteParams) => {
@@ -103,55 +104,91 @@ const FavoriteListUI = (props: FavoriteParams) => {
103
104
  });
104
105
  }
105
106
 
107
+ const BusinessSkeleton = () => {
108
+ return (
109
+ <Placeholder
110
+ Animation={Fade}
111
+ style={{ marginBottom: 20 }}>
112
+ <View style={{ width: '100%' }}>
113
+ <PlaceholderLine
114
+ height={200}
115
+ style={{ marginBottom: 20, borderRadius: 25 }}
116
+ />
117
+ <View style={{ paddingHorizontal: 10 }}>
118
+ <View
119
+ style={{
120
+ flexDirection: 'row',
121
+ justifyContent: 'space-between',
122
+ }}>
123
+ <PlaceholderLine
124
+ height={25}
125
+ width={40}
126
+ style={{ marginBottom: 10 }}
127
+ />
128
+ <PlaceholderLine
129
+ height={25}
130
+ width={20}
131
+ style={{ marginBottom: 10 }}
132
+ />
133
+ </View>
134
+ <PlaceholderLine
135
+ height={20}
136
+ width={30}
137
+ style={{ marginBottom: 10 }}
138
+ />
139
+ <PlaceholderLine
140
+ height={20}
141
+ width={80}
142
+ style={{ marginBottom: 10 }}
143
+ />
144
+ </View>
145
+ </View>
146
+ </Placeholder>
147
+ )
148
+ }
149
+
150
+ const ProductSkeleton = () => {
151
+ return (
152
+ <Placeholder style={{ padding: 5 }} Animation={Fade}>
153
+ <View style={{ flexDirection: 'row' }}>
154
+ <PlaceholderLine
155
+ width={24}
156
+ height={70}
157
+ style={{ marginRight: 10, marginBottom: 10 }}
158
+ />
159
+ <Placeholder style={{ paddingVertical: 10 }}>
160
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
161
+ <PlaceholderLine width={20} />
162
+ </Placeholder>
163
+ </View>
164
+ </Placeholder>
165
+ )
166
+ }
167
+
168
+ const OrderSkeleton = () => {
169
+ return (
170
+ <Placeholder style={{ padding: 5 }} Animation={Fade}>
171
+ <View style={{ flexDirection: 'row' }}>
172
+ <PlaceholderLine
173
+ width={24}
174
+ height={70}
175
+ style={{ marginRight: 10, marginBottom: 10 }}
176
+ />
177
+ <Placeholder style={{ paddingVertical: 10 }}>
178
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
179
+ <PlaceholderLine width={20} />
180
+ </Placeholder>
181
+ </View>
182
+ </Placeholder>
183
+ )
184
+ }
185
+
106
186
  return (
107
187
  <Container>
108
188
  {isBusiness && (
109
189
  <>
110
- {favoriteList?.loading && (
111
- [...Array(5).keys()].map(i => (
112
- <Placeholder
113
- Animation={Fade}
114
- key={i}
115
- style={{ marginBottom: 20 }}>
116
- <View style={{ width: '100%' }}>
117
- <PlaceholderLine
118
- height={200}
119
- style={{ marginBottom: 20, borderRadius: 25 }}
120
- />
121
- <View style={{ paddingHorizontal: 10 }}>
122
- <View
123
- style={{
124
- flexDirection: 'row',
125
- justifyContent: 'space-between',
126
- }}>
127
- <PlaceholderLine
128
- height={25}
129
- width={40}
130
- style={{ marginBottom: 10 }}
131
- />
132
- <PlaceholderLine
133
- height={25}
134
- width={20}
135
- style={{ marginBottom: 10 }}
136
- />
137
- </View>
138
- <PlaceholderLine
139
- height={20}
140
- width={30}
141
- style={{ marginBottom: 10 }}
142
- />
143
- <PlaceholderLine
144
- height={20}
145
- width={80}
146
- style={{ marginBottom: 10 }}
147
- />
148
- </View>
149
- </View>
150
- </Placeholder>
151
- ))
152
- )}
153
- {!favoriteList?.loading && favoriteList?.favorites?.length > 0 && (
154
- favoriteList.favorites.map((business: any, i:number) => (
190
+ {favoriteList?.favorites?.length > 0 && (
191
+ favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((business: any, i:number) => (
155
192
  <BusinessController
156
193
  key={`${business.id}_` + i}
157
194
  business={business}
@@ -171,41 +208,35 @@ const FavoriteListUI = (props: FavoriteParams) => {
171
208
  />
172
209
  ))
173
210
  )}
211
+ {favoriteList?.loading && (
212
+ [...Array(5).keys()].map(i => (
213
+ <BusinessSkeleton key={i} />
214
+ ))
215
+ )}
174
216
  </>
175
217
  )}
176
218
 
177
219
  {isOrder && (
178
220
  <>
179
- {favoriteList?.loading && (
180
- [...Array(5).keys()].map(i => (
181
- <Placeholder key={i} style={{ padding: 5 }} Animation={Fade}>
182
- <View style={{ flexDirection: 'row' }}>
183
- <PlaceholderLine
184
- width={24}
185
- height={70}
186
- style={{ marginRight: 10, marginBottom: 10 }}
187
- />
188
- <Placeholder style={{ paddingVertical: 10 }}>
189
- <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
190
- <PlaceholderLine width={20} />
191
- </Placeholder>
192
- </View>
193
- </Placeholder>
221
+ {favoriteList?.favorites?.length > 0 && (
222
+ favoriteList.favorites?.sort((a: any, b:any) => moment(a?.delivery_datetime_utc).valueOf() - moment(b?.delivery_datetime_utc).valueOf())
223
+ .map((order: any, i: number) => (
224
+ <SingleOrderCard
225
+ key={`${order?.id}_${i}`}
226
+ order={order}
227
+ getOrderStatus={getOrderStatus}
228
+ onNavigationRedirect={onNavigationRedirect}
229
+ pastOrders={pastOrders.includes(order?.status)}
230
+ handleUpdateOrderList={handleUpdateFavoriteList}
231
+ handleUpdateFavoriteList={handleUpdateFavoriteList}
232
+ handleReorder={handleReorder}
233
+ reorderLoading={reorderState?.loading}
234
+ />
194
235
  ))
195
236
  )}
196
- {!favoriteList?.loading && favoriteList?.favorites?.length > 0 && (
197
- favoriteList.favorites.map((order: any, i: number) => (
198
- <SingleOrderCard
199
- key={`${order?.id}_${i}`}
200
- order={order}
201
- getOrderStatus={getOrderStatus}
202
- onNavigationRedirect={onNavigationRedirect}
203
- pastOrders={pastOrders.includes(order?.status)}
204
- handleUpdateOrderList={handleUpdateFavoriteList}
205
- handleUpdateFavoriteList={handleUpdateFavoriteList}
206
- handleReorder={handleReorder}
207
- reorderLoading={reorderState?.loading}
208
- />
237
+ {favoriteList?.loading && (
238
+ [...Array(5).keys()].map(i => (
239
+ <OrderSkeleton key={i} />
209
240
  ))
210
241
  )}
211
242
  </>
@@ -213,25 +244,8 @@ const FavoriteListUI = (props: FavoriteParams) => {
213
244
 
214
245
  {isProduct && (
215
246
  <>
216
- {favoriteList?.loading && (
217
- [...Array(5).keys()].map(i => (
218
- <Placeholder key={i} style={{ padding: 5 }} Animation={Fade}>
219
- <View style={{ flexDirection: 'row' }}>
220
- <PlaceholderLine
221
- width={24}
222
- height={70}
223
- style={{ marginRight: 10, marginBottom: 10 }}
224
- />
225
- <Placeholder style={{ paddingVertical: 10 }}>
226
- <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
227
- <PlaceholderLine width={20} />
228
- </Placeholder>
229
- </View>
230
- </Placeholder>
231
- ))
232
- )}
233
- {!favoriteList?.loading && favoriteList?.favorites?.length > 0 && (
234
- favoriteList.favorites.map((product: any, i: number) => (
247
+ {favoriteList?.favorites?.length > 0 && (
248
+ favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((product: any, i: number) => (
235
249
  <SingleProductCard
236
250
  key={`${product?.id}_${i}`}
237
251
  isSoldOut={product.inventoried && !product.quantity}
@@ -241,6 +255,11 @@ const FavoriteListUI = (props: FavoriteParams) => {
241
255
  />
242
256
  ))
243
257
  )}
258
+ {favoriteList?.loading && (
259
+ [...Array(5).keys()].map(i => (
260
+ <ProductSkeleton key={i} />
261
+ ))
262
+ )}
244
263
  </>
245
264
  )}
246
265
 
@@ -417,14 +417,17 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
417
417
  ];
418
418
  const driverLocationString = typeof order?.driver?.location?.location === 'string' && order?.driver?.location?.location?.split(',').map((l: string) => l.replace(/[^-.0-9]/g, ''))
419
419
  const parsedLocations = locations.map(location => typeof location?.location === 'string' ? {
420
- ...location,
421
- lat: parseFloat(location?.location?.split(',')[0].replace(/[^-.0-9]/g, '')),
422
- lng: parseFloat(location?.location?.split(',')[1].replace(/[^-.0-9]/g, ''))
423
- } : location)
420
+ ...location,
421
+ lat: parseFloat(location?.location?.split(',')[0].replace(/[^-.0-9]/g, '')),
422
+ lng: parseFloat(location?.location?.split(',')[1].replace(/[^-.0-9]/g, ''))
423
+ } : location)
424
424
 
425
425
  useEffect(() => {
426
426
  if (driverLocation) {
427
- locations[0] = driverLocation;
427
+ parsedLocations[0] = {
428
+ ...locations[0],
429
+ ...driverLocation
430
+ }
428
431
  }
429
432
  }, [driverLocation]);
430
433
 
@@ -698,7 +701,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
698
701
  <Map>
699
702
  <GoogleMap
700
703
  location={typeof order?.driver?.location?.location === 'string'
701
- ? {
704
+ ? {
702
705
  lat: parseFloat(driverLocationString[0]),
703
706
  lng: parseFloat(driverLocationString[1]),
704
707
  } : driverLocation ?? order?.driver?.location
@@ -1029,7 +1032,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1029
1032
  )}
1030
1033
  </View>
1031
1034
  <OText>
1032
- -{parsePrice(event.amount, {isTruncable: true})}
1035
+ -{parsePrice(event.amount, { isTruncable: true })}
1033
1036
  </OText>
1034
1037
  </View>
1035
1038
  ))}
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  PaymentOptions as PaymentOptionsController,
11
11
  useLanguage,
12
- ToastType,
12
+ ToastType,
13
13
  useToast,
14
14
  } from 'ordering-components/native';
15
15
  import { useTheme } from 'styled-components/native';
@@ -30,6 +30,7 @@ import {
30
30
  PMCardItemContent
31
31
  } from './styles'
32
32
  import { getIconCard, flatArray } from '../../utils';
33
+ import { useApplePay } from '@stripe/stripe-react-native';
33
34
 
34
35
  const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
35
36
  const methodsPay = ['google_pay', 'apple_pay']
@@ -62,7 +63,8 @@ const PaymentOptionsUI = (props: any) => {
62
63
  } = props
63
64
 
64
65
  const theme = useTheme();
65
- const [, { showToast }] = useToast();
66
+ const [, { showToast }] = useToast();
67
+ const { confirmApplePayPayment } = useApplePay()
66
68
 
67
69
  const getPayIcon = (method: string) => {
68
70
  switch (method) {
@@ -98,18 +100,18 @@ const PaymentOptionsUI = (props: any) => {
98
100
  // ]
99
101
 
100
102
  const handlePaymentMethodClick = (paymethod: any) => {
101
- if (cart?.balance > 0) {
102
- const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
103
- if (webViewPaymentGateway.includes(paymethod?.gateway)) {
104
- handlePaymentMethodClickCustom(paymethod)
105
- }
106
- handlePaymethodClick(paymethod, isPopupMethod)
107
- return
108
- }
109
- showToast(
103
+ if (cart?.balance > 0) {
104
+ const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
105
+ if (webViewPaymentGateway.includes(paymethod?.gateway)) {
106
+ handlePaymentMethodClickCustom(paymethod)
107
+ }
108
+ handlePaymethodClick(paymethod, isPopupMethod)
109
+ return
110
+ }
111
+ showToast(
110
112
  ToastType.Error,
111
113
  t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
112
- ;
114
+ ;
113
115
  }
114
116
 
115
117
  useEffect(() => {
@@ -134,7 +136,7 @@ const PaymentOptionsUI = (props: any) => {
134
136
 
135
137
  useEffect(() => {
136
138
  if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
137
- handlePlaceOrder()
139
+ handlePlaceOrder(confirmApplePayPayment)
138
140
  }
139
141
  }, [paymethodData, paymethodSelected])
140
142
 
@@ -15,22 +15,14 @@ import FastImage from 'react-native-fast-image'
15
15
  import IconAntDesign from 'react-native-vector-icons/AntDesign'
16
16
  import { shape } from '../../utils';
17
17
 
18
- function SingleProductCardPropsAreEqual(prevProps : any, nextProps : any) {
19
- return JSON.stringify(prevProps.product) === JSON.stringify(nextProps.product) &&
20
- prevProps.isSoldOut === nextProps.isSoldOut &&
21
- prevProps.productAddedToCartLength === nextProps.productAddedToCartLength &&
22
- prevProps.categoryState === nextProps.categoryState
23
- }
24
-
25
- const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
18
+ const SinguleProductCardUI = (props: SingleProductCardParams) => {
26
19
  const {
27
20
  product,
28
21
  isSoldOut,
29
22
  onProductClick,
30
23
  productAddedToCartLength,
31
24
  style,
32
- handleFavoriteProduct,
33
- handleUpdateProducts
25
+ handleFavoriteProduct
34
26
  } = props;
35
27
 
36
28
  const theme = useTheme();
@@ -212,7 +204,7 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
212
204
  )}
213
205
  </CardContainer>
214
206
  );
215
- }, SingleProductCardPropsAreEqual);
207
+ };
216
208
 
217
209
  export const SingleProductCard = (props: SingleProductCardParams) => {
218
210
  const singleProductCardProps = {
@@ -605,6 +605,8 @@ export interface BusinessSearchParams {
605
605
  setFilters: (filters: any) => void,
606
606
  lazySearch?: boolean,
607
607
  brandList?: any;
608
+ handleUpdateProducts: any,
609
+ handleUpdateBusinessList?: any;
608
610
  }
609
611
 
610
612
  export interface NoNetworkParams {