ordering-ui-react-native 0.22.59 → 0.22.61

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.59",
3
+ "version": "0.22.61",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useCallback, useRef } from 'react';
1
+ import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react';
2
2
  import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView, Keyboard, BackHandler, SafeAreaView } from 'react-native';
3
3
  import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
4
4
  import NativeStripeSdk from '@stripe/stripe-react-native/src/NativeStripeSdk'
@@ -180,7 +180,11 @@ const CheckoutUI = (props: any) => {
180
180
  const containerRef = useRef<any>()
181
181
  const cardsMethods = ['credomatic']
182
182
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
183
- const notFields = ['coupon', 'mobile_phone', 'address', 'zipcode', 'address_notes']
183
+ const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
184
+
185
+ const guestCheckoutDriveTip = checkoutFieldsState?.fields?.find(field => field.order_type_id === 1 && field?.validation_field?.code === 'driver_tip')
186
+ const guestCheckoutComment = useMemo(() => checkoutFieldsState?.fields?.find(field => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [checkoutFieldsState, options])
187
+
184
188
  const placeSpotTypes = [3, 4, 5]
185
189
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
186
190
  const businessConfigs = businessDetails?.business?.configs ?? []
@@ -205,7 +209,9 @@ const CheckoutUI = (props: any) => {
205
209
  return acc = acc
206
210
  }, cart?.subtotal)
207
211
 
208
- const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
212
+ const validateCommentsCartField = (!user?.guest_id ? (validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required) : (guestCheckoutComment?.enabled && guestCheckoutComment?.required_with_guest)) && (cart?.comment === null || cart?.comment?.trim().length === 0)
213
+ const validateDriverTipField = options.type === 1 && (!user?.guest_id ? (validationFields?.fields?.checkout?.driver_tip?.enabled && validationFields?.fields?.checkout?.driver_tip?.required) : (guestCheckoutDriveTip?.enabled && guestCheckoutDriveTip?.required_with_guest)) && (Number(cart?.driver_tip) <= 0)
214
+
209
215
  const validateZipcodeCard = validationFields?.fields?.card?.zipcode?.enabled &&
210
216
  validationFields?.fields?.card?.zipcode?.required &&
211
217
  paymethodSelected?.data?.card &&
@@ -220,8 +226,9 @@ const CheckoutUI = (props: any) => {
220
226
  validationFields?.fields?.checkout?.driver_tip?.required &&
221
227
  (Number(cart?.driver_tip) <= 0)) ||
222
228
  (validateCommentsCartField) ||
223
- (validateZipcodeCard)
224
- || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
229
+ (validateDriverTipField && !isGiftCardCart) ||
230
+ (validateZipcodeCard) ||
231
+ (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
225
232
 
226
233
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
227
234
  ? JSON.parse(configs?.driver_tip_options?.value) || []
@@ -997,7 +1004,15 @@ const CheckoutUI = (props: any) => {
997
1004
  {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
998
1005
  </OText>
999
1006
  )}
1000
-
1007
+ {validateDriverTipField && !isGiftCardCart &&
1008
+ (
1009
+ <OText
1010
+ color={theme.colors.error}
1011
+ size={12}
1012
+ >
1013
+ {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
1014
+ </OText>
1015
+ )}
1001
1016
  {validateCommentsCartField && (
1002
1017
  <OText
1003
1018
  color={theme.colors.error}
@@ -8,7 +8,6 @@ import Alert from '../../../../../src/providers/AlertProvider'
8
8
  import { OIcon } from '../shared';
9
9
 
10
10
  export const GoogleMap = (props: GoogleMapsParams) => {
11
-
12
11
  const {
13
12
  location,
14
13
  handleChangeAddressMap,
@@ -23,7 +22,8 @@ export const GoogleMap = (props: GoogleMapsParams) => {
23
22
  businessZones,
24
23
  delta,
25
24
  autoCompleteAddress,
26
- setAutoCompleteAddress
25
+ setAutoCompleteAddress,
26
+ manualZoom
27
27
  } = props
28
28
 
29
29
  const [, t] = useLanguage()
@@ -217,11 +217,12 @@ export const GoogleMap = (props: GoogleMapsParams) => {
217
217
 
218
218
  useEffect(() => {
219
219
  const interval = setInterval(() => {
220
- if (mapRef.current && locations) {
220
+ if (mapRef.current && locations && !manualZoom) {
221
221
  fitAllMarkers()
222
222
  }
223
223
  }, 1000)
224
224
  if (locations) {
225
+ fitAllMarkers()
225
226
  SETMARKERS(locations)
226
227
  }
227
228
  return () => clearInterval(interval)
@@ -749,6 +749,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
749
749
  }
750
750
  locations={parsedLocations}
751
751
  readOnly
752
+ manualZoom
752
753
  />
753
754
  </Map>
754
755
  )}
@@ -639,6 +639,7 @@ export interface GoogleMapsParams {
639
639
  delta?: number
640
640
  setAutoCompleteAddress?: (val: boolean) => void,
641
641
  autoCompleteAddress?: boolean,
642
+ manualZoom?: boolean
642
643
  }
643
644
 
644
645
  export interface HelpParams {