ordering-ui-react-native 0.21.3 → 0.21.5

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.3",
3
+ "version": "0.21.5",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -464,7 +464,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
464
464
  return (
465
465
  <>
466
466
  <OrderContentComponent
467
- isDelivery
468
467
  order={order}
469
468
  logisticOrderStatus={logisticOrderStatus}
470
469
  isOrderGroup={isOrderGroup}
@@ -37,15 +37,14 @@ interface OrderContent {
37
37
  order: any,
38
38
  logisticOrderStatus?: Array<number>,
39
39
  isOrderGroup?: boolean,
40
- lastOrder?: boolean,
41
- isDelivery?: boolean
40
+ lastOrder?: boolean
42
41
  }
43
42
 
44
43
  export const OrderContentComponent = (props: OrderContent) => {
45
44
  const [, t] = useLanguage();
46
45
  const theme = useTheme()
47
46
  const [{ user }] = useSession()
48
- const { order, logisticOrderStatus, isOrderGroup, lastOrder, isDelivery } = props;
47
+ const { order, logisticOrderStatus, isOrderGroup, lastOrder } = props;
49
48
  const [{ parsePrice, parseNumber }] = useUtils();
50
49
  const [{ configs }] = useConfig();
51
50
  const [orientationState] = useDeviceOrientation();
@@ -55,8 +54,14 @@ export const OrderContentComponent = (props: OrderContent) => {
55
54
 
56
55
  const [openReviewModal, setOpenReviewModal] = useState(false)
57
56
 
58
- const [isReadMore, setIsReadMore] = useState(false)
59
- const [lengthMore, setLengthMore] = useState(false)
57
+ const [isReadMore, setIsReadMore] = useState({
58
+ customerAddress: false,
59
+ businessAddressNotes: false
60
+ })
61
+ const [lengthMore, setLengthMore] = useState({
62
+ customerAddress: false,
63
+ businessAddressNotes: false
64
+ })
60
65
 
61
66
  const pastOrderStatuses = [1, 2, 5, 6, 10, 11, 12, 16, 17]
62
67
 
@@ -109,8 +114,15 @@ export const OrderContentComponent = (props: OrderContent) => {
109
114
  return /^\d+$/.test(str);
110
115
  }
111
116
 
112
- const onTextLayout = useCallback((e: any) => {
113
- setLengthMore((e.nativeEvent.lines.length == 2 && e.nativeEvent.lines[1].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 2); //to check the text is more than 2 lines or not
117
+ const onTextLayout = useCallback((e: any, item: string) => {
118
+ if (item === 'customerAddress') {
119
+ const customerAddressMore = (e.nativeEvent.lines.length == 2 && e.nativeEvent.lines[1].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 2
120
+ setLengthMore(prev => ({ ...prev, customerAddress: customerAddressMore }))
121
+ }
122
+ if (item === 'businessAddressNotes') {
123
+ const businessAddressNotesMore = (e.nativeEvent.lines.length == 3 && e.nativeEvent.lines[2].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 3
124
+ setLengthMore(prev => ({ ...prev, businessAddressNotes: businessAddressNotesMore }))
125
+ }
114
126
  }, []);
115
127
 
116
128
  return (
@@ -210,18 +222,28 @@ export const OrderContentComponent = (props: OrderContent) => {
210
222
  </OText>
211
223
  )}
212
224
  {!!order?.business?.address_notes && (
213
- <View style={styles.linkWithIcons}>
214
- <OLink
215
- PressStyle={styles.linkWithIcons}
216
- url={Platform.select({
217
- ios: `maps:0,0?q=${order?.business?.address_notes}`,
218
- android: `geo:0,0?q=${order?.business?.address_notes}`,
219
- })}
220
- shorcut={order?.business?.address_notes}
221
- TextStyle={styles.textLink}
222
- numberOfLines={isDelivery ? 0 : 1}
223
- />
224
- </View>
225
+ <>
226
+ <View style={styles.linkWithIcons}>
227
+ <OLink
228
+ PressStyle={styles.linkWithIcons}
229
+ url={Platform.select({
230
+ ios: `maps:0,0?q=${order?.business?.address_notes}`,
231
+ android: `geo:0,0?q=${order?.business?.address_notes}`,
232
+ })}
233
+ shorcut={order?.business?.address_notes}
234
+ TextStyle={styles.textLink}
235
+ onTextLayout={e => onTextLayout(e, 'businessAddressNotes')}
236
+ numberOfLines={isReadMore.businessAddressNotes ? 20 : 3}
237
+ />
238
+ </View>
239
+ {lengthMore.businessAddressNotes && (
240
+ <TouchableOpacity
241
+ onPress={() => setIsReadMore({ ...isReadMore, businessAddressNotes: !isReadMore.businessAddressNotes })}
242
+ >
243
+ <OText size={12} color={theme.colors.statusOrderBlue}>{isReadMore.businessAddressNotes ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
244
+ </TouchableOpacity>
245
+ )}
246
+ </>
225
247
  )}
226
248
  </OrderBusiness>
227
249
 
@@ -329,15 +351,17 @@ export const OrderContentComponent = (props: OrderContent) => {
329
351
  ios: `maps:0,0?q=${order?.customer?.address}`,
330
352
  android: `geo:0,0?q=${order?.customer?.address}`,
331
353
  })}
332
- onTextLayout={onTextLayout}
333
- numberOfLines={isReadMore ? 20 : 2}
354
+ onTextLayout={e => onTextLayout(e, 'customerAddress')}
355
+ numberOfLines={isReadMore.customerAddress ? 20 : 2}
334
356
  shorcut={order?.customer?.address}
335
357
  TextStyle={styles.textLink}
336
358
  />
337
359
  </View>
338
- {lengthMore && (
339
- <TouchableOpacity onPress={() => setIsReadMore(!isReadMore)}>
340
- <OText size={12} color={theme.colors.statusOrderBlue}>{isReadMore ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
360
+ {lengthMore.customerAddress && (
361
+ <TouchableOpacity
362
+ onPress={() => setIsReadMore({ ...isReadMore, customerAddress: !isReadMore.customerAddress })}
363
+ >
364
+ <OText size={12} color={theme.colors.statusOrderBlue}>{isReadMore.customerAddress ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
341
365
  </TouchableOpacity>
342
366
  )}
343
367
  </>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState, useCallback } from 'react';
2
2
  import {
3
3
  BusinessInformation as BusinessInformationController,
4
4
  useLanguage, useUtils, useConfig,
@@ -16,13 +16,16 @@ import {
16
16
  DivideView,
17
17
  MediaWrapper,
18
18
  } from './styles';
19
- import { StyleSheet, View } from 'react-native';
19
+ import { StyleSheet, View, TouchableOpacity } from 'react-native';
20
20
  import { BusinessInformationParams } from '../../types';
21
21
  import { GoogleMap } from '../GoogleMap';
22
22
  import { WebView } from 'react-native-webview';
23
23
  import { formatUrlVideo } from '../../utils'
24
24
  import { ScheduleAccordion } from '../ScheduleAccordion';
25
25
  import moment from 'moment';
26
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
27
+ const { useDeviceOrientation } = DeviceOrientationMethods
28
+
26
29
  const BusinessInformationUI = (props: BusinessInformationParams) => {
27
30
  const { businessState, businessSchedule, businessLocation } = props;
28
31
 
@@ -30,6 +33,11 @@ const BusinessInformationUI = (props: BusinessInformationParams) => {
30
33
  const [, t] = useLanguage();
31
34
  const [{ optimizeImage }] = useUtils();
32
35
  const [{ configs }] = useConfig()
36
+ const [orientationState] = useDeviceOrientation();
37
+
38
+ const [isReadMore, setIsReadMore] = useState(false)
39
+ const [lengthMore, setLengthMore] = useState(false)
40
+ const WIDTH_SCREEN = orientationState?.dimensions?.width
33
41
 
34
42
  const hideLocation = theme?.business_view?.components?.information?.components?.location?.hidden
35
43
  const hideSchedule = theme?.business_view?.components?.information?.components?.schedule?.hidden
@@ -73,6 +81,10 @@ const BusinessInformationUI = (props: BusinessInformationParams) => {
73
81
  return iAry;
74
82
  };
75
83
 
84
+ const onTextLayout = useCallback((e: any) => {
85
+ setLengthMore((e.nativeEvent.lines.length == 3 && e.nativeEvent.lines[2].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 3)
86
+ }, [])
87
+
76
88
  return (
77
89
  <BusinessInformationContainer>
78
90
  <WrapMainContent contentContainerStyle={{}}>
@@ -93,16 +105,36 @@ const BusinessInformationUI = (props: BusinessInformationParams) => {
93
105
  readOnly
94
106
  location={businessLocation.location}
95
107
  markerTitle={businessState?.business?.name}
108
+ businessZones={businessState?.business?.zones}
96
109
  />
97
110
  </WrapBusinessMap>
98
111
  )}
99
112
  </>
100
113
  )}
101
114
  {!hideAddress && (
102
- <OText size={12} mBottom={20}>
115
+ <OText size={12} mBottom={10}>
103
116
  {businessState?.business?.address}
104
117
  </OText>
105
118
  )}
119
+ {businessState?.business?.address_notes && (
120
+ <>
121
+ <OText
122
+ size={12}
123
+ mBottom={10}
124
+ numberOfLines={isReadMore ? 20 : 3}
125
+ onTextLayout={onTextLayout}
126
+ >
127
+ {businessState?.business?.address_notes}
128
+ </OText>
129
+ {lengthMore && (
130
+ <TouchableOpacity
131
+ onPress={() => setIsReadMore(!isReadMore)}
132
+ >
133
+ <OText size={12} mBottom={20} color={theme.colors.primary}>{isReadMore ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
134
+ </TouchableOpacity>
135
+ )}
136
+ </>
137
+ )}
106
138
  <DivideView />
107
139
  {!hideSchedule && (
108
140
  <>
@@ -163,9 +163,10 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
163
163
  if (product.ingredients?.length === 0 && product.extras.length === 0 && !product.inventoried && auth && isQuickAddProduct) {
164
164
  const isProductAddedToCart = currentCart?.products?.find((Cproduct: any) => Cproduct.id === product.id)
165
165
  const productQuantity = isProductAddedToCart?.quantity
166
+ const minimumPerOrder = product?.minimum_per_order || 1
166
167
  const addCurrentProduct = {
167
168
  ...product,
168
- quantity: 1
169
+ quantity: minimumPerOrder
169
170
  }
170
171
  const updateCurrentProduct = {
171
172
  name: product?.name,
@@ -569,6 +569,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
569
569
  {
570
570
  !businessId && !props.franchiseId && (
571
571
  <HighestRatedBusinesses
572
+ propsToFetch={props.propsToFetch}
572
573
  onBusinessClick={handleBusinessClick}
573
574
  navigation={navigation}
574
575
  favoriteIds={favoriteIds}
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
2
  import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView } from 'react-native';
3
3
  import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
4
4
  import Picker from 'react-native-country-picker-modal';
@@ -56,6 +56,8 @@ import { OrderSummary } from '../OrderSummary';
56
56
  import { getTypesText } from '../../utils';
57
57
  import { CartStoresListing } from '../CartStoresListing';
58
58
  import { PaymentOptionsWebView } from '../../../../../src/components/PaymentOptionsWebView';
59
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
60
+ const { useDeviceOrientation } = DeviceOrientationMethods
59
61
 
60
62
  const mapConfigs = {
61
63
  mapZoom: 16,
@@ -141,6 +143,10 @@ const CheckoutUI = (props: any) => {
141
143
  const [{ options, carts, loading }, { confirmCart }] = useOrder();
142
144
  const [validationFields] = useValidationFields();
143
145
  const [events] = useEvent()
146
+ const [orientationState] = useDeviceOrientation();
147
+ const [isReadMore, setIsReadMore] = useState(false)
148
+ const [lengthMore, setLengthMore] = useState(false)
149
+ const WIDTH_SCREEN = orientationState?.dimensions?.width
144
150
 
145
151
  const [errorCash, setErrorCash] = useState(false);
146
152
  const [userErrors, setUserErrors] = useState<any>([]);
@@ -367,6 +373,10 @@ const CheckoutUI = (props: any) => {
367
373
  }
368
374
  }, [cart?.paymethod_data])
369
375
 
376
+ const onTextLayout = useCallback((e: any) => {
377
+ setLengthMore((e.nativeEvent.lines.length == 3 && e.nativeEvent.lines[2].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 3)
378
+ }, [])
379
+
370
380
  return (
371
381
  <>
372
382
  <Container noPadding>
@@ -458,6 +468,25 @@ const CheckoutUI = (props: any) => {
458
468
  {businessDetails?.business?.address}
459
469
  </OText>
460
470
  )}
471
+ {businessDetails?.business?.address_notes && (
472
+ <>
473
+ <OText
474
+ size={12}
475
+ lineHeight={18}
476
+ numberOfLines={isReadMore ? 20 : 3}
477
+ onTextLayout={onTextLayout}
478
+ >
479
+ {businessDetails?.business?.address_notes}
480
+ </OText>
481
+ {lengthMore && (
482
+ <TouchableOpacity
483
+ onPress={() => setIsReadMore(!isReadMore)}
484
+ >
485
+ <OText size={12} color={theme.colors.primary}>{isReadMore ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
486
+ </TouchableOpacity>
487
+ )}
488
+ </>
489
+ )}
461
490
  </View>
462
491
  </>
463
492
  )}
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect, useRef } from 'react'
2
2
  import { Dimensions, StyleSheet, View, Platform } from 'react-native';
3
- import MapView, { PROVIDER_DEFAULT, PROVIDER_GOOGLE, Marker, Region, } from 'react-native-maps'
3
+ import MapView, { PROVIDER_DEFAULT, PROVIDER_GOOGLE, Marker, Region, Polygon, Circle } from 'react-native-maps'
4
4
  import Geocoder from 'react-native-geocoding';
5
5
  import { useLanguage, useConfig } from 'ordering-components/native'
6
6
  import { GoogleMapsParams } from '../../types';
@@ -19,7 +19,8 @@ export const GoogleMap = (props: GoogleMapsParams) => {
19
19
  setSaveLocation,
20
20
  handleToggleMap,
21
21
  locations,
22
- isIntGeoCoder
22
+ isIntGeoCoder,
23
+ businessZones
23
24
  } = props
24
25
 
25
26
  const [, t] = useLanguage()
@@ -44,6 +45,19 @@ export const GoogleMap = (props: GoogleMapsParams) => {
44
45
  ERROR_MAX_LIMIT_LOCATION: `Sorry, You can only set the position to ${maxLimitLocation}m`
45
46
  }
46
47
 
48
+ const units: any = {
49
+ mi: 1609,
50
+ km: 1000
51
+ }
52
+
53
+ const types: any = [1, 2, 5]
54
+
55
+ const fillStyles = {
56
+ fillColor: 'rgba(44, 123, 229, 0.3)',
57
+ strokeColor: 'rgba(44, 123, 229, 1)',
58
+ strokeWidth: 2
59
+ }
60
+
47
61
  const geocodePosition = (pos: { latitude: number, longitude: number }, isMovingRegion ?: boolean) => {
48
62
  Geocoder.from({
49
63
  latitude: pos.latitude,
@@ -230,6 +244,36 @@ export const GoogleMap = (props: GoogleMapsParams) => {
230
244
  title={markerTitle || t('YOUR_LOCATION', 'Your Location')}
231
245
  />
232
246
  )}
247
+ {businessZones?.length > 0 && businessZones.filter((item: any) => types.includes(item?.type)).map((businessZone: any, i: number) => (
248
+ <React.Fragment key={i}>
249
+ {businessZone?.type === 2 && Array.isArray(businessZone?.data) && (
250
+ <Polygon
251
+ coordinates={businessZone?.data.map((item: any) => ({ latitude: item.lat, longitude: item.lng}))}
252
+ fillColor={fillStyles.fillColor}
253
+ strokeColor={fillStyles.strokeColor}
254
+ strokeWidth={fillStyles.strokeWidth}
255
+ />
256
+ )}
257
+ {(businessZone.type === 1 && businessZone?.data?.center && businessZone?.data?.radio) && (
258
+ <Circle
259
+ center={{ latitude: businessZone?.data?.center.lat, longitude: businessZone?.data?.center.lng}}
260
+ radius={businessZone?.data.radio * 1000}
261
+ fillColor={fillStyles.fillColor}
262
+ strokeColor={fillStyles.strokeColor}
263
+ strokeWidth={fillStyles.strokeWidth}
264
+ />
265
+ )}
266
+ {(businessZone.type === 5 && businessZone?.data?.distance) && (
267
+ <Circle
268
+ center={{ latitude: businessZone?.data?.center.lat, longitude: businessZone?.data?.center.lng}}
269
+ radius={businessZone?.data.distance * units[businessZone?.data?.unit]}
270
+ fillColor={fillStyles.fillColor}
271
+ strokeColor={fillStyles.strokeColor}
272
+ strokeWidth={fillStyles.strokeWidth}
273
+ />
274
+ )}
275
+ </React.Fragment>
276
+ ))}
233
277
  </MapView>
234
278
  <Alert
235
279
  open={alertState.open}
@@ -176,7 +176,7 @@ export const ProductOptionsUI = (props: any) => {
176
176
  marginTop: 10
177
177
  },
178
178
  wrapperNavbar: {
179
- paddingHorizontal: 40,
179
+ paddingHorizontal: 30,
180
180
  paddingTop: 0,
181
181
  }
182
182
  });
@@ -613,7 +613,7 @@ export const ProductOptionsUI = (props: any) => {
613
613
  >
614
614
  {(String(img).includes('http') || typeof img === 'number') ? (
615
615
  <FastImage
616
- style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1, aspectRatio: 16 / 9 }}
616
+ style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1, aspectRatio: 4 / 3 }}
617
617
  source={typeof img !== 'number' ? {
618
618
  uri: optimizeImage(img, 'h_1024,c_limit'),
619
619
  priority: FastImage.priority.normal,
@@ -690,7 +690,7 @@ export const ProductOptionsUI = (props: any) => {
690
690
  )}
691
691
  </WrapHeader>
692
692
  <ProductSummary
693
- ph={isChewLayout ? 20 : 40}
693
+ ph={isChewLayout ? 20 : 30}
694
694
  onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}
695
695
  >
696
696
  <ProductTitle>
@@ -792,7 +792,7 @@ export const ProductOptionsUI = (props: any) => {
792
792
  marginBottom: 20,
793
793
  borderBottomWidth: 1,
794
794
  borderBottomColor: theme.colors.border,
795
- marginHorizontal: isChewLayout ? 20 : 30,
795
+ marginHorizontal: 20,
796
796
  backgroundColor: theme.colors.backgroundPage,
797
797
  }}
798
798
  >
@@ -866,7 +866,7 @@ export const ProductOptionsUI = (props: any) => {
866
866
  </>
867
867
  ) : (
868
868
  <ProductEditions
869
- style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}
869
+ style={{ paddingHorizontal: isChewLayout ? 20 : 30 }}
870
870
  onLayout={(event: any) => {
871
871
  setEditionsLayoutY(event.nativeEvent.layout?.y)
872
872
  }}
@@ -70,7 +70,7 @@ export const ProductActions = styled.View`
70
70
  position: absolute;
71
71
  bottom: 0px;
72
72
  padding-top: ${(props: any) => props.ios ? '20px' : '0'};
73
- padding-horizontal: 40px;
73
+ padding-horizontal: 30px;
74
74
  padding-vertical: 20px;
75
75
  width: 100%;
76
76
  flex-direction: ${(props: any) => props.isColumn ? 'column' : 'row'};
@@ -86,8 +86,8 @@ export const ProductOptionSubOptionUI = (props: any) => {
86
86
  {suboption?.name}
87
87
  </OText>
88
88
  </IconControl>
89
- <QuantityControl>
90
- {option?.allow_suboption_quantity && state?.selected && (
89
+ {option?.allow_suboption_quantity && state?.selected && (
90
+ <QuantityControl>
91
91
  <>
92
92
  <Checkbox disabled={disabled || state.quantity === 0} onPress={decrement}>
93
93
  <IconAntDesign
@@ -107,10 +107,10 @@ export const ProductOptionSubOptionUI = (props: any) => {
107
107
  />
108
108
  </Checkbox>
109
109
  </>
110
- )}
111
- </QuantityControl>
112
- <PositionControl>
113
- {option?.with_half_option && state?.selected && (
110
+ </QuantityControl>
111
+ )}
112
+ {option?.with_half_option && state?.selected && (
113
+ <PositionControl>
114
114
  <>
115
115
  <Circle disabled={disabled} onPress={() => changePosition('left')}>
116
116
  <OIcon
@@ -138,10 +138,10 @@ export const ProductOptionSubOptionUI = (props: any) => {
138
138
  />
139
139
  </Circle>
140
140
  </>
141
- )}
142
- </PositionControl>
141
+ </PositionControl>
142
+ )}
143
143
  {price > 0 && (
144
- <OText size={12} lineHeight={18} color={theme.colors.textSecondary} style={{ paddingRight: 10 }}>
144
+ <OText size={12} lineHeight={18} color={theme.colors.textSecondary} style={{width: 70, maxWidth: 70}}>
145
145
  + {parsePrice(price)}
146
146
  </OText>
147
147
  )}
@@ -18,14 +18,12 @@ export const QuantityControl = styled.View`
18
18
  flex-direction: row;
19
19
  align-items: center;
20
20
  justify-content: space-between;
21
- margin-right: 5px;
22
- width: 55px;
21
+ width: 62px;
23
22
  `
24
23
 
25
24
  export const PositionControl = styled.View`
26
25
  flex-direction: row;
27
26
  align-items: center;
28
- margin-right: 5px;
29
27
  `
30
28
 
31
29
  export const Checkbox = styled.TouchableOpacity`
@@ -632,7 +632,8 @@ export interface GoogleMapsParams {
632
632
  locations?: Array<any>,
633
633
  setSaveLocation?: (val: boolean) => void,
634
634
  handleToggleMap?: () => void,
635
- isIntGeoCoder: boolean
635
+ isIntGeoCoder: boolean,
636
+ businessZones?: any
636
637
  }
637
638
 
638
639
  export interface HelpParams {