ordering-ui-react-native 0.16.61 → 0.16.64

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.61",
3
+ "version": "0.16.64",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -111,6 +111,13 @@ const ChatUI = (props: MessagesParams) => {
111
111
  { key: 'driver_message_4', text: t('DRIVER_MESSAGE_4', 'driver_message_4') }
112
112
  ]
113
113
 
114
+ const adminMessageList: any = [
115
+ { key: 'message_1', text: t('ADMIN_MESSAGE_1', 'admin_message_1') },
116
+ { key: 'message_2', text: t('ADMIN_MESSAGE_2', 'admin_message_2') },
117
+ { key: 'message_3', text: t('ADMIN_MESSAGE_3', 'admin_message_3') },
118
+ { key: 'message_4', text: t('ADMIN_MESSAGE_4', 'admin_message_4') }
119
+ ]
120
+
114
121
  const handleClickQuickMessage = (text: string) => {
115
122
  setMessage && setMessage(`${message}${text}`)
116
123
  }
@@ -426,7 +433,8 @@ const ChatUI = (props: MessagesParams) => {
426
433
  };
427
434
 
428
435
  useEffect(() => {
429
- if (user.level === 2) setMessageList(storeMessageList)
436
+ if (user.level === 0) setMessageList(adminMessageList)
437
+ else if (user.level === 2) setMessageList(storeMessageList)
430
438
  else if (user.level === 4) setMessageList(driverMessageList)
431
439
  else setMessageList([])
432
440
  }, [user])
@@ -88,7 +88,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
88
88
  handleClickLogisticOrder,
89
89
  logisticOrders,
90
90
  loadLogisticOrders,
91
- isLogisticActivated
91
+ isLogisticActivated,
92
+ isAlsea
92
93
  } = props;
93
94
 
94
95
  const defaultSearchList = {
@@ -545,7 +546,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
545
546
  </ScrollView>
546
547
  </FiltersTab>
547
548
  <View style={{ flex: 1, minHeight: HEIGHT_SCREEN - 450 }}>
548
- {currentTabSelected !== 'logisticOrders' && (
549
+ {currentTabSelected !== 'logisticOrders' && !isAlsea && (
549
550
  <View
550
551
  style={{
551
552
  display: 'flex',
@@ -293,7 +293,8 @@ export interface OrdersOptionParams {
293
293
  handleClickLogisticOrder: (status: number, orderId: number) => void,
294
294
  logisticOrders: {orders: Array<any>, loading: boolean, error: Array<string> | string},
295
295
  loadLogisticOrders: () => void;
296
- isLogisticActivated?: boolean
296
+ isLogisticActivated?: boolean;
297
+ isAlsea?: boolean;
297
298
  }
298
299
  export interface ActiveOrdersParams {
299
300
  orders?: any;
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { StyleSheet, View, TouchableOpacity, Linking } from 'react-native';
2
+ import { StyleSheet, View, TouchableOpacity, Linking, Pressable } from 'react-native';
3
3
  import { useUtils, useOrder, useLanguage, useOrderingTheme } from 'ordering-components/native';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import { OIcon, OText, OModal } from '../shared';
@@ -46,7 +46,7 @@ export const BusinessBasicInformation = (
46
46
  const [openBusinessReviews, setOpenBusinessReviews] = useState(false);
47
47
  const [businessInformationObtained, setBusinessInformationObtained] = useState(false)
48
48
  const [businessReviewsObtained, setBusinessReviewsObtainedbtained] = useState(false)
49
- const isChewLayout = theme?.layouts?.business_view?.components?.header?.components?.layout?.type === 'chew'
49
+ const isChewLayout = orderingTheme?.theme?.business_view?.components?.header?.components?.layout?.type === 'chew'
50
50
  const showLogo = !orderingTheme?.theme?.business_view?.components?.header?.components?.business?.components?.logo?.hidden
51
51
 
52
52
  const styles = StyleSheet.create({
@@ -218,14 +218,14 @@ export const BusinessBasicInformation = (
218
218
  />
219
219
  )}
220
220
  {!!business?.tiktok_profile && (
221
- <TouchableOpacity style={styles.socialIcon} onPress={() => Linking.openURL(business?.tiktok_profile)}>
221
+ <Pressable style={styles.socialIcon} onPress={() => Linking.openURL(business?.tiktok_profile)}>
222
222
  <View style={styles.tiktokIcon}>
223
223
  <OIcon
224
224
  src={theme.images.general.tiktok}
225
225
  style={{ width: '100%', height: '100%' }}
226
226
  />
227
227
  </View>
228
- </TouchableOpacity>
228
+ </Pressable>
229
229
  )}
230
230
  {!!business?.pinterest_profile && (
231
231
  <SocialNetWork
@@ -327,7 +327,7 @@ export const BusinessBasicInformation = (
327
327
  </Placeholder>
328
328
  ) : (
329
329
  <TitleWrapper>
330
- <OText size={24} weight={'600'}>
330
+ <OText size={24} weight={'600'} numberOfLines={2}>
331
331
  {business?.name}
332
332
  </OText>
333
333
  {business?.ribbon?.enabled && (
@@ -75,9 +75,9 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
75
75
  const [{ configs }] = useConfig()
76
76
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
77
77
 
78
- const isChewLayout = theme?.layouts?.business_view?.components?.header?.components?.layout?.type === 'chew'
78
+ const isChewLayout = orderingTheme?.theme?.business_view?.components?.header?.components?.layout?.type === 'chew'
79
79
  const showLogo = !orderingTheme?.theme?.business_view?.components?.header?.components?.business?.components?.logo?.hidden
80
- const showBusinessNearCity = !theme?.layouts?.business_view?.components?.near_business?.hidden
80
+ const hideBusinessNearCity = orderingTheme?.theme?.business_view?.components?.near_business?.hidden
81
81
 
82
82
  const styles = StyleSheet.create({
83
83
  mainContainer: {
@@ -277,7 +277,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
277
277
  </WrapSearchBar>
278
278
  )}
279
279
  </TopHeader>
280
- {showBusinessNearCity && businessState?.business?.city_id && (
280
+ {!hideBusinessNearCity && businessState?.business?.city_id && (
281
281
  <NearBusiness>
282
282
  <BusinessesListing
283
283
  logosLayout
@@ -80,8 +80,8 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
80
80
  const appState = useRef(AppState.currentState)
81
81
  const searchBarRef = useRef<any>()
82
82
  const [appStateVisible, setAppStateVisible] = useState(appState.current);
83
- const isChewLayout = theme?.layouts?.header?.components?.layout?.type === 'chew'
84
- const showCities = !orderingTheme?.theme?.business_listing_view?.components?.cities?.hidden
83
+ const isChewLayout = orderingTheme?.theme?.header?.components?.layout?.type === 'chew'
84
+ const hideCities = orderingTheme?.theme?.business_listing_view?.components?.cities?.hidden
85
85
  const [refreshing] = useState(false);
86
86
  const styles = StyleSheet.create({
87
87
  container: {
@@ -216,6 +216,11 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
216
216
  }
217
217
  }
218
218
 
219
+ const handleChangeCity = (cityId: number | null) => {
220
+ changeCityFilter(orderState?.options?.city_id === cityId ? null : cityId)
221
+ setIsOpenCities(false)
222
+ }
223
+
219
224
  useEffect(() => {
220
225
  if (!businessesList?.loading) {
221
226
  const fb = businessesList.businesses.filter((b) => b.featured === true && b?.open);
@@ -345,11 +350,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
345
350
  <OText size={18} weight={700} color={theme.colors?.white}>
346
351
  {t('WELCOME', 'Welcome')} {user?.name}!
347
352
  </OText>
348
- <TouchableOpacity
349
- onPress={() => searchBarRef?.current?.focus?.()}
350
- >
351
- <Ionicons name='search' style={{ ...styles.iconStyle, color: theme.colors?.white }} />
352
- </TouchableOpacity>
353
353
  </View>
354
354
  )}
355
355
  <Search isChewLayout={isChewLayout}>
@@ -485,7 +485,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
485
485
  />
486
486
  )}
487
487
 
488
- {showCities && (
488
+ {!hideCities && (
489
489
  <View style={{ marginTop: 10 }}>
490
490
  <OButton
491
491
  onClick={() => setIsOpenCities(true)}
@@ -654,7 +654,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
654
654
  borderBottomColor: orderState?.options?.city_id === city?.id ? theme.colors.primary : theme.colors.backgroundGray,
655
655
  marginBottom: 10,
656
656
  }}
657
- onPress={() => changeCityFilter(city?.id)}
657
+ onPress={() => handleChangeCity(city?.id)}
658
658
  disabled={orderState?.loading}
659
659
  >
660
660
  <OText color={orderState?.options?.city_id === city?.id ? theme.colors.primary : theme.colors.black}>
@@ -1,6 +1,6 @@
1
1
 
2
2
  import React, { useState, useEffect } from 'react'
3
- import { useOrder, useSession, useLanguage } from 'ordering-components/native';
3
+ import { useOrder, useSession, useLanguage, useOrderingTheme } from 'ordering-components/native';
4
4
 
5
5
  import { useTheme } from 'styled-components/native'
6
6
  import { BusinessesListing as OriginalBusinessListing } from './Layout/Original'
@@ -11,7 +11,8 @@ import { ReviewTrigger } from '../ReviewTrigger';
11
11
  export const BusinessesListing = (props: any) => {
12
12
  const { logosLayout } = props
13
13
  const theme = useTheme()
14
- const layout = theme?.layouts?.business_listing_view?.components?.layout?.type || 'original'
14
+ const [orderingTheme] = useOrderingTheme()
15
+ const layout = orderingTheme?.theme?.business_listing_view?.components?.layout?.type || 'original'
15
16
  const [, t] = useLanguage();
16
17
  const [{ auth }] = useSession()
17
18
  const [, { getLastOrderHasNoReview }] = useOrder();
@@ -96,4 +97,4 @@ export const BusinessesListing = (props: any) => {
96
97
  )}
97
98
  </>
98
99
  )
99
- }
100
+ }
@@ -60,11 +60,11 @@ const CartUI = (props: any) => {
60
60
 
61
61
  const isCartPending = cart?.status === 2
62
62
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
63
- const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
63
+ const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
64
64
 
65
65
  const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
66
66
  const businessId = business?.business_id ?? null
67
- const placeSpotTypes = [3, 4]
67
+ const placeSpotTypes = [4]
68
68
 
69
69
  const momentFormatted = !orderState?.option?.moment
70
70
  ? t('RIGHT_NOW', 'Right Now')
@@ -99,10 +99,10 @@ const CartUI = (props: any) => {
99
99
  setOpenUpselling(false)
100
100
  setCanOpenUpselling(false)
101
101
  if (isCheckoutMultiBusinessEnabled) {
102
- props.onNavigationRedirect('CheckoutNavigator', {
103
- screen: 'MultiCheckout'
104
- })
105
- } else {
102
+ props.onNavigationRedirect('CheckoutNavigator', {
103
+ screen: 'MultiCheckout'
104
+ })
105
+ } else {
106
106
  props.onNavigationRedirect('CheckoutNavigator', {
107
107
  screen: 'CheckoutPage',
108
108
  cartUuid: cart?.uuid,
@@ -446,7 +446,7 @@ const CartUI = (props: any) => {
446
446
  </OText>
447
447
  </View>
448
448
  )}
449
- </>
449
+ </>
450
450
  )}
451
451
  </BusinessItemAccordion>
452
452
 
@@ -141,9 +141,9 @@ const CheckoutUI = (props: any) => {
141
141
  const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
142
142
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
143
143
  const [isOpen, setIsOpen] = useState(false)
144
- const [requiredFields, setRequiredFields] = useState<any>([])
144
+ const [requiredFields, setRequiredFields] = useState<any>([])
145
145
 
146
- const placeSpotTypes = [3, 4]
146
+ const placeSpotTypes = [4]
147
147
  const businessConfigs = businessDetails?.business?.configs ?? []
148
148
  const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
149
149
  const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
@@ -178,15 +178,15 @@ const CheckoutUI = (props: any) => {
178
178
  }
179
179
  }
180
180
 
181
- const handlePlaceOrder = (confirmPayment : any) => {
181
+ const handlePlaceOrder = (confirmPayment: any) => {
182
182
  if (!userErrors.length && !requiredFields?.length) {
183
183
  handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
184
184
  return
185
185
  }
186
186
  if (requiredFields?.length) {
187
- setIsOpen(true)
188
- return
189
- }
187
+ setIsOpen(true)
188
+ return
189
+ }
190
190
  let stringError = ''
191
191
  Object.values(userErrors).map((item: any, i: number) => {
192
192
  stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
@@ -646,6 +646,7 @@ const CheckoutUI = (props: any) => {
646
646
  cart={cart}
647
647
  isCartPending={cart?.status === 2}
648
648
  onNavigationRedirect={onNavigationRedirect}
649
+ placeSpotTypes={placeSpotTypes}
649
650
  />
650
651
  </>
651
652
  )}
@@ -39,7 +39,8 @@ const OrderSummaryUI = (props: any) => {
39
39
  commentState,
40
40
  handleChangeComment,
41
41
  onNavigationRedirect,
42
- handleRemoveOfferClick
42
+ handleRemoveOfferClick,
43
+ placeSpotTypes
43
44
  } = props;
44
45
 
45
46
  const theme = useTheme()
@@ -52,7 +53,6 @@ const OrderSummaryUI = (props: any) => {
52
53
  const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
53
54
  const [openPlaceModal, setOpenPlaceModal] = useState(false)
54
55
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
55
- const placeSpotTypes = [3, 4]
56
56
 
57
57
  const handleDeleteClick = (product: any) => {
58
58
  removeProduct(product, cart)
@@ -304,7 +304,7 @@ const OrderSummaryUI = (props: any) => {
304
304
  </OSTable>
305
305
  </View>
306
306
  )}
307
- {placeSpotTypes.includes(orderState?.options?.type) && (
307
+ {placeSpotTypes && placeSpotTypes.includes(orderState?.options?.type) && (
308
308
  <OSTable style={{ marginTop: 15 }}>
309
309
  <OText size={14} lineHeight={21} weight={'600'}>
310
310
  {t('SPOT', 'Spot')}: {cart?.place?.name || t('NO_SELECTED', 'No selected')}
@@ -169,7 +169,7 @@ export const ProductOptionsUI = (props: any) => {
169
169
  const [gallery, setGallery] = useState([])
170
170
  const [thumbsSwiper, setThumbsSwiper] = useState(0)
171
171
  const [indexGallery, setIndexGallery] = useState(0)
172
- const [selOpt, setSelectedOpt] = useState(0);
172
+ const [selOpt, setSelectedOpt] = useState(-1);
173
173
  const [isHaveWeight, setIsHaveWeight] = useState(false)
174
174
  const [playing, setPlaying] = useState(false);
175
175
  const [qtyBy, setQtyBy] = useState({
@@ -323,6 +323,14 @@ export const ProductOptionsUI = (props: any) => {
323
323
  </>
324
324
  );
325
325
 
326
+ const handleScroll = ({ nativeEvent: { contentOffset, layoutMeasurement } }: any) => {
327
+
328
+ const _topOption = Object.keys(optionLayout).find(((option: any) => Math.abs(contentOffset?.y - layoutMeasurement?.height - optionLayout[option]?.y) < 20))
329
+ if (_topOption) {
330
+ const _topOptionId = Number(_topOption.replace('id:', ''))
331
+ }
332
+ }
333
+
326
334
  const handleGoBack = navigation?.canGoBack()
327
335
  ? () => navigation.goBack()
328
336
  : () => navigation.navigate('Business', { store: props.businessSlug })
@@ -408,7 +416,7 @@ export const ProductOptionsUI = (props: any) => {
408
416
  height: 44,
409
417
  shadowOpacity: 0,
410
418
  borderWidth: 1,
411
- marginTop: isHaveWeight ? 10: 0
419
+ marginTop: isHaveWeight ? 10 : 0
412
420
  }}
413
421
  />
414
422
  )}
@@ -457,7 +465,8 @@ export const ProductOptionsUI = (props: any) => {
457
465
  <ScrollView
458
466
  ref={scrollViewRef}
459
467
  contentContainerStyle={{ paddingBottom: 80 }}
460
- stickyHeaderIndices={[2]}>
468
+ stickyHeaderIndices={[2]}
469
+ onScroll={handleScroll}>
461
470
  <WrapHeader onLayout={(event: any) => setHeaderRefHeight(event.nativeEvent.layout?.height)}>
462
471
  {loading && !product ? (
463
472
  <View style={styles.productHeaderSkeleton}>
@@ -681,36 +690,36 @@ export const ProductOptionsUI = (props: any) => {
681
690
  contentContainerStyle={{ paddingHorizontal: 33, backgroundColor: theme.colors.white }}
682
691
  >
683
692
  <TouchableOpacity
684
- key={`eopt_all_0`}
685
- onPress={() => setSelectedOpt(0)}
693
+ key={`eopt_key_00`}
694
+ onPress={() => setSelectedOpt(-1)}
686
695
  style={[
687
696
  styles.extraItem,
688
697
  {
689
- borderBottomColor: selOpt == 0 ? theme.colors.textNormal : theme.colors.border,
698
+ borderBottomColor: selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
690
699
  },
691
700
  ]}>
692
701
  <OText
693
- color={selOpt == 0 ? theme.colors.textNormal : theme.colors.textSecondary}
694
- size={selOpt == 0 ? 14 : 12}
695
- weight={selOpt == 0 ? '600' : 'normal'}>
702
+ color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
703
+ size={selOpt == -1 ? 14 : 12}
704
+ weight={selOpt == -1 ? '600' : 'normal'}>
696
705
  {t('ALL', 'All')}
697
706
  </OText>
698
707
  </TouchableOpacity>
699
708
  {product?.ingredients.length > 0 && (
700
709
  <TouchableOpacity
701
- key={`eopt_all_00`}
702
- onPress={() => setSelectedOpt(-1)}
710
+ key={`eopt_key_01`}
711
+ onPress={() => setSelectedOpt(0)}
703
712
  style={[
704
713
  styles.extraItem,
705
714
  {
706
715
  borderBottomColor:
707
- selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
716
+ selOpt == 0 ? theme.colors.textNormal : theme.colors.border,
708
717
  },
709
718
  ]}>
710
719
  <OText
711
- color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
712
- size={selOpt == -1 ? 14 : 12}
713
- weight={selOpt == -1 ? '600' : 'normal'}>
720
+ color={selOpt == 0 ? theme.colors.textNormal : theme.colors.textSecondary}
721
+ size={selOpt == 0 ? 14 : 12}
722
+ weight={selOpt == 0 ? '600' : 'normal'}>
714
723
  {t('INGREDIENTS', 'Ingredients')}
715
724
  </OText>
716
725
  </TouchableOpacity>
@@ -760,10 +769,10 @@ export const ProductOptionsUI = (props: any) => {
760
769
  </>
761
770
  ) : (
762
771
  <ProductEditions>
763
- {selOpt == 0 ? (
772
+ {selOpt === -1 ? (
764
773
  <>
765
774
  {product?.ingredients.length > 0 && (
766
- <View style={styles.optionContainer}>
775
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0)}>
767
776
  <SectionTitle>
768
777
  <OText size={16}>
769
778
  {t('INGREDIENTS', 'Ingredients')}
@@ -845,7 +854,7 @@ export const ProductOptionsUI = (props: any) => {
845
854
  </>
846
855
  ) : (
847
856
  <>
848
- {selOpt == -1 ? (
857
+ {selOpt === 0 ? (
849
858
  <View style={styles.optionContainer}>
850
859
  <SectionTitle>
851
860
  <OText size={16}>
@@ -1084,6 +1093,7 @@ export const ProductOptionsUI = (props: any) => {
1084
1093
  export const ProductForm = (props: any) => {
1085
1094
  const productOptionsProps = {
1086
1095
  ...props,
1096
+ productCart: { quantity: props?.product?.minimum_per_order || 1 },
1087
1097
  UIComponent: ProductOptionsUI,
1088
1098
  };
1089
1099
 
@@ -5,6 +5,7 @@ import {
5
5
  useOrder,
6
6
  useUtils,
7
7
  useSession,
8
+ useOrderingTheme,
8
9
  SingleProductCard as SingleProductCardController
9
10
  } from 'ordering-components/native';
10
11
  import { useTheme } from 'styled-components/native';
@@ -39,7 +40,8 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
39
40
  } = props;
40
41
 
41
42
  const theme = useTheme();
42
- const showAddButton = !theme?.layouts?.business_view?.components?.products?.components?.add_to_cart_button?.hidden
43
+ const [orderingTheme] = useOrderingTheme()
44
+ const hideAddButton = orderingTheme?.theme?.business_view?.components?.products?.components?.add_to_cart_button?.hidden
43
45
 
44
46
  const styles = StyleSheet.create({
45
47
  container: {
@@ -132,7 +134,7 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
132
134
  <InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => setIsIntersectionObserver(true)}>
133
135
  {isIntersectionObserver ? (
134
136
  <CardContainer
135
- showAddButton={showAddButton}
137
+ showAddButton={!hideAddButton}
136
138
  style={[
137
139
  styles.container,
138
140
  (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
@@ -231,7 +233,7 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
231
233
  </SoldOut>
232
234
  )}
233
235
  </View>
234
- {showAddButton && (
236
+ {!hideAddButton && (
235
237
  <OButton
236
238
  onClick={() => onProductClick?.(product)}
237
239
  style={{