ordering-ui-react-native 0.22.56 → 0.22.58

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.22.56",
3
+ "version": "0.22.58",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -31,6 +31,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
31
31
  notShowCustomerPhone,
32
32
  orderTitle,
33
33
  appTitle,
34
+ isLoadingOrder
34
35
  } = props;
35
36
 
36
37
  const [, t] = useLanguage();
@@ -277,7 +278,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
277
278
  }
278
279
 
279
280
  bodyToSend.id = orderId;
280
- handleUpdateOrder && handleUpdateOrder(bodyToSend.status, bodyToSend);
281
+ handleUpdateOrder?.(bodyToSend.status, bodyToSend);
281
282
  };
282
283
 
283
284
  useEffect(() => {
@@ -517,7 +518,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
517
518
  ...styles.bottomParent,
518
519
  marginBottom: Platform.OS === 'ios'
519
520
  ? 30 : (keyboardState.height === 0)
520
- ? isPage ? 0 : 30
521
+ ? isPage ? 0 : 40
521
522
  : keyboardState.height - (isPage ? 20 : -10)
522
523
  }}
523
524
  >
@@ -529,7 +530,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
529
530
  style={{ borderRadius: 7, height: 45 }}
530
531
  parentStyle={{ width: '100%' }}
531
532
  textStyle={{ color: '#FFF', fontSize: 18 }}
532
- isDisabled={showTextArea && !comments}
533
+ isDisabled={(showTextArea && !comments) || isLoadingOrder}
533
534
  onClick={() => handleAcceptOrReject()}
534
535
  />
535
536
  </View>
@@ -428,6 +428,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
428
428
  forceUpdate && handleViewActionOrder && handleViewActionOrder(forceUpdate === 9 ? 'forcePickUp' : 'forceDelivery')
429
429
  }, [forceUpdate])
430
430
 
431
+ useEffect(() => {
432
+ if (!!props.order?.error || props.order?.error?.length > 0) {
433
+ showToast(ToastType.Error,
434
+ props.order?.error?.[0] ||
435
+ props.order?.error ||
436
+ t('NETWORK_ERROR', 'Network Error'),
437
+ 5000)
438
+ }
439
+ }, [props.order?.error])
440
+
431
441
  const styles = StyleSheet.create({
432
442
  btnPickUp: {
433
443
  borderWidth: 0,
@@ -478,7 +488,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
478
488
  isOrderGroup={isOrderGroup}
479
489
  lastOrder={lastOrder}
480
490
  />
481
- {(order?.status === 8 || order?.status === 18) && order?.delivery_type === 1 && (
491
+ {(order?.status === 8 || order?.status === 18) && order?.delivery_type === 1 && !props.order?.loading && (
482
492
  <Pickup>
483
493
  <OButton
484
494
  style={styles.btnPickUp}
@@ -491,7 +501,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
491
501
  />
492
502
  </Pickup>
493
503
  )}
494
- {order?.status === 3 && order?.delivery_type === 1 && !isHideRejectButtons && isEnabledOrderNotReady && (
504
+ {order?.status === 3 && order?.delivery_type === 1 && !isHideRejectButtons && isEnabledOrderNotReady && !props.order?.loading && (
495
505
  <View style={{ paddingVertical: 20, marginBottom: 20 }}>
496
506
  <OButton
497
507
  style={styles.btnPickUp}
@@ -613,6 +623,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
613
623
  )}
614
624
  {showFloatButtonsAcceptOrReject[order?.status] && (
615
625
  <FloatingButton
626
+ disabled={props.order?.loading}
616
627
  btnText={t('REJECT', 'Reject')}
617
628
  isSecondaryBtn={false}
618
629
  secondButtonClick={() => hideTimer ? handleChangeOrderStatus && handleChangeOrderStatus(8) : (order?.isLogistic && (order?.order_group || logisticOrderStatus.includes(order?.status))) ? handleAcceptLogisticOrder(order) : handleViewActionOrder('accept')}
@@ -687,6 +698,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
687
698
  actions={actions}
688
699
  orderTitle={orderTitle}
689
700
  appTitle={appTitle}
701
+ isLoadingOrder={props.order?.loading}
690
702
  />
691
703
  </OModal>
692
704
  )}
@@ -230,7 +230,7 @@ export const OrderContentComponent = (props: OrderContent) => {
230
230
  )}
231
231
  {!!order?.business?.location && order?.customer?.location && (
232
232
  <OText>
233
- {t('DISTANCE_TO_THE_BUSINESS', 'Distance to the business')}: {transformDistance(calculateDistance(order?.business?.location, { latitude: order?.customer?.location?.lat, longitude: order?.customer?.location?.lng }), distanceUnit)} {t(distanceUnit.toUpperCase(), distanceUnit)}
233
+ {t('DISTANCE_TO_THE_BUSINESS', 'Distance to the business')}: {transformDistance(calculateDistance(order?.business?.location, { latitude: order?.customer?.location?.lat, longitude: order?.customer?.location?.lng }), distanceUnit)} {t(distanceUnit?.toUpperCase?.(), distanceUnit)}
234
234
  </OText>
235
235
  )}
236
236
  {!!order?.business?.address_notes && (
@@ -412,7 +412,7 @@ export const OrderContentComponent = (props: OrderContent) => {
412
412
  <View style={{ marginTop: 10 }}>
413
413
  {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
414
414
  <OText>
415
- {t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}
415
+ {t(order?.delivery_option?.name?.toUpperCase?.()?.replace(/ /g, '_'), order?.delivery_option?.name)}
416
416
  </OText>
417
417
  )}
418
418
  </View>
@@ -474,7 +474,7 @@ export const OrderContentComponent = (props: OrderContent) => {
474
474
  <Table key={offer.id}>
475
475
  <OSRow>
476
476
  <OText mBottom={4}>
477
- {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
477
+ {t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)}
478
478
  {offer.rate_type === 1 && (
479
479
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
480
480
  )}
@@ -520,7 +520,7 @@ export const OrderContentComponent = (props: OrderContent) => {
520
520
  <Table key={tax.id}>
521
521
  <OSRow>
522
522
  <OText mBottom={4}>
523
- {t(tax?.name?.toUpperCase()?.replace(/ /g, '_'), tax?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
523
+ {t(tax?.name?.toUpperCase?.()?.replace(/ /g, '_'), tax?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
524
524
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
525
525
  </OText>
526
526
  </OSRow>
@@ -533,7 +533,7 @@ export const OrderContentComponent = (props: OrderContent) => {
533
533
  <Table key={fee.id}>
534
534
  <OSRow>
535
535
  <OText mBottom={4}>
536
- {t(fee?.name?.toUpperCase()?.replace(/ /g, '_'), fee?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
536
+ {t(fee?.name?.toUpperCase?.()?.replace(/ /g, '_'), fee?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
537
537
  ({fee?.fixed > 0 && `${parsePrice(fee?.fixed, { currency: order?.currency })} + `}{fee.percentage}%){' '}
538
538
  </OText>
539
539
  </OSRow>
@@ -546,7 +546,7 @@ export const OrderContentComponent = (props: OrderContent) => {
546
546
  <Table key={offer.id}>
547
547
  <OSRow>
548
548
  <OText mBottom={4}>
549
- {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
549
+ {t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)}
550
550
  {offer.rate_type === 1 && (
551
551
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
552
552
  )}
@@ -574,7 +574,7 @@ export const OrderContentComponent = (props: OrderContent) => {
574
574
  <Table key={offer.id}>
575
575
  <OSRow>
576
576
  <OText mBottom={4}>
577
- {t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
577
+ {t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)}
578
578
  {offer.rate_type === 1 && (
579
579
  <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
580
580
  )}
@@ -643,9 +643,9 @@ export const OrderContentComponent = (props: OrderContent) => {
643
643
  {event?.wallet_event
644
644
  ? walletName[event?.wallet_event?.wallet?.type]?.name
645
645
  : event?.paymethod?.gateway
646
- ? t(event?.paymethod?.gateway?.toUpperCase(), event?.paymethod?.name)
646
+ ? t(event?.paymethod?.gateway?.toUpperCase?.(), event?.paymethod?.name)
647
647
  : order?.paymethod?.id === event?.paymethod_id
648
- ? t(order?.paymethod?.gateway?.toUpperCase(), order?.paymethod?.name)
648
+ ? t(order?.paymethod?.gateway?.toUpperCase?.(), order?.paymethod?.name)
649
649
  : ''}
650
650
  </OText>
651
651
  </View>
@@ -597,6 +597,7 @@ export interface AcceptOrRejectOrderParams {
597
597
  isPage?: boolean
598
598
  navigation?: any
599
599
  route?: any
600
+ isLoadingOrder?: boolean
600
601
  }
601
602
 
602
603
  export interface MapViewParams {
@@ -133,6 +133,7 @@ const AddressFormUI = (props: AddressFormParams) => {
133
133
  const [configState] = useConfig();
134
134
  const [orderState] = useOrder();
135
135
  const { handleSubmit, errors, control, setValue } = useForm();
136
+ const [autoCompleteAddress, setAutoCompleteAddress] = useState(false)
136
137
 
137
138
  const [toggleMap, setToggleMap] = useState(false);
138
139
  const [alertState, setAlertState] = useState<{
@@ -572,6 +573,7 @@ const AddressFormUI = (props: AddressFormParams) => {
572
573
  placeholder={t('ADD_ADDRESS', 'Add a address')}
573
574
  onPress={(data, details: any) => {
574
575
  handleChangeAddress(data, details);
576
+ setAutoCompleteAddress(true);
575
577
  }}
576
578
  query={{
577
579
  key: googleMapsApiKey,
@@ -586,6 +588,7 @@ const AddressFormUI = (props: AddressFormParams) => {
586
588
  target: { name: 'address', value: text },
587
589
  });
588
590
  setValue('address', text);
591
+ setAutoCompleteAddress(true)
589
592
  }
590
593
  setIsFirstTime(false);
591
594
  setAddressEditing(text.length == 0);
@@ -673,6 +676,8 @@ const AddressFormUI = (props: AddressFormParams) => {
673
676
  setSaveLocation={setSaveMapLocation}
674
677
  handleToggleMap={handleToggleMap}
675
678
  isIntGeoCoder
679
+ setAutoCompleteAddress={setAutoCompleteAddress}
680
+ autoCompleteAddress={autoCompleteAddress}
676
681
  />
677
682
  </GoogleMapContainer>
678
683
  </View>
@@ -21,7 +21,9 @@ export const GoogleMap = (props: GoogleMapsParams) => {
21
21
  locations,
22
22
  isIntGeoCoder,
23
23
  businessZones,
24
- delta
24
+ delta,
25
+ autoCompleteAddress,
26
+ setAutoCompleteAddress
25
27
  } = props
26
28
 
27
29
  const [, t] = useLanguage()
@@ -59,7 +61,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
59
61
  strokeWidth: 2
60
62
  }
61
63
 
62
- const geocodePosition = (pos: { latitude: number, longitude: number }, isMovingRegion ?: boolean) => {
64
+ const geocodePosition = (pos: { latitude: number, longitude: number }, isMovingRegion?: boolean) => {
63
65
  Geocoder.from({
64
66
  latitude: pos.latitude,
65
67
  longitude: pos.longitude
@@ -84,7 +86,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
84
86
  }
85
87
  handleChangeAddressMap && handleChangeAddressMap(address, details)
86
88
  setSaveLocation && setSaveLocation(false)
87
- if(!isMovingRegion){
89
+ if (!isMovingRegion) {
88
90
  handleToggleMap && handleToggleMap()
89
91
  }
90
92
  } else {
@@ -95,7 +97,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
95
97
  })
96
98
  }
97
99
 
98
- const validateResult = (curPos: { latitude: number, longitude: number }) => {
100
+ const validateResult = (curPos: any) => {
99
101
  const loc1 = center
100
102
  const loc2 = curPos
101
103
  const distance = calculateDistance(loc1, loc2)
@@ -103,25 +105,33 @@ export const GoogleMap = (props: GoogleMapsParams) => {
103
105
  if (!maxLimitLocation) {
104
106
  geocodePosition(curPos)
105
107
  setMarkerPosition(curPos)
106
- setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
108
+ if (!autoCompleteAddress) {
109
+ setRegion({ longitude: curPos?.longitude || 0, latitude: curPos?.latitude || 0, latitudeDelta: curPos?.latitudeDelta || 0.0010, longitudeDelta: curPos?.longitudeDelta || (delta ?? 0.0010) * ASPECT_RATIO })
110
+ } else {
111
+ setRegion({ longitude: curPos?.longitude, latitude: curPos?.latitude, latitudeDelta: delta ?? 0.0010, longitudeDelta: (delta ?? 0.0010) * ASPECT_RATIO })
112
+ }
107
113
  return
108
114
  }
109
115
 
110
116
  const _maxLimitLocation = typeof maxLimitLocation === 'string' ? parseInt(maxLimitLocation, 10) : maxLimitLocation
111
117
 
112
118
  if (distance <= _maxLimitLocation) {
113
- if (!aproxEqual(curPos.latitude, center.lat) || !aproxEqual(curPos.longitude, center.lng)){
119
+ if (!aproxEqual(curPos?.latitude, center.lat) || !aproxEqual(curPos?.longitude, center.lng)) {
114
120
  geocodePosition(curPos, true)
115
121
  }
116
122
  setMarkerPosition(curPos)
117
- setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
123
+ if (!autoCompleteAddress) {
124
+ setRegion({ longitude: curPos?.longitude || 0, latitude: curPos?.latitude || 0, latitudeDelta: curPos?.latitudeDelta || 0.0010, longitudeDelta: curPos?.longitudeDelta || (delta ?? 0.0010) * ASPECT_RATIO })
125
+ } else {
126
+ setRegion({ longitude: curPos?.longitude, latitude: curPos?.latitude, latitudeDelta: delta ?? 0.0010, longitudeDelta: (delta ?? 0.0010) * ASPECT_RATIO })
127
+ }
118
128
  } else {
119
129
  setMapErrors && setMapErrors('ERROR_MAX_LIMIT_LOCATION')
120
130
  setMarkerPosition({ latitude: center.lat, longitude: center.lng })
121
131
  }
122
132
  }
123
133
 
124
- const aproxEqual = (n1 : number, n2 : number, epsilon = 0.000001) => {
134
+ const aproxEqual = (n1: number, n2: number, epsilon = 0.000001) => {
125
135
  return Math.abs(n1 - n2) < epsilon
126
136
  }
127
137
 
@@ -182,11 +192,21 @@ export const GoogleMap = (props: GoogleMapsParams) => {
182
192
  }, [isIntGeoCoder])
183
193
 
184
194
  useEffect(() => {
185
- mapRef.current.animateToRegion({
186
- ...region,
195
+ const regionConfig = {
187
196
  latitude: location?.lat,
188
197
  longitude: location?.lng,
189
- })
198
+ latitudeDelta: delta ?? 0.0010,
199
+ longitudeDelta: (delta ?? 0.0010) * ASPECT_RATIO
200
+ }
201
+
202
+ mapRef.current.animateToRegion(autoCompleteAddress
203
+ ? regionConfig
204
+ : { ...region, ...regionConfig }
205
+ )
206
+
207
+ if (autoCompleteAddress) {
208
+ setAutoCompleteAddress && setAutoCompleteAddress(false)
209
+ }
190
210
  }, [location])
191
211
 
192
212
  useEffect(() => {
@@ -213,7 +233,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
213
233
  provider={PROVIDER_GOOGLE}
214
234
  initialRegion={region}
215
235
  style={styles.map}
216
- onRegionChangeComplete={!readOnly ? (coordinates) => handleChangeRegion(coordinates) : () => { }}
236
+ onRegionChangeComplete={!readOnly ? (coordinates) => { handleChangeRegion(coordinates) } : () => { }}
217
237
  zoomTapEnabled
218
238
  zoomEnabled
219
239
  zoomControlEnabled
@@ -249,7 +269,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
249
269
  <React.Fragment key={i}>
250
270
  {businessZone?.type === 2 && Array.isArray(businessZone?.data) && (
251
271
  <Polygon
252
- coordinates={businessZone?.data.map((item: any) => ({ latitude: item.lat, longitude: item.lng}))}
272
+ coordinates={businessZone?.data.map((item: any) => ({ latitude: item.lat, longitude: item.lng }))}
253
273
  fillColor={fillStyles.fillColor}
254
274
  strokeColor={fillStyles.strokeColor}
255
275
  strokeWidth={fillStyles.strokeWidth}
@@ -257,7 +277,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
257
277
  )}
258
278
  {(businessZone.type === 1 && businessZone?.data?.center && businessZone?.data?.radio) && (
259
279
  <Circle
260
- center={{ latitude: businessZone?.data?.center.lat, longitude: businessZone?.data?.center.lng}}
280
+ center={{ latitude: businessZone?.data?.center.lat, longitude: businessZone?.data?.center.lng }}
261
281
  radius={businessZone?.data.radio * 1000}
262
282
  fillColor={fillStyles.fillColor}
263
283
  strokeColor={fillStyles.strokeColor}
@@ -266,7 +286,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
266
286
  )}
267
287
  {(businessZone.type === 5 && businessZone?.data?.distance) && (
268
288
  <Circle
269
- center={{ latitude: center.lat, longitude: center.lng}}
289
+ center={{ latitude: center.lat, longitude: center.lng }}
270
290
  radius={businessZone?.data.distance * units[businessZone?.data?.unit]}
271
291
  fillColor={fillStyles.fillColor}
272
292
  strokeColor={fillStyles.strokeColor}
@@ -275,7 +295,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
275
295
  )}
276
296
  </React.Fragment>
277
297
  ))}
278
- </MapView>
298
+ </MapView >
279
299
  <Alert
280
300
  open={alertState.open}
281
301
  onAccept={closeAlert}
@@ -630,6 +630,7 @@ const LoginFormUI = (props: LoginParams) => {
630
630
  />
631
631
  )
632
632
  }
633
+ autoCapitalize='none'
633
634
  value={value}
634
635
  forwardRef={passwordRef}
635
636
  onChange={(val: any) => onChange(val)}
@@ -835,6 +835,7 @@ const SignupFormUI = (props: SignupParams) => {
835
835
  />
836
836
  )
837
837
  }
838
+ autoCapitalize='none'
838
839
  value={value}
839
840
  onChange={(val: any) => onChange(val)}
840
841
  returnKeyType="done"
@@ -607,7 +607,7 @@ export interface UpsellingProductsParams {
607
607
  business?: any;
608
608
  businessId?: number;
609
609
  cartProducts?: Array<any>;
610
- handleUpsellingPage: (cart ?: any) => void;
610
+ handleUpsellingPage: (cart?: any) => void;
611
611
  openUpselling: boolean;
612
612
  canOpenUpselling?: boolean;
613
613
  setCanOpenUpselling?: (value: any) => void;
@@ -637,6 +637,8 @@ export interface GoogleMapsParams {
637
637
  isIntGeoCoder: boolean,
638
638
  businessZones?: any
639
639
  delta?: number
640
+ setAutoCompleteAddress?: (val: boolean) => void,
641
+ autoCompleteAddress?: boolean,
640
642
  }
641
643
 
642
644
  export interface HelpParams {