ordering-ui-react-native 0.15.8 → 0.15.9-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.
Files changed (129) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessTypeFilter/index.tsx +12 -2
  4. package/src/components/BusinessTypeFilter/styles.tsx +1 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +0 -1
  7. package/src/components/LanguageSelector/index.tsx +1 -0
  8. package/src/components/Messages/index.tsx +38 -30
  9. package/src/components/MomentOption/index.tsx +3 -1
  10. package/src/components/OrderDetails/index.tsx +25 -4
  11. package/src/components/PaymentOptions/index.tsx +9 -16
  12. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  13. package/src/components/ProductForm/index.tsx +1 -1
  14. package/src/components/ProductForm/styles.tsx +1 -0
  15. package/src/components/StripeElementsForm/index.tsx +27 -48
  16. package/src/components/VerifyPhone/styles.tsx +1 -2
  17. package/src/config.json +0 -2
  18. package/src/pages/Checkout.tsx +1 -1
  19. package/src/types/index.tsx +1 -9
  20. package/src/utils/index.tsx +2 -1
  21. package/themes/business/index.tsx +2 -0
  22. package/themes/business/src/components/Chat/index.tsx +32 -31
  23. package/themes/business/src/components/Home/index.tsx +128 -55
  24. package/themes/business/src/components/Home/styles.tsx +8 -1
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +59 -98
  26. package/themes/business/src/components/OrderDetails/Business.tsx +1 -0
  27. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +27 -0
  28. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +85 -17
  29. package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
  30. package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
  31. package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
  32. package/themes/business/src/components/OrdersOption/index.tsx +70 -116
  33. package/themes/business/src/components/OrdersOption/styles.tsx +2 -5
  34. package/themes/business/src/components/PreviousOrders/index.tsx +82 -23
  35. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  36. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  37. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  38. package/themes/kiosk/src/components/BusinessController/index.tsx +27 -6
  39. package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
  40. package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +51 -24
  41. package/themes/kiosk/src/components/Cart/index.tsx +1 -1
  42. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  43. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  44. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  45. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  46. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +7 -5
  47. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  48. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  49. package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
  50. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  51. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  52. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  53. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  54. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  55. package/themes/kiosk/src/components/ProductForm/index.tsx +174 -126
  56. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  57. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  58. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  59. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  60. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  61. package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
  62. package/themes/original/index.tsx +177 -0
  63. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  64. package/themes/original/src/components/AddressList/index.tsx +28 -2
  65. package/themes/original/src/components/AppleLogin/index.tsx +119 -78
  66. package/themes/original/src/components/BusinessBasicInformation/index.tsx +95 -44
  67. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  68. package/themes/original/src/components/BusinessController/index.tsx +32 -21
  69. package/themes/original/src/components/BusinessListingSearch/index.tsx +7 -3
  70. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  71. package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
  72. package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
  73. package/themes/original/src/components/BusinessProductsList/index.tsx +129 -22
  74. package/themes/original/src/components/BusinessProductsList/styles.tsx +32 -2
  75. package/themes/original/src/components/BusinessProductsListing/index.tsx +18 -28
  76. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  77. package/themes/original/src/components/BusinessesListing/index.tsx +40 -53
  78. package/themes/original/src/components/Cart/index.tsx +40 -9
  79. package/themes/original/src/components/CartContent/index.tsx +2 -2
  80. package/themes/original/src/components/Checkout/index.tsx +47 -31
  81. package/themes/original/src/components/Checkout/styles.tsx +7 -0
  82. package/themes/original/src/components/CouponControl/index.tsx +1 -0
  83. package/themes/original/src/components/DriverTips/index.tsx +1 -1
  84. package/themes/original/src/components/ForgotPasswordForm/index.tsx +8 -12
  85. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
  86. package/themes/original/src/components/Home/index.tsx +1 -1
  87. package/themes/original/src/components/LoginForm/index.tsx +156 -70
  88. package/themes/original/src/components/LoginForm/styles.tsx +6 -1
  89. package/themes/original/src/components/Messages/index.tsx +52 -45
  90. package/themes/original/src/components/Messages/styles.tsx +1 -3
  91. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  92. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  93. package/themes/original/src/components/OrderDetails/index.tsx +104 -126
  94. package/themes/original/src/components/OrderDetails/styles.tsx +3 -1
  95. package/themes/original/src/components/OrderProgress/index.tsx +4 -4
  96. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  97. package/themes/original/src/components/OrderSummary/index.tsx +34 -1
  98. package/themes/original/src/components/OrdersOption/index.tsx +15 -46
  99. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  100. package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
  101. package/themes/original/src/components/PaymentOptions/index.tsx +24 -25
  102. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -8
  103. package/themes/original/src/components/PlaceSpot/index.tsx +114 -0
  104. package/themes/original/src/components/PlaceSpot/styles.tsx +11 -0
  105. package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
  106. package/themes/original/src/components/ProductForm/index.tsx +31 -20
  107. package/themes/original/src/components/ProductForm/styles.tsx +2 -2
  108. package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
  109. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  110. package/themes/original/src/components/SignupForm/index.tsx +173 -154
  111. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
  112. package/themes/original/src/components/TaxInformation/index.tsx +17 -7
  113. package/themes/original/src/components/UpsellingProducts/index.tsx +6 -6
  114. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  115. package/themes/original/src/components/UserFormDetails/index.tsx +2 -14
  116. package/themes/original/src/components/UserProfile/index.tsx +16 -16
  117. package/themes/original/src/components/UserProfileForm/index.tsx +8 -6
  118. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  119. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  120. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  121. package/themes/original/src/components/shared/index.tsx +2 -0
  122. package/themes/original/src/config/constants.tsx +6 -6
  123. package/themes/original/src/types/index.tsx +63 -23
  124. package/themes/original/src/utils/index.tsx +12 -2
  125. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  126. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +5 -5
  127. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  128. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  129. package/src/components/StripeMethodForm/index.tsx +0 -168
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useEffect } from 'react'
2
2
  import { useLanguage, BusinessMenuListing } from 'ordering-components/native'
3
3
  import { OText } from '../shared'
4
4
  import { BusinessMenuListParams } from '../../types'
@@ -19,7 +19,7 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
19
19
 
20
20
  const [, t] = useLanguage()
21
21
  const theme = useTheme()
22
- const {top} = useSafeAreaInsets()
22
+ const { top } = useSafeAreaInsets()
23
23
 
24
24
  const styles = StyleSheet.create({
25
25
  container: {
@@ -36,7 +36,7 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
36
36
  height: 44,
37
37
  width: '100%'
38
38
  }
39
- })
39
+ })
40
40
 
41
41
  const dropDownIcon = () => {
42
42
  return (
@@ -48,12 +48,18 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
48
48
  )
49
49
  }
50
50
 
51
+ useEffect(() => {
52
+ if (!businessMenuList?.loading && businessMenuList?.menus?.length === 1){
53
+ setMenu(businessMenuList?.menus[0])
54
+ }
55
+ }, [businessMenuList?.menus])
56
+
51
57
  return (
52
58
  <>
53
59
  {businessMenuList.loading ? (
54
60
  <Placeholder Animation={Fade}>
55
61
  <View>
56
- <PlaceholderLine height={44}/>
62
+ <PlaceholderLine height={44} />
57
63
  </View>
58
64
  </Placeholder>
59
65
  ) : (
@@ -67,6 +73,7 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
67
73
  onSelect={(selectedItem, index) => {
68
74
  setMenu(selectedItem)
69
75
  }}
76
+ defaultValue={businessMenuList?.menus?.length === 1 && businessMenuList?.menus[0]}
70
77
  buttonTextAfterSelection={(selectedItem, index) => {
71
78
  return selectedItem.name
72
79
  }}
@@ -51,7 +51,9 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
51
51
  const [selectDate, setSelectedDate] = useState<any>(null)
52
52
  const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
53
53
  const [isEnabled, setIsEnabled] = useState(false)
54
- const {top} = useSafeAreaInsets()
54
+ const { top } = useSafeAreaInsets()
55
+ const showOrderTime = (selectedPreorderType === 1 && Object.keys(menu)?.length > 0) || selectedPreorderType === 0
56
+ const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
55
57
  const styles = StyleSheet.create({
56
58
  container: {
57
59
  height: windowHeight,
@@ -300,60 +302,62 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
300
302
  />
301
303
  </View>
302
304
  </BusinessInfoWrapper>
303
- <PreorderTypeWrapper>
304
- <OText
305
- size={16}
306
- style={{
307
- fontWeight: '600',
308
- lineHeight: 24,
309
- marginBottom: 12
310
- }}
311
- >
312
- {t('PREORDER_TYPE', 'Preorder type')}
313
- </OText>
314
- <SelectDropdown
315
- defaultValueByIndex={selectedPreorderType}
316
- data={preorderTypeList}
317
- // disabled={orderState.loading}
318
- onSelect={(selectedItem, index) => {
319
- setSelectedPreorderType(index)
320
- }}
321
- buttonTextAfterSelection={(selectedItem, index) => {
322
- return selectedItem.name
323
- }}
324
- rowTextForSelection={(item, index) => {
325
- return item.name
326
- }}
327
- buttonStyle={styles.selectOption}
328
- buttonTextStyle={{
329
- color: theme.colors.disabled,
330
- fontSize: 14,
331
- textAlign: 'left',
332
- marginHorizontal: 0
333
- }}
334
- dropdownStyle={{
335
- borderRadius: 8,
336
- borderColor: theme.colors.lightGray,
337
- marginTop: Platform.OS === 'ios' ? 12 : -top
338
- }}
339
- rowStyle={{
340
- borderBottomColor: theme.colors.backgroundGray100,
341
- backgroundColor: theme.colors.backgroundGray100,
342
- height: 40,
343
- flexDirection: 'column',
344
- alignItems: 'flex-start',
345
- paddingTop: 8,
346
- paddingHorizontal: 14
347
- }}
348
- rowTextStyle={{
349
- color: theme.colors.disabled,
350
- fontSize: 14,
351
- marginHorizontal: 0
352
- }}
353
- renderDropdownIcon={() => dropDownIcon()}
354
- dropdownOverlayColor='transparent'
355
- />
356
- </PreorderTypeWrapper>
305
+ {isPreOrderSetting && (
306
+ <PreorderTypeWrapper>
307
+ <OText
308
+ size={16}
309
+ style={{
310
+ fontWeight: '600',
311
+ lineHeight: 24,
312
+ marginBottom: 12
313
+ }}
314
+ >
315
+ {t('PREORDER_TYPE', 'Preorder type')}
316
+ </OText>
317
+ <SelectDropdown
318
+ defaultValueByIndex={selectedPreorderType}
319
+ data={preorderTypeList}
320
+ // disabled={orderState.loading}
321
+ onSelect={(selectedItem, index) => {
322
+ setSelectedPreorderType(index)
323
+ }}
324
+ buttonTextAfterSelection={(selectedItem, index) => {
325
+ return selectedItem.name
326
+ }}
327
+ rowTextForSelection={(item, index) => {
328
+ return item.name
329
+ }}
330
+ buttonStyle={styles.selectOption}
331
+ buttonTextStyle={{
332
+ color: theme.colors.disabled,
333
+ fontSize: 14,
334
+ textAlign: 'left',
335
+ marginHorizontal: 0
336
+ }}
337
+ dropdownStyle={{
338
+ borderRadius: 8,
339
+ borderColor: theme.colors.lightGray,
340
+ marginTop: Platform.OS === 'ios' ? 12 : -top
341
+ }}
342
+ rowStyle={{
343
+ borderBottomColor: theme.colors.backgroundGray100,
344
+ backgroundColor: theme.colors.backgroundGray100,
345
+ height: 40,
346
+ flexDirection: 'column',
347
+ alignItems: 'flex-start',
348
+ paddingTop: 8,
349
+ paddingHorizontal: 14
350
+ }}
351
+ rowTextStyle={{
352
+ color: theme.colors.disabled,
353
+ fontSize: 14,
354
+ marginHorizontal: 0
355
+ }}
356
+ renderDropdownIcon={() => dropDownIcon()}
357
+ dropdownOverlayColor='transparent'
358
+ />
359
+ </PreorderTypeWrapper>
360
+ )}
357
361
  {selectedPreorderType === 1 && (
358
362
  <MenuWrapper>
359
363
  <OText
@@ -373,78 +377,94 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
373
377
  />
374
378
  </MenuWrapper>
375
379
  )}
376
- <OrderTimeWrapper>
380
+ {isPreOrderSetting && showOrderTime && (
381
+ <OrderTimeWrapper>
382
+ <OText
383
+ size={16}
384
+ style={{
385
+ fontWeight: '600',
386
+ lineHeight: 24
387
+ }}
388
+ >
389
+ {t('ORDER_TIME', 'Order time')}
390
+ </OText>
391
+ <View style={{ flex: 1 }}>
392
+ {selectDate && datesWhitelist[0]?.start !== null && (
393
+ <CalendarStrip
394
+ scrollable
395
+ style={styles.calendar}
396
+ calendarHeaderContainerStyle={styles.calendarHeaderContainer}
397
+ calendarHeaderStyle={styles.calendarHeader}
398
+ dateNumberStyle={styles.dateNumber}
399
+ dateNameStyle={styles.dateName}
400
+ iconContainer={{ flex: 0.1 }}
401
+ highlightDateNameStyle={styles.highlightDateName}
402
+ highlightDateNumberStyle={styles.highlightDateNumber}
403
+ dayContainerStyle={{ height: '100%' }}
404
+ highlightDateContainerStyle={{ height: '100%' }}
405
+ calendarHeaderFormat='MMMM, YYYY'
406
+ iconStyle={{ borderWidth: 1 }}
407
+ selectedDate={selectDate}
408
+ datesWhitelist={datesWhitelist}
409
+ disabledDateNameStyle={styles.disabledDateName}
410
+ disabledDateNumberStyle={styles.disabledDateNumber}
411
+ disabledDateOpacity={0.6}
412
+ onDateSelected={(date) => onSelectDate(date)}
413
+ leftSelector={<LeftSelector />}
414
+ rightSelector={<RightSelector />}
415
+ />
416
+ )}
417
+ </View>
418
+ <TimeListWrapper nestedScrollEnabled={true}>
419
+ {(isEnabled && timeList?.length > 0) ? (
420
+ <TimeContentWrapper>
421
+ {timeList.map((time: any, i: number) => (
422
+ <TouchableOpacity key={i} onPress={() => handleChangeTime(time.value)}>
423
+ <TimeItem active={timeSelected === time.value}>
424
+ <OText
425
+ size={14}
426
+ color={timeSelected === time.value ? theme.colors.primary : theme.colors.textNormal}
427
+ style={{
428
+ lineHeight: 24
429
+ }}
430
+ >{time.text}</OText>
431
+ </TimeItem>
432
+ </TouchableOpacity>
433
+ ))}
434
+ {timeList.length % 3 === 2 && (
435
+ <TimeItem style={{ backgroundColor: 'transparent' }} />
436
+ )}
437
+ </TimeContentWrapper>
438
+ ) : (
439
+ <OText
440
+ size={16}
441
+ style={{
442
+ fontWeight: '600',
443
+ lineHeight: 24,
444
+ marginBottom: 12,
445
+ textAlign: 'center'
446
+ }}
447
+ >
448
+ {t('ERROR_ADD_PRODUCT_BUSINESS_CLOSED', 'The business is closed at the moment')}
449
+ </OText>
450
+ )}
451
+ </TimeListWrapper>
452
+ </OrderTimeWrapper>
453
+ )}
454
+ {!isPreOrderSetting && (
377
455
  <OText
378
456
  size={16}
379
457
  style={{
380
458
  fontWeight: '600',
381
- lineHeight: 24
459
+ lineHeight: 24,
460
+ marginTop: 30,
461
+ marginBottom: 12,
462
+ textAlign: 'center'
382
463
  }}
383
- >
384
- {t('ORDER_TIME', 'Order time')}
464
+ >
465
+ {t('ERROR_ADD_PRODUCT_BUSINESS_CLOSED', 'The business is closed at the moment')}
385
466
  </OText>
386
- <View style={{ flex: 1 }}>
387
- {selectDate && datesWhitelist[0]?.start !== null && (
388
- <CalendarStrip
389
- scrollable
390
- style={styles.calendar}
391
- calendarHeaderContainerStyle={styles.calendarHeaderContainer}
392
- calendarHeaderStyle={styles.calendarHeader}
393
- dateNumberStyle={styles.dateNumber}
394
- dateNameStyle={styles.dateName}
395
- iconContainer={{ flex: 0.1 }}
396
- highlightDateNameStyle={styles.highlightDateName}
397
- highlightDateNumberStyle={styles.highlightDateNumber}
398
- dayContainerStyle={{ height: '100%' }}
399
- highlightDateContainerStyle={{ height: '100%' }}
400
- calendarHeaderFormat='MMMM, YYYY'
401
- iconStyle={{ borderWidth: 1 }}
402
- selectedDate={selectDate}
403
- datesWhitelist={datesWhitelist}
404
- disabledDateNameStyle={styles.disabledDateName}
405
- disabledDateNumberStyle={styles.disabledDateNumber}
406
- disabledDateOpacity={0.6}
407
- onDateSelected={(date) => onSelectDate(date)}
408
- leftSelector={<LeftSelector />}
409
- rightSelector={<RightSelector />}
410
- />
411
- )}
412
- </View>
413
- <TimeListWrapper nestedScrollEnabled={true}>
414
- {(isEnabled && timeList?.length > 0) ? (
415
- <TimeContentWrapper>
416
- {timeList.map((time: any, i: number) => (
417
- <TouchableOpacity key={i} onPress={() => handleChangeTime(time.value)}>
418
- <TimeItem active={timeSelected === time.value}>
419
- <OText
420
- size={14}
421
- color={timeSelected === time.value ? theme.colors.primary : theme.colors.textNormal}
422
- style={{
423
- lineHeight: 24
424
- }}
425
- >{time.text}</OText>
426
- </TimeItem>
427
- </TouchableOpacity>
428
- ))}
429
- {timeList.length % 3 === 2 && (
430
- <TimeItem style={{ backgroundColor: 'transparent' }} />
431
- )}
432
- </TimeContentWrapper>
433
- ) : (
434
- <OText
435
- size={16}
436
- style={{
437
- fontWeight: '600',
438
- lineHeight: 24,
439
- marginBottom: 12,
440
- textAlign: 'center'
441
- }}
442
- >
443
- {t('ERROR_ADD_PRODUCT_BUSINESS_CLOSED', 'The business is closed at the moment')}
444
- </OText>
445
- )}
446
- </TimeListWrapper>
447
- </OrderTimeWrapper>
467
+ )}
448
468
  <OButton
449
469
  text={t('GO_TO_MENU', 'Go to menu')}
450
470
  textStyle={{ color: 'white' }}
@@ -44,11 +44,11 @@ const BusinessProductsCategoriesUI = (props: any) => {
44
44
  borderTopStartRadius: 4,
45
45
  borderTopEndRadius: 4,
46
46
  backgroundColor: theme.colors.textPrimary,
47
- },
48
- tabDeactived: {
47
+ },
48
+ tabDeactived: {
49
49
  marginTop: 10,
50
50
  height: 4
51
- }
51
+ }
52
52
  });
53
53
 
54
54
  const handleCategoryScroll = (category: any) => {
@@ -111,8 +111,10 @@ const BusinessProductsCategoriesUI = (props: any) => {
111
111
  categories.length &&
112
112
  categories.map((category: any) => (
113
113
  <Tab
114
- key={category.name}
115
- onPress={() => handleCategoryScroll(category)}
114
+ key={category.id}
115
+ onPress={() => requestAnimationFrame(() => {
116
+ handleCategoryScroll(category)
117
+ })}
116
118
  style={[
117
119
  category.id === 'featured' && !featured && styles.featuredStyle,
118
120
  {
@@ -4,11 +4,12 @@ import { SingleProductCard } from '../SingleProductCard';
4
4
  import { NotFoundSource } from '../NotFoundSource';
5
5
  import { BusinessProductsListParams } from '../../types';
6
6
  import { OButton, OIcon, OModal, OText } from '../shared';
7
- import { ProductsContainer, ErrorMessage, WrapperNotFound } from './styles';
7
+ import { ProductsContainer, ErrorMessage, WrapperNotFound, RibbonBox, SubCategoriesContainer, ContainerButton, HeaderWrapper } from './styles';
8
8
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
9
- import { View } from 'react-native';
9
+ import { View, ScrollView } from 'react-native';
10
10
  import { StyleSheet } from 'react-native';
11
11
  import { useTheme } from 'styled-components/native';
12
+ import { shape } from '../../utils'
12
13
 
13
14
  const BusinessProductsListUI = (props: BusinessProductsListParams) => {
14
15
  const {
@@ -27,7 +28,12 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
27
28
  handleCancelSearch,
28
29
  categoriesLayout,
29
30
  setCategoriesLayout,
30
- currentCart
31
+ currentCart,
32
+ setSubcategoriesSelected,
33
+ subcategoriesSelected,
34
+ onClickCategory,
35
+ lazyLoadProductsRecommended,
36
+ isFiltMode
31
37
  } = props;
32
38
 
33
39
  const [, t] = useLanguage();
@@ -43,20 +49,85 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
43
49
  setCategoriesLayout(_categoriesLayout)
44
50
  }
45
51
 
46
- return (
47
- <ProductsContainer>
48
- {category.id &&
49
- categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any) => (
50
- <SingleProductCard
51
- key={'prod_' + product.id}
52
- isSoldOut={product.inventoried && !product.quantity}
53
- product={product}
54
- businessId={businessId}
55
- onProductClick={() => onProductClick(product)}
56
- productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
52
+ const onClickSubcategory = (subCategory: any, parentCategory: any) => {
53
+ if (parentCategory && lazyLoadProductsRecommended) {
54
+ onClickCategory(parentCategory)
55
+ }
56
+ if (!subCategory) {
57
+ setSubcategoriesSelected?.(subcategoriesSelected.filter((_subcategory: any) => _subcategory?.parent_category_id !== parentCategory?.id))
58
+ return
59
+ }
60
+ const categoryFounded = subcategoriesSelected.find((_subcategory: any) => subCategory?.id === _subcategory?.id)
61
+ if (categoryFounded) {
62
+ setSubcategoriesSelected?.(subcategoriesSelected.filter((_subcategory: any) => subCategory?.id !== _subcategory?.id))
63
+ } else {
64
+ setSubcategoriesSelected?.([...subcategoriesSelected, subCategory])
65
+ }
66
+ }
67
+
68
+ const SubcategoriesComponent = ({ category }: any) => {
69
+ const allsubcategorySelected = !subcategoriesSelected?.some((subcategory: any) => category?.id === subcategory?.parent_category_id)
70
+
71
+ return (
72
+ <SubCategoriesContainer>
73
+ <ContainerButton
74
+ isSelected={allsubcategorySelected}
75
+ >
76
+ <OButton
77
+ onClick={() => onClickSubcategory(null, category)}
78
+ bgColor={allsubcategorySelected ? theme.colors.primary : theme.colors.backgroundGray}
79
+ text={`${t('ALL', 'All')} ${allsubcategorySelected ? 'X' : ''}`}
80
+ style={bpStyles.categoryButtonStyle}
81
+ textStyle={{ color: allsubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
57
82
  />
58
- ))}
83
+ </ContainerButton>
84
+ {category?.subcategories?.map((subcategory: any) => {
85
+ const isSubcategorySelected = subcategoriesSelected?.find((_subcategory: any) => _subcategory?.id === subcategory?.id)
86
+ return (
87
+ <ContainerButton
88
+ key={subcategory?.id}
89
+ isSelected={isSubcategorySelected}
90
+ >
91
+ <OButton
92
+ onClick={() => onClickSubcategory(subcategory, category)}
93
+ bgColor={isSubcategorySelected ? theme.colors.primary : theme.colors.backgroundGray}
94
+ text={`${subcategory?.name} ${isSubcategorySelected ? 'X' : ''}`}
95
+ style={bpStyles.categoryButtonStyle}
96
+ textStyle={{ color: isSubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
97
+ />
98
+ </ContainerButton>
99
+ )
100
+ }
101
+ )}
102
+ </SubCategoriesContainer>
103
+ )
104
+ }
59
105
 
106
+
107
+ return (
108
+ <ProductsContainer renderToHardwareTextureAndroid={categoryState.loading || isBusinessLoading}>
109
+ <HeaderWrapper>
110
+ {category?.subcategories?.length > 0 && (
111
+ <SubcategoriesComponent category={category} />
112
+ )}
113
+ </HeaderWrapper>
114
+ {category.id &&
115
+ categoryState.products
116
+ ?.filter((product: any) =>
117
+ !subcategoriesSelected.find((subcategory: any) => subcategory?.parent_category_id === category?.id) ||
118
+ subcategoriesSelected?.some((subcategory: any) => subcategory.id === product?.category_id))
119
+ ?.sort((a: any, b: any) => a.rank - b.rank)
120
+ ?.map((product: any, i : number) => (
121
+ <SingleProductCard
122
+ key={'prod_' + product.id + `_${i}`}
123
+ isSoldOut={product.inventoried && !product.quantity}
124
+ product={product}
125
+ businessId={businessId}
126
+ onProductClick={() => onProductClick(product)}
127
+ productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
128
+ />
129
+ ))
130
+ }
60
131
  {!category.id &&
61
132
  featured &&
62
133
  categoryState?.products?.find((product: any) => product.featured) && (
@@ -71,7 +142,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
71
142
  (product: any, i: any) =>
72
143
  product.featured && (
73
144
  <SingleProductCard
74
- key={i}
145
+ key={'feat_' + product.id + `_${i}`}
75
146
  isSoldOut={product.inventoried && !product.quantity}
76
147
  product={product}
77
148
  businessId={businessId}
@@ -85,9 +156,14 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
85
156
  )}
86
157
 
87
158
  {!category?.id && categories.filter(category => category?.id !== null).map((category, i, _categories) => {
88
- const products = !isUseParentCategory
159
+ const _products = !isUseParentCategory
89
160
  ? categoryState?.products?.filter((product: any) => product?.category_id === category?.id) ?? []
90
161
  : categoryState?.products?.filter((product: any) => category?.children?.some((cat: any) => cat.category_id === product?.category_id)) ?? []
162
+ const products = subcategoriesSelected?.length > 0
163
+ ? _products?.filter((product: any) =>
164
+ !subcategoriesSelected.find((subcategory: any) => subcategory?.parent_category_id === category?.id) ||
165
+ subcategoriesSelected?.some((subcategory: any) => subcategory.id === product?.category_id))
166
+ : _products
91
167
 
92
168
  const shortCategoryDescription = category?.description?.length > 80 ? `${category?.description?.substring(0, 80)}...` : category?.description
93
169
 
@@ -110,10 +186,28 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
110
186
  <OText size={16} weight="600">
111
187
  {category.name}
112
188
  </OText>
189
+ {category?.ribbon?.enabled && (
190
+ <RibbonBox
191
+ bgColor={category?.ribbon?.color}
192
+ isRoundRect={category?.ribbon?.shape === shape?.rectangleRound}
193
+ isCapsule={category?.ribbon?.shape === shape?.capsuleShape}
194
+ >
195
+ <OText
196
+ size={10}
197
+ weight={'400'}
198
+ color={theme.colors.white}
199
+ numberOfLines={2}
200
+ ellipsizeMode='tail'
201
+ lineHeight={13}
202
+ >
203
+ {category?.ribbon?.text}
204
+ </OText>
205
+ </RibbonBox>
206
+ )}
113
207
  </View>
114
208
  {!!category?.description && (
115
209
  <View style={{ position: 'relative' }}>
116
- <OText size={12} weight={'500'} mBottom={5}>
210
+ <OText size={12} weight={'500'} mBottom={10} color='#909BA9'>
117
211
  {shortCategoryDescription}
118
212
  {category?.description?.length > 80 && (
119
213
  <OButton
@@ -133,6 +227,9 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
133
227
  </OText>
134
228
  </View>
135
229
  )}
230
+ {category?.subcategories?.length > 0 && !isFiltMode && (
231
+ <SubcategoriesComponent category={category} />
232
+ )}
136
233
  <>
137
234
  {products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
138
235
  <SingleProductCard
@@ -176,6 +273,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
176
273
  !isBusinessLoading &&
177
274
  categoryState.products.length === 0 &&
178
275
  !errors &&
276
+ !isFiltMode &&
179
277
  !(
180
278
  (searchValue && errorQuantityProducts) ||
181
279
  (!searchValue && !errorQuantityProducts)
@@ -220,7 +318,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
220
318
  title={openDescription?.name}
221
319
  onClose={() => setOpenDescription(null)}
222
320
  >
223
- <View style={{ padding: 20 }}>
321
+ <ScrollView style={{ padding: 20 }}>
224
322
  {!!openDescription?.image && (
225
323
  <OIcon
226
324
  url={optimizeImage(openDescription?.image, 'h_100,c_limit')}
@@ -229,15 +327,15 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
229
327
  style={{ borderRadius: 7.6 }}
230
328
  />
231
329
  )}
232
- <OText>{openDescription?.description}</OText>
233
- </View>
330
+ <OText mBottom={40}>{openDescription?.description}</OText>
331
+ </ScrollView>
234
332
  </OModal>
235
333
  </ProductsContainer>
236
334
  );
237
335
  };
238
336
 
239
337
  const bpStyles = StyleSheet.create({
240
- catWrap: { flexDirection: 'row', alignItems: 'center', height: 41, marginBottom: 19 },
338
+ catWrap: { flexDirection: 'row', alignItems: 'center', marginBottom: 19 },
241
339
  catIcon: {
242
340
  borderRadius: 7.6,
243
341
  shadowColor: '#000000',
@@ -246,6 +344,15 @@ const bpStyles = StyleSheet.create({
246
344
  shadowRadius: 1,
247
345
  marginEnd: 13,
248
346
  },
347
+ categoryButtonStyle: {
348
+ borderWidth: 0,
349
+ marginLeft: 5,
350
+ marginRight: 5,
351
+ marginBottom: 10,
352
+ height: 35,
353
+ paddingLeft: 3,
354
+ paddingRight: 3,
355
+ }
249
356
  });
250
357
 
251
358
  export const BusinessProductsList = (props: BusinessProductsListParams) => {
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components/native'
1
+ import styled, { css } from 'styled-components/native'
2
2
 
3
3
  export const ProductsContainer = styled.View`
4
4
  `
@@ -11,4 +11,34 @@ export const ErrorMessage = styled.View`
11
11
 
12
12
  export const WrapperNotFound = styled.View`
13
13
  height: 500px;
14
- `
14
+ `
15
+
16
+ export const RibbonBox = styled.View`
17
+ margin-left: 5px;
18
+ background-color: ${(props: any) => props.theme.colors.primary};
19
+ padding: 2px 8px;
20
+ max-width: 180px;
21
+
22
+ ${(props: any) => props.bgColor && css`
23
+ background-color: ${props.bgColor};
24
+ `}
25
+
26
+ ${(props: any) => props.isRoundRect && css`
27
+ border-radius: 7.6px;
28
+ `}
29
+
30
+ ${(props: any) => props.isCapsule && css`
31
+ border-radius: 50px;
32
+ `}
33
+ `
34
+
35
+ export const SubCategoriesContainer = styled.View`
36
+ flex-direction: row;
37
+ flex-wrap: wrap;
38
+ margin-bottom: 10px;
39
+ `
40
+
41
+ export const ContainerButton = styled.View`
42
+ `
43
+
44
+ export const HeaderWrapper = styled.View``