ordering-ui-react-native 0.17.85 → 0.17.86

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.
Files changed (22) hide show
  1. package/package.json +1 -1
  2. package/themes/business/src/components/ProductItemAccordion/index.tsx +21 -3
  3. package/themes/original/src/components/AddressForm/index.tsx +26 -22
  4. package/themes/original/src/components/BusinessBasicInformation/index.tsx +91 -70
  5. package/themes/original/src/components/BusinessController/index.tsx +71 -49
  6. package/themes/original/src/components/BusinessProductsListing/index.tsx +2 -2
  7. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +47 -29
  8. package/themes/original/src/components/Cart/index.tsx +8 -6
  9. package/themes/original/src/components/Checkout/index.tsx +39 -31
  10. package/themes/original/src/components/Messages/index.tsx +8 -7
  11. package/themes/original/src/components/MultiCheckout/index.tsx +2 -7
  12. package/themes/original/src/components/MyOrders/index.tsx +9 -7
  13. package/themes/original/src/components/OrderDetails/index.tsx +99 -73
  14. package/themes/original/src/components/OrderTypeSelector/index.tsx +6 -4
  15. package/themes/original/src/components/SingleOrderCard/index.tsx +44 -28
  16. package/themes/original/src/components/SingleProductCard/index.tsx +51 -21
  17. package/themes/original/src/components/SingleProductCard/styles.tsx +11 -1
  18. package/themes/original/src/components/UserProfile/index.tsx +82 -53
  19. package/themes/original/src/components/shared/OButton.tsx +5 -1
  20. package/themes/original/src/components/shared/OInput.tsx +8 -2
  21. package/themes/original/src/types/index.tsx +1 -0
  22. package/themes/original/src/utils/index.tsx +12 -0
@@ -18,8 +18,7 @@ import {
18
18
  useSession,
19
19
  useOrder,
20
20
  useConfig,
21
- useUtils,
22
- useOrderingTheme
21
+ useUtils
23
22
  } from 'ordering-components/native';
24
23
  import { useTheme } from 'styled-components/native';
25
24
  import Ionicons from 'react-native-vector-icons/Ionicons'
@@ -74,13 +73,25 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
74
73
  logosLayout
75
74
  } = props;
76
75
  const theme = useTheme();
77
- const [orderingTheme] = useOrderingTheme()
78
76
  const isFocused = useIsFocused();
77
+
78
+ const [, t] = useLanguage();
79
+ const [{ user, auth }] = useSession();
80
+ const [orderState, { changeCityFilter }] = useOrder();
81
+ const [{ configs }] = useConfig();
82
+ const [{ parseDate }] = useUtils();
83
+
79
84
  const appState = useRef(AppState.currentState)
80
85
  const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
81
- const hideCities = theme?.business_listing_view?.components?.cities?.hidden ?? true
82
86
  const [refreshing] = useState(false);
83
- const bgHeader = orderingTheme?.theme?.business_listing_view?.components?.business_hero?.components?.image
87
+ const hideCities = (theme?.business_listing_view?.components?.cities?.hidden || orderState?.options?.type !== 2) ?? true
88
+ const hideHero = theme?.business_listing_view?.components?.business_hero?.hidden
89
+ const hidePreviousOrders = theme?.business_listing_view?.components?.previous_orders_block?.hidden
90
+ const hideHighestBusiness = theme?.business_listing_view?.components?.highest_rated_business_block?.hidden
91
+ const isAllCategoriesHidden = theme?.business_listing_view?.components?.categories?.hidden
92
+ const bgHeader = theme?.business_listing_view?.components?.business_hero?.components?.image
93
+ const bgHeaderHeight = theme?.business_listing_view?.components?.business_hero?.components?.style?.height
94
+
84
95
  const styles = StyleSheet.create({
85
96
  container: {
86
97
  marginBottom: 0,
@@ -144,13 +155,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
144
155
  },
145
156
  });
146
157
 
147
-
148
- const [, t] = useLanguage();
149
- const [{ user, auth }] = useSession();
150
- const [orderState, { changeCityFilter }] = useOrder();
151
- const [{ configs }] = useConfig();
152
- const [{ parseDate }] = useUtils();
153
-
154
158
  const { top } = useSafeAreaInsets();
155
159
 
156
160
  const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
@@ -466,18 +470,30 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
466
470
  )}
467
471
  </View>
468
472
  {!isChewLayout ? (
469
- <HeaderWrapper
470
- source={bgHeader ? { uri: bgHeader } : theme.images.backgrounds.business_list_header}
471
- style={{ paddingTop: top + 20 }}
472
- resizeMode='cover'
473
- >
474
- {!auth && (
475
-
476
- <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
477
- <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
478
- </TouchableOpacity>
473
+ <>
474
+ {!hideHero ? (
475
+ <HeaderWrapper
476
+ source={bgHeader ? { uri: bgHeader } : theme.images.backgrounds.business_list_header}
477
+ style={{ paddingTop: top + 20 }}
478
+ resizeMode='cover'
479
+ bgHeaderHeight={bgHeaderHeight}
480
+ >
481
+ {!auth && (
482
+ <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
483
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
484
+ </TouchableOpacity>
485
+ )}
486
+ </HeaderWrapper>
487
+ ) : (
488
+ <>
489
+ {!auth && (
490
+ <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
491
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
492
+ </TouchableOpacity>
493
+ )}
494
+ </>
479
495
  )}
480
- </HeaderWrapper>
496
+ </>
481
497
  ) : (
482
498
  <OrderTypesContainer>
483
499
  <OrderTypeSelector
@@ -502,10 +518,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
502
518
  </TouchableOpacity>
503
519
  </View>
504
520
  )}
505
- <OrderProgress
506
- {...props}
507
- isFocused={isFocused}
508
- />
521
+ {!hidePreviousOrders && (
522
+ <OrderProgress
523
+ {...props}
524
+ isFocused={isFocused}
525
+ />
526
+ )}
509
527
  {
510
528
  !businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
511
529
  <FeaturedWrapper>
@@ -538,7 +556,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
538
556
  </FeaturedWrapper>
539
557
  )
540
558
  }
541
- {!isChewLayout && (
559
+ {!isChewLayout && !hideHighestBusiness && (
542
560
  <>
543
561
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
544
562
  {
@@ -558,7 +576,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
558
576
 
559
577
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
560
578
  <ListWrapper style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
561
- {!businessId && (
579
+ {!businessId && !isAllCategoriesHidden && (
562
580
  <BusinessTypeFilter
563
581
  images={props.images}
564
582
  businessTypes={props.businessTypes}
@@ -70,7 +70,8 @@ const CartUI = (props: any) => {
70
70
  const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
71
71
  const businessId = business?.business_id ?? null
72
72
  const placeSpotTypes = [4]
73
-
73
+ const hideCartComments = theme?.business_view?.components?.cart?.components?.comments?.hidden
74
+ const hideCartDiscount = theme?.business_view?.components?.cart?.components?.discount?.hidden
74
75
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
75
76
  ? JSON.parse(configs?.driver_tip_options?.value) || []
76
77
  : configs?.driver_tip_options?.value || []
@@ -251,6 +252,7 @@ const CartUI = (props: any) => {
251
252
  offsetDisabled={offsetDisabled}
252
253
  onDeleteProduct={handleDeleteClick}
253
254
  onEditProduct={handleEditProduct}
255
+ viewString='business_view'
254
256
  />
255
257
  ))}
256
258
 
@@ -262,7 +264,7 @@ const CartUI = (props: any) => {
262
264
  {parsePrice(cart?.subtotal + getIncludedTaxes())}
263
265
  </OText>
264
266
  </OSTable>
265
- {cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
267
+ {!hideCartDiscount && cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
266
268
  <OSTable>
267
269
  {cart?.discount_type === 1 ? (
268
270
  <OText size={12} lineHeight={18}>
@@ -276,7 +278,7 @@ const CartUI = (props: any) => {
276
278
  </OSTable>
277
279
  )}
278
280
  {
279
- cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any, i: number) => (
281
+ !hideCartDiscount && cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any, i: number) => (
280
282
  <OSTable key={`${offer.id}_${i}`}>
281
283
  <OSRow>
282
284
  <OText size={12} lineHeight={18}>{offer.name}</OText>
@@ -297,7 +299,7 @@ const CartUI = (props: any) => {
297
299
  ))
298
300
  }
299
301
  {/* <Divider /> */}
300
- {cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
302
+ {!hideCartDiscount && cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
301
303
  <OSTable>
302
304
  <OText size={12} lineHeight={18} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
303
305
  {cart?.business?.tax_type === 1 ? (
@@ -363,7 +365,7 @@ const CartUI = (props: any) => {
363
365
  {orderState?.options?.type === 1 && cart?.delivery_price > 0 && !hideDeliveryFee && (
364
366
  <OSTable>
365
367
  <OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
366
- <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price_with_discount ?? cart?.delivery_price)}</OText>
368
+ <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price)}</OText>
367
369
  </OSTable>
368
370
  )}
369
371
  {
@@ -474,7 +476,7 @@ const CartUI = (props: any) => {
474
476
  </TouchableOpacity>
475
477
  </OSTable>
476
478
  )}
477
- {cart?.status !== 2 && (
479
+ {cart?.status !== 2 && !hideCartComments && (
478
480
  <OSTable>
479
481
  <View style={{ width: '100%', marginTop: 20 }}>
480
482
  <OText size={16} lineHeight={18}>{t('COMMENTS', 'Comments')}</OText>
@@ -155,6 +155,10 @@ const CheckoutUI = (props: any) => {
155
155
  const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (isWalletCashEnabled || isWalletCreditPointsEnabled)
156
156
  const isBusinessChangeEnabled = configs?.cart_change_business_validation?.value === '1'
157
157
  const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
158
+ const hideBusinessAddress = theme?.checkout?.components?.business?.components?.address?.hidden
159
+ const hideBusinessDetails = theme?.checkout?.components?.business?.hidden
160
+ const hideBusinessMap = theme?.checkout?.components?.business?.components?.map?.hidden
161
+ const hideCustomerDetails = theme?.checkout?.components?.customer?.hidden
158
162
 
159
163
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
160
164
  const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
@@ -353,7 +357,7 @@ const CheckoutUI = (props: any) => {
353
357
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 18, marginHorizontal: -40 }} />
354
358
  </ChSection>
355
359
 
356
- {!isGiftCardCart && (
360
+ {!isGiftCardCart && !hideBusinessDetails && (
357
361
  <ChSection>
358
362
  <ChBusinessDetails>
359
363
  {
@@ -384,9 +388,11 @@ const CheckoutUI = (props: any) => {
384
388
  <OText size={12} lineHeight={18} weight={'400'}>
385
389
  {businessDetails?.business?.cellphone}
386
390
  </OText>
387
- <OText size={12} lineHeight={18} weight={'400'}>
388
- {businessDetails?.business?.address}
389
- </OText>
391
+ {!hideBusinessAddress && (
392
+ <OText size={12} lineHeight={18} weight={'400'}>
393
+ {businessDetails?.business?.address}
394
+ </OText>
395
+ )}
390
396
  </View>
391
397
  </>
392
398
  )}
@@ -402,33 +408,35 @@ const CheckoutUI = (props: any) => {
402
408
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
403
409
  </ChSection>
404
410
  )}
411
+ {!hideCustomerDetails && (
405
412
 
406
- <ChSection>
407
- <ChUserDetails>
408
- {cartState.loading ? (
409
- <Placeholder Animation={Fade}>
410
- <PlaceholderLine height={20} />
411
- <PlaceholderLine height={12} />
412
- <PlaceholderLine height={12} />
413
- <PlaceholderLine height={12} style={{ marginBottom: 20 }} />
414
- </Placeholder>
415
- ) : (
416
- <UserDetails
417
- isUserDetailsEdit={isUserDetailsEdit}
418
- HeaderTitle={<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer Details')} mb={0} />}
419
- cartStatus={cart?.status}
420
- businessId={cart?.business_id}
421
- useValidationFields
422
- useDefualtSessionManager
423
- useSessionUser
424
- isCheckout
425
- phoneUpdate={phoneUpdate}
426
- togglePhoneUpdate={togglePhoneUpdate}
427
- />
428
- )}
429
- </ChUserDetails>
430
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
431
- </ChSection>
413
+ <ChSection>
414
+ <ChUserDetails>
415
+ {cartState.loading ? (
416
+ <Placeholder Animation={Fade}>
417
+ <PlaceholderLine height={20} />
418
+ <PlaceholderLine height={12} />
419
+ <PlaceholderLine height={12} />
420
+ <PlaceholderLine height={12} style={{ marginBottom: 20 }} />
421
+ </Placeholder>
422
+ ) : (
423
+ <UserDetails
424
+ isUserDetailsEdit={isUserDetailsEdit}
425
+ HeaderTitle={<HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer Details')} mb={0} />}
426
+ cartStatus={cart?.status}
427
+ businessId={cart?.business_id}
428
+ useValidationFields
429
+ useDefualtSessionManager
430
+ useSessionUser
431
+ isCheckout
432
+ phoneUpdate={phoneUpdate}
433
+ togglePhoneUpdate={togglePhoneUpdate}
434
+ />
435
+ )}
436
+ </ChUserDetails>
437
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
438
+ </ChSection>
439
+ )}
432
440
 
433
441
  {options?.type === 1 && !isGiftCardCart && (
434
442
  <DeliveryOptionsContainer>
@@ -509,7 +517,7 @@ const CheckoutUI = (props: any) => {
509
517
  </ChSection>
510
518
  )}
511
519
 
512
- {!isGiftCardCart && (
520
+ {!isGiftCardCart && !hideBusinessMap && (
513
521
  <ChSection>
514
522
  <ChAddress>
515
523
  {(businessDetails?.loading || cartState.loading) ? (
@@ -13,6 +13,7 @@ import { Header, TitleHeader, Wrapper, QuickMessageContainer, ProfileMessageHead
13
13
  import { MessagesParams } from '../../types'
14
14
  import { useWindowDimensions } from 'react-native'
15
15
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
16
+ import { getLogisticTag } from '../../utils'
16
17
 
17
18
  const ORDER_STATUS: any = {
18
19
  0: 'ORDER_STATUS_PENDING',
@@ -127,7 +128,7 @@ const MessagesUI = (props: MessagesParams) => {
127
128
  ?
128
129
  `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${filterSpecialStatus.includes(message.change.attribute) ?
129
130
  `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}` :
130
- `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
131
+ `${message.change?.attribute !== 'logistic_status' ? message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)]) : message.change.old !== null && getLogisticTag(message.change.old)} ${t('TO', 'to')} ${message.change?.attribute !== 'logistic_status' ? t(ORDER_STATUS[parseInt(message.change.new, 10)]) : getLogisticTag(message.change.new)}`
131
132
  }`
132
133
  : message.change.new
133
134
  ?
@@ -155,9 +156,9 @@ const MessagesUI = (props: MessagesParams) => {
155
156
  image: message.source,
156
157
  system: message.type === 1,
157
158
  user: {
158
- _id: message.author.id,
159
- name: message.author.name,
160
- avatar: message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo
159
+ _id: message.author && message.author.id,
160
+ name: message.author && message.author.name,
161
+ avatar: message.author && (message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo)
161
162
  }
162
163
  });
163
164
  }
@@ -170,9 +171,9 @@ const MessagesUI = (props: MessagesParams) => {
170
171
  image: message.source,
171
172
  system: message.type === 1,
172
173
  user: {
173
- _id: message.author.id,
174
- name: message.author.name,
175
- avatar: message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo
174
+ _id: message.author && message.author.id ,
175
+ name: message.author && message.author.name,
176
+ avatar: message.author && (message.author.id !== user.id && type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo)
176
177
  }
177
178
  });
178
179
  }
@@ -65,9 +65,7 @@ const MultiCheckoutUI = (props: any) => {
65
65
  paddingLeft: 40,
66
66
  paddingRight: 40
67
67
  },
68
- wrapperNavbar: Platform.OS === 'ios'
69
- ? { paddingVertical: 0, paddingHorizontal: 40 }
70
- : { paddingVertical: 20, paddingHorizontal: 40 }
68
+ wrapperNavbar: { paddingHorizontal: 40 }
71
69
  })
72
70
 
73
71
  const [, { showToast }] = useToast();
@@ -150,15 +148,12 @@ const MultiCheckoutUI = (props: any) => {
150
148
  <Container noPadding>
151
149
  <View style={styles.wrapperNavbar}>
152
150
  <NavBar
153
- isVertical
154
151
  title={t('CHECKOUT', 'Checkout')}
155
152
  titleAlign={'center'}
156
153
  onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
157
154
  showCall={false}
155
+ paddingTop={Platform.OS === 'ios' ? 0 : 4}
158
156
  btnStyle={{ paddingLeft: 0 }}
159
- style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
160
- titleWrapStyle={{ paddingHorizontal: 0 }}
161
- titleStyle={{ marginRight: 0, marginLeft: 0 }}
162
157
  />
163
158
  </View>
164
159
  <ChContainer style={styles.pagePadding}>
@@ -30,15 +30,17 @@ export const MyOrders = (props: any) => {
30
30
 
31
31
  const notOrderOptions = ['business', 'products']
32
32
  const allEmpty = (ordersLength?.activeOrdersLength === 0 && ordersLength?.previousOrdersLength === 0) || ((isEmptyBusinesses || businessOrderIds?.length === 0) && hideOrders)
33
- const MyOrdersMenu = [
34
- { key: 'orders', value: t('ORDERS', 'Orders') },
35
- { key: 'business', value: t('BUSINESS', 'Business') },
36
- { key: 'products', value: t('PRODUCTS', 'Products') }
37
- ]
33
+
38
34
  const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
39
35
  const showNavbar = theme?.bar_menu?.components?.orders?.hidden
40
36
  const hideOrdersTheme = theme?.bar_menu?.components?.orders?.hidden
41
-
37
+ const hideProductsTab = theme?.orders?.components?.products_tab?.hidden
38
+ const hideBusinessTab = theme?.orders?.components?.business_tab?.hidden
39
+ const MyOrdersMenu = [
40
+ { key: 'orders', value: t('ORDERS', 'Orders'), disabled: false },
41
+ { key: 'business', value: t('BUSINESS', 'Business'), disabled: hideBusinessTab },
42
+ { key: 'products', value: t('PRODUCTS', 'Products'), disabled: hideProductsTab }
43
+ ]
42
44
  const goToBack = () => navigation?.canGoBack() && navigation.goBack()
43
45
 
44
46
  const handleOnRefresh = () => {
@@ -125,7 +127,7 @@ export const MyOrders = (props: any) => {
125
127
  showsHorizontalScrollIndicator={false}
126
128
  scrollEventThrottle={16}
127
129
  >
128
- {MyOrdersMenu.filter(option => !hideOrders || option.key !== 'orders').map(option => (
130
+ {MyOrdersMenu.filter(option => (!hideOrders || option.key !== 'orders') && !option.disabled).map(option => (
129
131
  <Tab
130
132
  key={option.key}
131
133
  onPress={() => setSelectedOption(option.key)}