ordering-ui-react-native 0.15.9 → 0.15.12

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.15.9",
3
+ "version": "0.15.12",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -47,6 +47,8 @@ const MomentOptionUI = (props: MomentOptionParams) => {
47
47
  const [optionSelected, setOptionSelected] = useState({ isAsap: false, isSchedule: false })
48
48
  const [momentState, setMomentState] = useState({ isLoading: 0, isEditing: false })
49
49
 
50
+ const is12hours = configs?.dates_moment_format?.value?.includes('hh:mm')
51
+
50
52
  const goToBack = () => navigation?.canGoBack() && navigation.goBack()
51
53
 
52
54
  const _handleAsap = () => {
@@ -192,7 +194,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
192
194
  disabled={orderState.loading}
193
195
  >
194
196
  <OText color={timeSelected === hour.startTime ? theme.colors.primary : theme.colors.textSecondary}>
195
- {configs?.format_time?.value === '12' ? (
197
+ {is12hours ? (
196
198
  hour.startTime.includes('12')
197
199
  ? `${hour.startTime}PM`
198
200
  : parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
@@ -32,7 +32,8 @@ export const getTraduction = (key: string, t: any) => {
32
32
  ERROR_PLACE_PAY_WITH_CARD1: 'An error occurred while trying to pay by card',
33
33
  ERROR_PLACE_PAY_WITH_PAYPAL_CAPTURE: 'An error occurred while trying to pay by PayPal',
34
34
  ERROR_ADD_PRODUCT_VERY_FAR_FOR_DELIVERY: 'Error adding product, very far for delivery',
35
- ERROR_PRODUCT_NOT_FOUND: 'Error with the product'
35
+ ERROR_PRODUCT_NOT_FOUND: 'Error with the product',
36
+ ERROR_ADD_BUSINESS_INVALID: 'An error occurred with the business',
36
37
  }
37
38
 
38
39
  return keyList[key] ? t(key, keyList[key]) : t(key)
@@ -38,7 +38,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
38
38
  },
39
39
  });
40
40
 
41
- const _categories: any = business?.original?.categories;
41
+ const _categories: any = business?.categories;
42
42
  let _promos: any = [];
43
43
  _categories?.forEach((categ: any) => {
44
44
  const _featuredProds = categ?.products?.filter(
@@ -183,8 +183,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
183
183
  resetInactivityTimeout()
184
184
  navigation.navigate('Category', {
185
185
  category,
186
- categories: business.original.categories,
187
- businessId: business?.api?.businessId,
186
+ categories: business?.categories,
187
+ businessId: business?.id,
188
188
  businessSlug: business?.slug,
189
189
  clearInactivityTimeout,
190
190
  resetInactivityTimeout,
@@ -212,6 +212,7 @@ const CategoriesMenu = (props: any): React.ReactElement => {
212
212
  businessId={parseInt(businessId, 10)}
213
213
  businessSlug={businessSlug}
214
214
  onSave={() => {
215
+ showCartBottomSheet()
215
216
  setDrawerValues({ isOpen: !drawerState.isOpen, data: null })
216
217
  }}
217
218
  navigation={navigation}
@@ -87,7 +87,6 @@ export const ProductOptionsUI = (props: any) => {
87
87
  const isErrors = Object.values(errors).length > 0
88
88
  if (!isErrors) {
89
89
  handleSave && handleSave()
90
- showCartBottomSheet()
91
90
  return
92
91
  }
93
92
  }
@@ -58,9 +58,9 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
58
58
  const maxDistanceOptions = [1000, 2000, 5000, 'default']
59
59
  const maxTimeOptions = [5, 15, 30, 'default']
60
60
  const sortItems = [
61
- { text: t('PICKED_FOR_YOU', 'Picked for you (default)'), value: 'default' },
61
+ { text: t('PICKED_FOR_YOU', 'Picked for you (default)'), value: 'distance' },
62
62
  { text: t('DELIVERY_TIME', 'Delivery time'), value: 'delivery_time' },
63
- { text: t('PICKUP_TIME', 'Pickup time'), value: 'pickup_type' }
63
+ { text: t('PICKUP_TIME', 'Pickup time'), value: 'pickup_time' }
64
64
  ]
65
65
 
66
66
  const styles = StyleSheet.create({
@@ -396,7 +396,7 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
396
396
  <OText weight='bold' mBottom={7} size={16}>
397
397
  {t('SORT', 'Sort')}
398
398
  </OText>
399
- {sortItems?.map(item => (
399
+ {sortItems?.filter(item => !(orderState?.options?.type === 1 && item?.value === 'pickup_time') && !(orderState?.options?.type === 2 && item?.value === 'delivery_time'))?.map(item => (
400
400
  <TouchableOpacity
401
401
  key={item?.value}
402
402
  onPress={() => handleChangeFilters('orderBy', item?.value)}
@@ -39,7 +39,8 @@ import {
39
39
  ChCart,
40
40
  DeliveryOptionsContainer,
41
41
  DeliveryOptionItem,
42
- WalletPaymentOptionContainer
42
+ WalletPaymentOptionContainer,
43
+ CartHeader
43
44
  } from './styles';
44
45
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
45
46
 
@@ -570,9 +571,28 @@ const CheckoutUI = (props: any) => {
570
571
  />
571
572
  ) : (
572
573
  <>
573
- <OText size={16} lineHeight={24} color={theme.colors.textNormal}>
574
- {t('ORDER_SUMMARY', 'Order Summary')}
575
- </OText>
574
+ <CartHeader>
575
+ <OText
576
+ size={16}
577
+ lineHeight={24}
578
+ color={theme.colors.textNormal}
579
+ style={{ fontWeight: '500' }}
580
+ >
581
+ {t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
582
+ </OText>
583
+ <TouchableOpacity
584
+ onPress={() => onNavigationRedirect('Business', { store: cart?.business?.slug })}
585
+ >
586
+ <OText
587
+ size={10}
588
+ lineHeight={15}
589
+ color={theme.colors.primary}
590
+ style={{ textDecorationLine: 'underline' }}
591
+ >
592
+ {t('ADD_PRODUCTS', 'Add products')}
593
+ </OText>
594
+ </TouchableOpacity>
595
+ </CartHeader>
576
596
  {props.isFranchiseApp && (
577
597
  <TouchableOpacity
578
598
  onPress={() => setOpenChangeStore(true)}
@@ -105,3 +105,10 @@ export const DeliveryOptionItem = styled.View`
105
105
  flex-direction: row;
106
106
  background-color: ${(props : any) => props?.backgroundColor ?? '#fff'};
107
107
  `;
108
+
109
+ export const CartHeader = styled.View`
110
+ align-items: center;
111
+ flex-direction: row;
112
+ justify-content: space-between;
113
+ margin-bottom: 10px;
114
+ `
@@ -9,6 +9,8 @@ import {
9
9
  import {
10
10
  PaymentOptions as PaymentOptionsController,
11
11
  useLanguage,
12
+ ToastType,
13
+ useToast,
12
14
  } from 'ordering-components/native';
13
15
  import { useTheme } from 'styled-components/native';
14
16
  import { PaymentOptionCash } from '../PaymentOptionCash';
@@ -59,7 +61,7 @@ const PaymentOptionsUI = (props: any) => {
59
61
  } = props
60
62
 
61
63
  const theme = useTheme();
62
-
64
+ const [, { showToast }] = useToast();
63
65
 
64
66
  const getPayIcon = (method: string) => {
65
67
  switch (method) {
@@ -95,11 +97,18 @@ const PaymentOptionsUI = (props: any) => {
95
97
  // ]
96
98
 
97
99
  const handlePaymentMethodClick = (paymethod: any) => {
98
- const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
99
- if (webViewPaymentGateway.includes(paymethod?.gateway)) {
100
- handlePaymentMethodClickCustom(paymethod)
101
- }
102
- handlePaymethodClick(paymethod, isPopupMethod)
100
+ if (cart?.balance > 0) {
101
+ const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
102
+ if (webViewPaymentGateway.includes(paymethod?.gateway)) {
103
+ handlePaymentMethodClickCustom(paymethod)
104
+ }
105
+ handlePaymethodClick(paymethod, isPopupMethod)
106
+ return
107
+ }
108
+ showToast(
109
+ ToastType.Error,
110
+ t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
111
+ ;
103
112
  }
104
113
 
105
114
  useEffect(() => {