ordering-ui-react-native 0.16.57-release → 0.16.58-release

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.57-release",
3
+ "version": "0.16.58-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -41,7 +41,10 @@ const CartUI = (props: any) => {
41
41
  commentState,
42
42
  onNavigationRedirect,
43
43
  handleRemoveOfferClick,
44
- isMultiCheckout
44
+ isMultiCheckout,
45
+ hideDeliveryFee,
46
+ hideDriverTip,
47
+ showGeneralBtn
45
48
  } = props
46
49
 
47
50
  const theme = useTheme();
@@ -191,6 +194,26 @@ const CartUI = (props: any) => {
191
194
 
192
195
  return (
193
196
  <CContainer>
197
+ {showGeneralBtn && cart?.valid_products &&(
198
+ <CheckoutAction style={{ marginTop: 0 }}>
199
+ <OButton
200
+ text={(subtotalWithTaxes >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
201
+ !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
202
+ ) : !cart?.valid_address ? (
203
+ `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
204
+ ) : (
205
+ `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
206
+ )}
207
+ bgColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
208
+ isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
209
+ borderColor={theme.colors.primary}
210
+ imgRightSrc={null}
211
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
212
+ onClick={() => handleUpsellingPage()}
213
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
214
+ />
215
+ </CheckoutAction>
216
+ )}
194
217
  {openUpselling && (
195
218
  <UpsellingProducts
196
219
  handleUpsellingPage={handleUpsellingPage}
@@ -336,7 +359,7 @@ const CartUI = (props: any) => {
336
359
  </OSTable>
337
360
  ))
338
361
  }
339
- {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
362
+ {orderState?.options?.type === 1 && cart?.delivery_price > 0 && !hideDeliveryFee && (
340
363
  <OSTable>
341
364
  <OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
342
365
  <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price)}</OText>
@@ -363,7 +386,7 @@ const CartUI = (props: any) => {
363
386
  </OSTable>
364
387
  ))
365
388
  }
366
- {cart?.driver_tip > 0 && (
389
+ {cart?.driver_tip > 0 && !hideDriverTip && (
367
390
  <OSTable>
368
391
  <OText size={12} lineHeight={18}>
369
392
  {t('DRIVER_TIP', 'Driver tip')}
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { View } from 'react-native';
3
- import { useLanguage } from 'ordering-components/native';
3
+ import { useLanguage, useConfig } from 'ordering-components/native';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import { CCContainer, CCNotCarts, CCList } from './styles';
6
6
 
@@ -17,9 +17,11 @@ export const CartContent = (props: any) => {
17
17
 
18
18
  const theme = useTheme();
19
19
  const [, t] = useLanguage()
20
+ const [{ configs }] = useConfig()
20
21
  const [isCartsLoading, setIsCartsLoading] = useState(false)
21
22
 
22
23
  const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
24
+ const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
23
25
 
24
26
  return (
25
27
  <CCContainer
@@ -32,6 +34,7 @@ export const CartContent = (props: any) => {
32
34
  {cart.products.length > 0 && (
33
35
  <>
34
36
  <Cart
37
+ showGeneralBtn={i === 0 && isMultiCheckout}
35
38
  singleBusiness={props.singleBusiness}
36
39
  isFranchiseApp={props.isFranchiseApp}
37
40
  cart={cart}
@@ -39,6 +42,7 @@ export const CartContent = (props: any) => {
39
42
  onNavigationRedirect={props.onNavigationRedirect}
40
43
  isCartsLoading={isCartsLoading}
41
44
  setIsCartsLoading={setIsCartsLoading}
45
+ isMultiCheckout={isMultiCheckout}
42
46
  hideUpselling
43
47
  />
44
48
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginTop: 20 }} />
@@ -7,7 +7,7 @@ import {
7
7
  useValidationFields,
8
8
  useSession,
9
9
  useToast,
10
- ToastType,
10
+ ToastType,
11
11
  MultiCheckout as MultiCheckoutController
12
12
  } from 'ordering-components/native'
13
13
  import { View, StyleSheet, Platform } from 'react-native'
@@ -36,11 +36,11 @@ import {
36
36
  } from './styles'
37
37
 
38
38
  const mapConfigs = {
39
- mapZoom: 16,
40
- mapSize: {
41
- width: 640,
42
- height: 190
43
- }
39
+ mapZoom: 16,
40
+ mapSize: {
41
+ width: 640,
42
+ height: 190
43
+ }
44
44
  }
45
45
 
46
46
  const MultiCheckoutUI = (props: any) => {
@@ -54,75 +54,77 @@ const MultiCheckoutUI = (props: any) => {
54
54
  handleSelectPaymethod,
55
55
  handleSelectWallet,
56
56
  handlePaymethodDataChange,
57
- cartUuid
57
+ cartUuid,
58
+ totalCartsFee,
59
+ cartGroup
58
60
  } = props
59
61
 
60
- const theme = useTheme();
62
+ const theme = useTheme();
61
63
  const styles = StyleSheet.create({
62
64
  pagePadding: {
63
- paddingLeft: 40,
64
- paddingRight: 40
65
- },
65
+ paddingLeft: 40,
66
+ paddingRight: 40
67
+ },
66
68
  wrapperNavbar: Platform.OS === 'ios'
67
- ? { paddingVertical: 0, paddingHorizontal: 40 }
68
- : { paddingVertical: 20, paddingHorizontal: 40 }
69
+ ? { paddingVertical: 0, paddingHorizontal: 40 }
70
+ : { paddingVertical: 20, paddingHorizontal: 40 }
69
71
  })
70
72
 
71
- const [, { showToast }] = useToast();
73
+ const [, { showToast }] = useToast();
72
74
  const [, t] = useLanguage()
73
- const [{ configs }] = useConfig();
74
- const [{ parsePrice, parseDate }] = useUtils();
75
- const [{ options, carts, loading }, { confirmCart }] = useOrder();
76
- const [validationFields] = useValidationFields();
75
+ const [{ configs }] = useConfig();
76
+ const [{ parsePrice, parseDate }] = useUtils();
77
+ const [{ options, carts, loading }, { confirmCart }] = useOrder();
78
+ const [validationFields] = useValidationFields();
77
79
  const [{ user }] = useSession()
78
80
 
79
- const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
80
- const isPreOrder = configs?.preorder_status_enabled?.value === '1'
81
+ const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
82
+ const isPreOrder = configs?.preorder_status_enabled?.value === '1'
81
83
  const maximumCarts = 5
82
84
  const isDisablePlaceOrderButton = !(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) || openCarts.length > maximumCarts || (paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data)
83
85
  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) || []
84
86
 
85
- const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
86
- const [phoneUpdate, setPhoneUpdate] = useState(false);
87
- const [userErrors, setUserErrors] = useState<any>([]);
87
+ const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
88
+ const [phoneUpdate, setPhoneUpdate] = useState(false);
89
+ const [userErrors, setUserErrors] = useState<any>([]);
88
90
  const handleMomentClick = () => {
89
- if (isPreOrder) {
90
- navigation.navigate('MomentOption')
91
- }
92
- }
91
+ if (isPreOrder) {
92
+ navigation.navigate('MomentOption')
93
+ }
94
+ }
93
95
 
94
96
  const checkValidationFields = () => {
95
- setUserErrors([])
96
- const errors = []
97
- const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
97
+ setUserErrors([])
98
+ const errors = []
99
+ const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
98
100
 
99
- Object.values(validationFields?.fields?.checkout).map((field: any) => {
100
- if (field?.required && !notFields.includes(field.code)) {
101
- if (!user[field?.code]) {
102
- errors.push(t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `The field ${field?.name} is required`))
103
- }
104
- }
105
- })
101
+ Object.values(validationFields?.fields?.checkout).map((field: any) => {
102
+ if (field?.required && !notFields.includes(field.code)) {
103
+ if (!user[field?.code]) {
104
+ errors.push(t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `The field ${field?.name} is required`))
105
+ }
106
+ }
107
+ })
106
108
 
107
- if (
108
- !user?.cellphone &&
109
- ((validationFields?.fields?.checkout?.cellphone?.enabled &&
110
- validationFields?.fields?.checkout?.cellphone?.required) ||
111
- configs?.verification_phone_required?.value === '1')
112
- ) {
113
- errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone number is required'))
114
- }
109
+ if (
110
+ !user?.cellphone &&
111
+ ((validationFields?.fields?.checkout?.cellphone?.enabled &&
112
+ validationFields?.fields?.checkout?.cellphone?.required) ||
113
+ configs?.verification_phone_required?.value === '1')
114
+ ) {
115
+ errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone number is required'))
116
+ }
115
117
 
116
- if (phoneUpdate) {
117
- errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
118
- }
118
+ if (phoneUpdate) {
119
+ errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
120
+ }
119
121
 
120
- setUserErrors(errors)
121
- }
122
+ setUserErrors(errors)
123
+ }
122
124
 
123
125
  const togglePhoneUpdate = (val: boolean) => {
124
- setPhoneUpdate(val)
125
- }
126
+ setPhoneUpdate(val)
127
+ }
126
128
 
127
129
  const handlePlaceOrder = () => {
128
130
  if (!userErrors.length) {
@@ -130,18 +132,18 @@ const MultiCheckoutUI = (props: any) => {
130
132
  return
131
133
  }
132
134
  let stringError = ''
133
- Object.values(userErrors).map((item: any, i: number) => {
134
- stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
135
- })
136
- showToast(ToastType.Error, stringError)
135
+ Object.values(userErrors).map((item: any, i: number) => {
136
+ stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
137
+ })
138
+ showToast(ToastType.Error, stringError)
137
139
  setIsUserDetailsEdit(true)
138
140
  }
139
141
 
140
142
  useEffect(() => {
141
- if (validationFields && validationFields?.fields?.checkout) {
142
- checkValidationFields()
143
- }
144
- }, [validationFields, user])
143
+ if (validationFields && validationFields?.fields?.checkout) {
144
+ checkValidationFields()
145
+ }
146
+ }, [validationFields, user])
145
147
 
146
148
  return (
147
149
  <>
@@ -244,12 +246,14 @@ const MultiCheckoutUI = (props: any) => {
244
246
  cart={cart}
245
247
  cartuuid={cart.uuid}
246
248
  isMultiCheckout
249
+ hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
250
+ hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
247
251
  onNavigationRedirect={(route: string, params: any) => props.navigation.navigate(route, params)}
248
252
  />
249
253
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
250
254
  </React.Fragment>
251
255
  ))}
252
- {openCarts.length === 0 && (
256
+ {!cartGroup?.loading && openCarts.length === 0 && (
253
257
  <CCNotCarts>
254
258
  <OText size={24} style={{ textAlign: 'center' }}>
255
259
  {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
@@ -263,6 +267,25 @@ const MultiCheckoutUI = (props: any) => {
263
267
  )}
264
268
  {openCarts.length > 0 && (
265
269
  <ChCartsTotal>
270
+ {totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
271
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
272
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
273
+ {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
274
+ </OText>
275
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>{parsePrice(totalCartsFee)}</OText>
276
+ </View>
277
+ )}
278
+ {openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
279
+ configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
280
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
281
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
282
+ {t('DRIVER_TIP', 'Driver tip')}
283
+ </OText>
284
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
285
+ {parsePrice(openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
286
+ </OText>
287
+ </View>
288
+ )}
266
289
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
267
290
  <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
268
291
  {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
@@ -283,14 +306,14 @@ const MultiCheckoutUI = (props: any) => {
283
306
  </ChSection>
284
307
  </ChContainer>
285
308
  </Container>
286
-
309
+
287
310
  <FloatingButton
288
- handleClick={() => handlePlaceOrder()}
311
+ handleClick={() => handlePlaceOrder()}
289
312
  isSecondaryBtn={isDisablePlaceOrderButton}
290
313
  disabled={isDisablePlaceOrderButton}
291
314
  btnText={placing ? t('PLACING', 'Placing') : t('PLACE_ORDER', 'Place Order')}
292
315
  btnRightValueShow
293
- btnRightValue={parsePrice(totalCartsPrice)}
316
+ btnRightValue={parsePrice(totalCartsPrice)}
294
317
  iosBottom={30}
295
318
  />
296
319
  </>