ordering-ui-react-native 0.23.99 → 0.24.0

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.23.99",
3
+ "version": "0.24.0",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -84,6 +84,7 @@ const CartUI = (props: any) => {
84
84
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
85
85
  ? JSON.parse(configs?.driver_tip_options?.value) || []
86
86
  : configs?.driver_tip_options?.value || []
87
+ const allowDriverTipPickup = configs?.driver_tip_allowed_at_pickup?.value === '1' && orderState?.options?.type === 2
87
88
 
88
89
  const momentFormatted = !orderState?.option?.moment
89
90
  ? t('RIGHT_NOW', 'Right Now')
@@ -465,7 +466,7 @@ const CartUI = (props: any) => {
465
466
  {!isMultiCheckout &&
466
467
  cart &&
467
468
  cart?.valid &&
468
- orderState?.options?.type === 1 &&
469
+ (orderState?.options?.type === 1 || allowDriverTipPickup) &&
469
470
  cart?.status !== 2 &&
470
471
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
471
472
  driverTipsOptions && driverTipsOptions?.length > 0 &&
@@ -71,6 +71,8 @@ const mapConfigs = {
71
71
  }
72
72
  };
73
73
 
74
+ const driverTipsTypes = [1, 2]
75
+
74
76
  const manageErrorsToShow = (array = []) => {
75
77
  let stringError = ''
76
78
  const list = Array.isArray(array) ? array : Object.values(array)
@@ -184,7 +186,7 @@ const CheckoutUI = (props: any) => {
184
186
  const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
185
187
 
186
188
  const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field: any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
187
- const guestCheckoutDriveTip = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === 1 && field?.validation_field?.code === 'driver_tip'), [JSON.stringify(checkoutFields), options])
189
+ const guestCheckoutDriveTip = useMemo(() => checkoutFields?.find((field: any) => driverTipsTypes.includes(field.order_type_id) && field?.validation_field?.code === 'driver_tip'), [JSON.stringify(checkoutFields), options])
188
190
  const guestCheckoutComment = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [JSON.stringify(checkoutFields), options])
189
191
  const guestCheckoutCoupon = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'coupon'), [JSON.stringify(checkoutFields), options])
190
192
  const guestCheckoutZipcode = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'zipcode'), [JSON.stringify(checkoutFields), options])
@@ -213,9 +215,9 @@ const CheckoutUI = (props: any) => {
213
215
  return acc = acc + item?.summary?.tax
214
216
  return acc = acc
215
217
  }, cart?.subtotal)
216
-
218
+ const allowDriverTipPickup = configs?.driver_tip_allowed_at_pickup?.value === '1' && options?.type === 2
217
219
  const validateCommentsCartField = (guestCheckoutComment?.enabled && (user?.guest_id ? guestCheckoutComment?.required_with_guest : guestCheckoutComment?.required)) && (cart?.comment === null || cart?.comment?.trim().length === 0)
218
- const validateDriverTipField = options.type === 1 && (guestCheckoutDriveTip?.enabled && (user?.guest_id ? guestCheckoutDriveTip?.required_with_guest : guestCheckoutDriveTip?.required)) && (Number(cart?.driver_tip) <= 0)
220
+ const validateDriverTipField = (options.type === 1 || allowDriverTipPickup) && (guestCheckoutDriveTip?.enabled && (user?.guest_id ? guestCheckoutDriveTip?.required_with_guest : guestCheckoutDriveTip?.required)) && (Number(cart?.driver_tip) <= 0)
219
221
  const validateCouponField = (guestCheckoutCoupon?.enabled && (user?.guest_id ? guestCheckoutCoupon?.required_with_guest : guestCheckoutCoupon?.required)) && !cart?.offers?.some((offer: any) => offer?.type === 2)
220
222
  const validateZipcodeCard = (guestCheckoutZipcode?.enabled && (user?.guest_id ? guestCheckoutZipcode?.required_with_guest : guestCheckoutZipcode?.required)) && paymethodSelected?.gateway === 'stripe' && paymethodSelected?.data?.card && !paymethodSelected?.data?.card?.zipcode
221
223
 
@@ -236,7 +238,7 @@ const CheckoutUI = (props: any) => {
236
238
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
237
239
  ? JSON.parse(configs?.driver_tip_options?.value) || []
238
240
  : configs?.driver_tip_options?.value || []
239
- const driverTipsField = !cartState.loading && cart && cart?.business_id && options.type === 1 && cart?.status !== 2 && (guestCheckoutDriveTip?.enabled) && driverTipsOptions.length > 0
241
+ const driverTipsField = !cartState.loading && cart && cart?.business_id && (options.type === 1 || allowDriverTipPickup) && cart?.status !== 2 && (guestCheckoutDriveTip?.enabled) && driverTipsOptions.length > 0
240
242
 
241
243
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
242
244
 
@@ -103,6 +103,7 @@ const MultiCheckoutUI = (props: any) => {
103
103
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
104
104
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
105
105
  const isMultiDriverTips = configs?.checkout_multi_business_enabled?.value === '1'
106
+ const allowDriverTipPickup = configs?.driver_tip_allowed_at_pickup?.value === '1' && options?.type === 2
106
107
  const isGuestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
107
108
  const walletCarts = (Object.values(carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && cart?.wallets) || null) || []
108
109
  const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
@@ -494,7 +495,7 @@ const MultiCheckoutUI = (props: any) => {
494
495
  )}
495
496
  {
496
497
  isMultiDriverTips &&
497
- options?.type === 1 &&
498
+ (options?.type === 1 || allowDriverTipPickup) &&
498
499
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
499
500
  openCarts.every((cart: any) => cart.business_id && cart.status !== 2) &&
500
501
  driverTipsOptions && driverTipsOptions?.length > 0 &&