ordering-ui-react-native 0.21.55-test → 0.21.57-test

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.
@@ -1,59 +1,29 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
3
3
  import Geolocation from '@react-native-community/geolocation'
4
- import { IOScrollView } from 'react-native-intersection-observer'
5
4
  import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
6
5
  import {
7
6
  View,
8
7
  StyleSheet,
9
- ScrollView,
10
8
  Platform,
11
9
  TouchableOpacity,
12
- RefreshControl,
13
- AppState
14
10
  } from 'react-native';
11
+
15
12
  import {
16
13
  BusinessList as BusinessesListingController,
17
- useLanguage,
18
- useSession,
19
14
  useOrder,
20
15
  useConfig,
21
- useUtils
22
16
  } from 'ordering-components/native';
23
17
  import { useTheme } from 'styled-components/native';
24
- import Ionicons from 'react-native-vector-icons/Ionicons'
25
18
 
26
19
  import {
27
- Search,
28
- OrderControlContainer,
29
- AddressInput,
30
- WrapMomentOption,
31
- HeaderWrapper,
32
- ListWrapper,
33
- FeaturedWrapper,
34
- FarAwayMessage,
35
- AddressInputContainer,
36
- PreorderInput,
37
- OrderTypesContainer,
38
20
  BusinessLogosContainer
39
21
  } from './styles';
40
22
 
41
- import { OIcon, OText, OModal } from '../../../shared';
42
23
  import { BusinessesListingParams } from '../../../../types';
43
- import { NotFoundSource } from '../../../NotFoundSource';
44
- import { BusinessTypeFilter } from '../../../BusinessTypeFilter';
45
- import { BusinessController } from '../../../BusinessController';
46
- import { OrderTypeSelector } from '../../../OrderTypeSelector';
47
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
48
- import { BusinessFeaturedController } from '../../../BusinessFeaturedController';
49
- import { HighestRatedBusinesses } from '../../../HighestRatedBusinesses';
50
- import { getTypesText } from '../../../../utils';
51
- import { OrderProgress } from '../../../OrderProgress';
52
- import { useFocusEffect, useIsFocused } from '@react-navigation/native';
24
+ import { useFocusEffect } from '@react-navigation/native';
53
25
  import FastImage from 'react-native-fast-image';
54
- import IconAntDesign from 'react-native-vector-icons/AntDesign';
55
- import { PageBanner } from '../../../PageBanner'
56
- import { CitiesControl } from '../../../CitiesControl'
26
+ import { FlatListBusinessListing } from './FlatListBusinessListing'
57
27
 
58
28
  const PIXELS_TO_SCROLL = 2000;
59
29
 
@@ -62,36 +32,19 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
62
32
  navigation,
63
33
  businessesList,
64
34
  getBusinesses,
65
- handleChangeBusinessType,
66
35
  handleBusinessClick,
67
36
  paginationProps,
68
- businessId,
69
- isGuestUser,
70
- handleUpdateBusinessList,
71
37
  citiesState,
72
38
  actualSlug,
73
39
  logosLayout
74
40
  } = props;
75
41
  const theme = useTheme();
76
- const isFocused = useIsFocused();
77
42
 
78
- const [, t] = useLanguage();
79
- const [{ user, auth }] = useSession();
80
43
  const [orderState, { changeCityFilter }] = useOrder();
81
44
  const [{ configs }] = useConfig();
82
- const [{ parseDate }] = useUtils();
83
45
 
84
- const appState = useRef(AppState.currentState)
85
46
  const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
86
- const [refreshing] = useState(false);
87
47
  const allCitiesDisabled = citiesState?.cities?.every((city: any) => !city.enabled)
88
- const hideCities = (theme?.business_listing_view?.components?.cities?.hidden || orderState?.options?.type !== 2 || allCitiesDisabled) ?? true
89
- const hideHero = theme?.business_listing_view?.components?.business_hero?.hidden
90
- const hidePreviousOrders = theme?.business_listing_view?.components?.previous_orders_block?.hidden
91
- const hideHighestBusiness = theme?.business_listing_view?.components?.highest_rated_business_block?.hidden
92
- const isAllCategoriesHidden = theme?.business_listing_view?.components?.categories?.hidden
93
- const bgHeader = theme?.business_listing_view?.components?.business_hero?.components?.image
94
- const bgHeaderHeight = theme?.business_listing_view?.components?.business_hero?.components?.style?.height
95
48
 
96
49
  const styles = StyleSheet.create({
97
50
  container: {
@@ -156,32 +109,14 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
156
109
  },
157
110
  });
158
111
 
159
- const { top } = useSafeAreaInsets();
160
-
161
112
  const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
162
113
  const [isFarAway, setIsFarAway] = useState(false)
163
- const [businessTypes, setBusinessTypes] = useState(null)
164
114
  const [orderTypeValue, setOrderTypeValue] = useState(orderState?.options?.value)
165
115
  const [isOpenCities, setIsOpenCities] = useState(false)
166
- const isPreorderEnabled = (configs?.preorder_status_enabled?.value === '1' || configs?.preorder_status_enabled?.value === 'true') &&
167
- Number(configs?.max_days_preorder?.value) > 0
168
- const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
169
116
  const timerId = useRef<any>(false)
170
117
  const [favoriteIds, setFavoriteIds] = useState<any>([])
171
- const chewOrderTypes = [{ name: t('DELIVERY', 'Delivery').toUpperCase(), value: 1 }, { name: t('PICKUP', 'Pickup').toUpperCase(), value: 2 }]
172
118
  const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
173
119
 
174
- const handleMomentClick = () => {
175
- if (isPreorderEnabled) {
176
- navigation.navigate('MomentOption')
177
- }
178
- }
179
-
180
- const configTypes =
181
- configs?.order_types_allowed?.value
182
- .split('|')
183
- .map((value: any) => Number(value)) || [];
184
-
185
120
  const handleScroll = ({ nativeEvent }: any) => {
186
121
  const y = nativeEvent.contentOffset.y;
187
122
  const height = nativeEvent.contentSize.height;
@@ -355,340 +290,25 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
355
290
  }
356
291
 
357
292
  return (
358
- <IOScrollView
359
- style={styles.container}
360
- onScroll={(e) => handleScroll(e)}
361
- showsVerticalScrollIndicator={false}
362
- refreshControl={
363
- <RefreshControl
364
- refreshing={refreshing}
365
- onRefresh={() => handleOnRefresh()}
366
- />
367
- }
368
- >
369
- {enabledPoweredByOrdering && auth && (
370
- <View style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', top: 20 }}>
371
- <OText>
372
- Powered By Ordering.co
373
- </OText>
374
- </View>
375
- )}
376
- <View style={{
377
- height: !isPreOrderSetting && isChewLayout ? 150 : isChewLayout ? 200 : isFarAway ? 150 : 100,
378
- marginTop: isChewLayout ? 0 : Platform.OS == 'ios' ? 0 : 50,
379
- backgroundColor: isChewLayout ? theme?.colors?.chew : theme.colors?.white
380
- }}
381
- >
382
- {isChewLayout && (
383
- <View style={{ marginTop: 30, paddingHorizontal: 30, flexDirection: 'row', justifyContent: 'space-between' }}>
384
- <OText size={24} weight={700} color={theme.colors?.white}>
385
- {t('WELCOME', 'Welcome')} {user?.name}
386
- </OText>
387
- </View>
388
- )}
389
- <Search isChewLayout={isChewLayout}>
390
- <AddressInput
391
- isChewLayout={isChewLayout}
392
- onPress={() =>
393
- auth
394
- ? navigation.navigate('AddressList', { isFromBusinesses: true })
395
- : navigation.navigate('AddressForm', {
396
- address: orderState.options?.address,
397
- isFromBusinesses: true,
398
- isGuestUser: isGuestUser
399
- })
400
- }>
401
- <AddressInputContainer isChewLayout={isChewLayout}>
402
- <OIcon
403
- src={theme.images.general.pin}
404
- color={theme.colors.disabled}
405
- width={16}
406
- style={{ marginRight: isChewLayout ? 0 : 10 }}
407
- />
408
- <OText size={12} numberOfLines={1} style={{ flex: 1 }}>
409
- {orderState?.options?.address?.address || t('WHAT_IS_YOUR_ADDRESS', 'What\'s your address?')}
410
- </OText>
411
- {!isChewLayout && (
412
- <OIcon
413
- src={theme.images.general.arrow_down}
414
- width={10}
415
- style={{ marginStart: 8 }}
416
- />
417
- )}
418
- </AddressInputContainer>
419
- </AddressInput>
420
- </Search>
421
- {isFarAway && !isChewLayout && (
422
- <FarAwayMessage style={styles.farAwayMsg}>
423
- <Ionicons name='md-warning-outline' style={styles.iconStyle} />
424
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
425
- </FarAwayMessage>
426
- )}
427
- {!isChewLayout ? (
428
- <OrderControlContainer>
429
- <View style={styles.wrapperOrderOptions}>
430
- {isPreOrderSetting && (
431
- <WrapMomentOption
432
- onPress={() => handleMomentClick()}>
433
- <OText
434
- size={12}
435
- numberOfLines={1}
436
- ellipsizeMode="tail"
437
- color={theme.colors.textSecondary}>
438
- {orderState.options?.moment
439
- ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
440
- : t('ASAP_ABBREVIATION', 'ASAP')}
441
- </OText>
442
- {isPreorderEnabled && (
443
- <OIcon
444
- src={theme.images.general.arrow_down}
445
- width={10}
446
- style={{ marginStart: 8 }}
447
- />
448
- )}
449
- </WrapMomentOption>
450
- )}
451
- <WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes, setOrderTypeValue })}>
452
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderTypeValue || orderState?.options?.type || 1), 'Delivery')}</OText>
453
- <OIcon
454
- src={theme.images.general.arrow_down}
455
- width={10}
456
- style={{ marginStart: 8 }}
457
- />
458
- </WrapMomentOption>
459
- </View>
460
- </OrderControlContainer>
461
- ) : (
462
- <>
463
- {isPreOrderSetting && (
464
- <View style={{ paddingHorizontal: 30 }}>
465
- <PreorderInput
466
- isChewLayout={isChewLayout}
467
- onPress={() => handleMomentClick()}
468
- >
469
- <OText color={theme.colors.textSecondary}>
470
- {orderState.options?.moment
471
- ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
472
- : t('ASAP_ABBREVIATION', 'ASAP')}</OText>
473
- </PreorderInput>
474
- </View>
475
- )}
476
- </>
477
- )}
478
- </View>
479
- {!isChewLayout ? (
480
- <>
481
- {!hideHero ? (
482
- <HeaderWrapper
483
- source={bgHeader ? { uri: bgHeader } : theme.images.backgrounds.business_list_header}
484
- style={{ paddingTop: top + 20 }}
485
- resizeMode='cover'
486
- bgHeaderHeight={bgHeaderHeight}
487
- >
488
- {!auth && (
489
- <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
490
- <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
491
- </TouchableOpacity>
492
- )}
493
- </HeaderWrapper>
494
- ) : (
495
- <>
496
- {!auth && (
497
- <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
498
- <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
499
- </TouchableOpacity>
500
- )}
501
- </>
502
- )}
503
- </>
504
- ) : (
505
- <OrderTypesContainer>
506
- <OrderTypeSelector
507
- handleChangeBusinessType={handleChangeBusinessType}
508
- isChewLayout
509
- chewOrderTypes={chewOrderTypes}
510
- handleChangeType={setOrderTypeValue}
511
- />
512
- </OrderTypesContainer>
513
- )}
514
-
515
- {!hideCities && orderTypeValue === 2 && (
516
- <View style={{ marginTop: 20 }}>
517
- <TouchableOpacity
518
- style={styles.buttonCityStyle}
519
- onPress={() => setIsOpenCities(true)}
520
- disabled={orderState?.loading}
521
- >
522
- <OText size={18} color={theme.colors.backgroundGray} weight='bold' style={{ textAlign: 'center' }}>
523
- {citiesState?.cities?.find((city: any) => city?.id === orderState?.options?.city_id)?.name || t('FILTER_BY_CITY', 'Filter by city')}
524
- </OText>
525
- </TouchableOpacity>
526
- </View>
527
- )}
528
- {!hidePreviousOrders && (
529
- <OrderProgress
530
- {...props}
531
- isFocused={isFocused}
532
- />
533
- )}
534
- {
535
- !businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
536
- <FeaturedWrapper>
537
- <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('BUSINESS_FEATURE', 'Featured business')}</OText>
538
- <ScrollView
539
- showsHorizontalScrollIndicator={false}
540
- nestedScrollEnabled
541
- horizontal
542
- contentContainerStyle={{ paddingHorizontal: 40 }}
543
- >
544
- {featuredBusiness.map((bAry: any, idx) => (
545
- <View key={'f-listing_' + idx}>
546
- <BusinessFeaturedController
547
- business={bAry[0]}
548
- isBusinessOpen={bAry[0]?.open}
549
- handleCustomClick={handleBusinessClick}
550
- orderType={orderState?.options?.type}
551
- />
552
- {bAry.length > 1 && (
553
- <BusinessFeaturedController
554
- business={bAry[1]}
555
- isBusinessOpen={bAry[1]?.open}
556
- handleCustomClick={handleBusinessClick}
557
- orderType={orderState?.options?.type}
558
- />
559
- )}
560
- </View>
561
- ))}
562
- </ScrollView>
563
- </FeaturedWrapper>
564
- )
565
- }
566
- {!isChewLayout && !hideHighestBusiness && (
567
- <>
568
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
569
- {
570
- !businessId && !props.franchiseId && (
571
- <HighestRatedBusinesses
572
- propsToFetch={props.propsToFetch}
573
- onBusinessClick={handleBusinessClick}
574
- navigation={navigation}
575
- favoriteIds={favoriteIds}
576
- setFavoriteIds={setFavoriteIds}
577
- />
578
- )
579
- }
580
- </>
581
- )}
582
-
583
- <PageBanner position='app_business_listing' navigation={navigation} />
584
-
585
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
586
- <ListWrapper style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
587
- {!businessId && !isAllCategoriesHidden && (
588
- <BusinessTypeFilter
589
- images={props.images}
590
- businessTypes={props.businessTypes}
591
- defaultBusinessType={props.defaultBusinessType}
592
- handleChangeBusinessType={handleChangeBusinessType}
593
- setBusinessTypes={setBusinessTypes}
594
- />
595
- )}
596
- {!businessesList.loading && businessesList.businesses.length === 0 && businessesList?.fetched && (
597
- <NotFoundSource
598
- content={t(
599
- 'NOT_FOUND_BUSINESSES',
600
- 'No businesses to delivery / pick up at this address, please change filters or change address.',
601
- )}
602
- />
603
- )}
604
- {businessesList.businesses?.map(
605
- (business: any, i: number) => (
606
- <BusinessController
607
- key={`${business.id}_` + i}
608
- enableIntersection
609
- business={business}
610
- isBusinessOpen={business.open}
611
- handleCustomClick={handleBusinessClick}
612
- orderType={orderState?.options?.type}
613
- navigation={navigation}
614
- businessHeader={business?.header}
615
- businessFeatured={business?.featured}
616
- businessLogo={business?.logo}
617
- businessReviews={business?.reviews}
618
- businessDeliveryPrice={business?.delivery_price}
619
- businessDeliveryTime={business?.delivery_time}
620
- businessPickupTime={business?.pickup_time}
621
- businessDistance={business?.distance}
622
- handleUpdateBusinessList={handleUpdateBusinessList}
623
- favoriteIds={favoriteIds}
624
- setFavoriteIds={setFavoriteIds}
625
- />
626
- )
627
- )}
628
- {(businessesList.loading || !businessesList?.fetched) && (
629
- <>
630
- {[
631
- ...Array(
632
- paginationProps.nextPageItems
633
- ? paginationProps.nextPageItems
634
- : 8,
635
- ).keys(),
636
- ].map((item, i) => (
637
- <Placeholder
638
- Animation={Fade}
639
- key={i}
640
- style={{ marginBottom: 20 }}>
641
- <View style={{ width: '100%' }}>
642
- <PlaceholderLine
643
- height={200}
644
- style={{ marginBottom: 20, borderRadius: 25 }}
645
- />
646
- <View style={{ paddingHorizontal: 10 }}>
647
- <View
648
- style={{
649
- flexDirection: 'row',
650
- justifyContent: 'space-between',
651
- }}>
652
- <PlaceholderLine
653
- height={25}
654
- width={40}
655
- style={{ marginBottom: 10 }}
656
- />
657
- <PlaceholderLine
658
- height={25}
659
- width={20}
660
- style={{ marginBottom: 10 }}
661
- />
662
- </View>
663
- <PlaceholderLine
664
- height={20}
665
- width={30}
666
- style={{ marginBottom: 10 }}
667
- />
668
- <PlaceholderLine
669
- height={20}
670
- width={80}
671
- style={{ marginBottom: 10 }}
672
- />
673
- </View>
674
- </View>
675
- </Placeholder>
676
- ))}
677
- </>
678
- )}
679
- </ListWrapper>
680
- <OModal
681
- open={isOpenCities}
682
- onClose={() => setIsOpenCities(false)}
683
- title={t('SELECT_A_CITY', 'Select a city')}
684
- >
685
- <CitiesControl
686
- cities={citiesState?.cities}
687
- onClose={() => setIsOpenCities(false)}
688
- handleChangeCity={handleChangeCity}
689
- />
690
- </OModal>
691
- </IOScrollView>
293
+ <FlatListBusinessListing
294
+ {...props}
295
+ navigation={navigation}
296
+ businessesList={businessesList}
297
+ enabledPoweredByOrdering={enabledPoweredByOrdering}
298
+ orderTypeValue={orderTypeValue}
299
+ allCitiesDisabled={allCitiesDisabled}
300
+ featuredBusiness={featuredBusiness}
301
+ favoriteIds={favoriteIds}
302
+ isFarAway={isFarAway}
303
+ isOpenCities={isOpenCities}
304
+ isChewLayout={isChewLayout}
305
+ handleScroll={handleScroll}
306
+ setIsOpenCities={setIsOpenCities}
307
+ setFavoriteIds={setFavoriteIds}
308
+ handleOnRefresh={handleOnRefresh}
309
+ setOrderTypeValue={setOrderTypeValue}
310
+ handleChangeCity={handleChangeCity}
311
+ />
692
312
  );
693
313
  };
694
314
 
@@ -192,7 +192,11 @@ const CheckoutUI = (props: any) => {
192
192
  }, cart?.subtotal)
193
193
 
194
194
  const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
195
- const validateZipcodeCard = validationFields?.fields?.card?.zipcode?.enabled && validationFields?.fields?.card?.zipcode?.required && !paymethodSelected?.data?.card?.zipcode
195
+ const validateZipcodeCard = validationFields?.fields?.card?.zipcode?.enabled &&
196
+ validationFields?.fields?.card?.zipcode?.required &&
197
+ paymethodSelected?.data?.card &&
198
+ !paymethodSelected?.data?.card?.zipcode &&
199
+ paymethodSelected?.gateway === 'stripe'
196
200
 
197
201
  const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
198
202
  placing || errorCash || subtotalWithTaxes < cart?.minimum ||
@@ -106,7 +106,7 @@ const RedeemGiftCardUI = (props: any) => {
106
106
  onChange(val)
107
107
  handleChangeCode(val)
108
108
  }}
109
- autoCapitalize='none'
109
+ autoCapitalize='characters'
110
110
  autoCorrect={false}
111
111
  blurOnSubmit={false}
112
112
  style={style.inputStyle}
@@ -129,7 +129,8 @@ export const LastOrder = (props: OrdersOptionParams) => {
129
129
  initialPage: 1,
130
130
  pageSize: 3,
131
131
  controlType: 'infinity'
132
- }
132
+ },
133
+ noGiftCardOrders: true
133
134
  }
134
135
 
135
136
  return <OrderList {...MyOrdersProps} />
@@ -117,7 +117,8 @@ export const LastOrders = (props: any) => {
117
117
  initialPage: 1,
118
118
  pageSize: 3,
119
119
  controlType: 'infinity'
120
- }
120
+ },
121
+ noGiftCardOrders: true
121
122
  }
122
123
  return <OrderListController {...helpProps} />
123
124
  }