ordering-ui-react-native 0.15.33 → 0.15.35-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 (182) hide show
  1. package/package.json +4 -2
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessController/index.tsx +8 -2
  4. package/src/components/BusinessTypeFilter/index.tsx +4 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +23 -3
  7. package/src/components/DriverTips/index.tsx +11 -6
  8. package/src/components/LanguageSelector/index.tsx +7 -2
  9. package/src/components/LoginForm/index.tsx +3 -1
  10. package/src/components/OrderDetails/index.tsx +2 -2
  11. package/src/components/PaymentOptions/index.tsx +9 -16
  12. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  13. package/src/components/SignupForm/index.tsx +3 -1
  14. package/src/components/SingleProductCard/index.tsx +16 -4
  15. package/src/components/StripeElementsForm/index.tsx +27 -48
  16. package/src/components/UpsellingProducts/index.tsx +1 -1
  17. package/src/components/UserProfileForm/index.tsx +63 -6
  18. package/src/components/UserProfileForm/styles.tsx +8 -0
  19. package/src/components/VerifyPhone/styles.tsx +1 -2
  20. package/src/components/shared/OModal.tsx +1 -1
  21. package/src/config.json +0 -2
  22. package/src/hooks/useCountdownTimer.tsx +26 -0
  23. package/src/navigators/CheckoutNavigator.tsx +6 -0
  24. package/src/navigators/HomeNavigator.tsx +12 -0
  25. package/src/pages/BusinessProductsList.tsx +1 -0
  26. package/src/pages/BusinessesListing.tsx +1 -1
  27. package/src/pages/Checkout.tsx +1 -1
  28. package/src/pages/MultiCheckout.tsx +31 -0
  29. package/src/pages/MultiOrdersDetails.tsx +27 -0
  30. package/src/pages/Sessions.tsx +22 -0
  31. package/src/types/index.tsx +5 -11
  32. package/src/utils/index.tsx +68 -1
  33. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  34. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  35. package/themes/business/src/components/Chat/index.tsx +38 -86
  36. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  37. package/themes/business/src/components/Home/index.tsx +128 -55
  38. package/themes/business/src/components/Home/styles.tsx +8 -1
  39. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  40. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  41. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  42. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  43. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  44. package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
  45. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +157 -89
  46. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  47. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  48. package/themes/business/src/components/OrdersListManager/index.tsx +52 -49
  49. package/themes/business/src/components/OrdersOption/index.tsx +57 -50
  50. package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
  51. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  52. package/themes/business/src/components/shared/OModal.tsx +1 -1
  53. package/themes/business/src/types/index.tsx +5 -1
  54. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  55. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  56. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  57. package/themes/kiosk/src/components/Cart/index.tsx +99 -25
  58. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  59. package/themes/kiosk/src/components/Checkout/index.tsx +34 -22
  60. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  61. package/themes/kiosk/src/components/Intro/index.tsx +12 -12
  62. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  63. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  64. package/themes/kiosk/src/components/OrderDetails/index.tsx +165 -65
  65. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  66. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  67. package/themes/kiosk/src/components/PaymentOptions/index.tsx +1 -1
  68. package/themes/kiosk/src/components/ProductForm/index.tsx +2 -2
  69. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  70. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  71. package/themes/kiosk/src/types/index.d.ts +2 -0
  72. package/themes/original/index.tsx +188 -1
  73. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  74. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  75. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  76. package/themes/original/src/components/AddressList/index.tsx +56 -18
  77. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  78. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  79. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  80. package/themes/original/src/components/BusinessController/index.tsx +56 -16
  81. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  82. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  83. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  84. package/themes/original/src/components/BusinessItemAccordion/index.tsx +4 -3
  85. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  86. package/themes/original/src/components/BusinessListingSearch/index.tsx +125 -7
  87. package/themes/original/src/components/BusinessListingSearch/styles.tsx +14 -1
  88. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  89. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
  90. package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
  91. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  92. package/themes/original/src/components/BusinessProductsList/index.tsx +139 -36
  93. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  94. package/themes/original/src/components/BusinessProductsListing/index.tsx +125 -21
  95. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  96. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  97. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  98. package/themes/original/src/components/BusinessesListing/index.tsx +85 -45
  99. package/themes/original/src/components/Cart/index.tsx +60 -43
  100. package/themes/original/src/components/CartContent/index.tsx +2 -2
  101. package/themes/original/src/components/Checkout/index.tsx +59 -48
  102. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  103. package/themes/original/src/components/Favorite/index.tsx +91 -0
  104. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  105. package/themes/original/src/components/FavoriteList/index.tsx +287 -0
  106. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  107. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  108. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  109. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  110. package/themes/original/src/components/Help/index.tsx +21 -4
  111. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  112. package/themes/original/src/components/Home/index.tsx +1 -1
  113. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  114. package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
  115. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  116. package/themes/original/src/components/LoginForm/index.tsx +394 -155
  117. package/themes/original/src/components/LoginForm/styles.tsx +7 -4
  118. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  119. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  120. package/themes/original/src/components/Messages/index.tsx +6 -1
  121. package/themes/original/src/components/Messages/styles.tsx +1 -3
  122. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  123. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  124. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  125. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  126. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  127. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  128. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  129. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  130. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  131. package/themes/original/src/components/OrderDetails/index.tsx +56 -33
  132. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  133. package/themes/original/src/components/OrderProgress/index.tsx +3 -3
  134. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  135. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  136. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  137. package/themes/original/src/components/OrdersOption/index.tsx +57 -56
  138. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  139. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  140. package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
  141. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  142. package/themes/original/src/components/PaymentOptions/index.tsx +9 -21
  143. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  144. package/themes/original/src/components/PreviousOrders/index.tsx +18 -145
  145. package/themes/original/src/components/ProductForm/index.tsx +76 -61
  146. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  147. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  148. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  149. package/themes/original/src/components/Promotions/index.tsx +250 -0
  150. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  151. package/themes/original/src/components/SearchBar/index.tsx +4 -1
  152. package/themes/original/src/components/Sessions/index.tsx +160 -0
  153. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  154. package/themes/original/src/components/SignupForm/index.tsx +9 -4
  155. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  156. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  157. package/themes/original/src/components/SingleProductCard/index.tsx +82 -30
  158. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  159. package/themes/original/src/components/StripeElementsForm/index.tsx +10 -2
  160. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  161. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  162. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  163. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  164. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  165. package/themes/original/src/components/UserProfile/index.tsx +62 -8
  166. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  167. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  168. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  169. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  170. package/themes/original/src/components/Wallets/index.tsx +76 -9
  171. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  172. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  173. package/themes/original/src/components/shared/OModal.tsx +4 -2
  174. package/themes/original/src/components/shared/index.tsx +2 -0
  175. package/themes/original/src/config/constants.tsx +6 -6
  176. package/themes/original/src/types/index.tsx +107 -9
  177. package/themes/original/src/utils/index.tsx +28 -2
  178. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  179. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
  180. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  181. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  182. package/src/components/StripeMethodForm/index.tsx +0 -174
@@ -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,
@@ -142,7 +144,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
142
144
 
143
145
  const validateSelectedDate = (curdate: any, menu: any) => {
144
146
  const day = moment(curdate).format('d')
145
- setIsEnabled(menu?.schedule[day]?.enabled || false)
147
+ setIsEnabled(menu?.schedule?.[day]?.enabled || false)
146
148
  }
147
149
 
148
150
  const getTimes = (curdate: any, menu: any) => {
@@ -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) => {
@@ -57,12 +57,12 @@ const BusinessProductsCategoriesUI = (props: any) => {
57
57
 
58
58
  if (!lazyLoadProductsRecommended) {
59
59
  if (category?.id) {
60
- scrollViewRef.current.scrollTo({
60
+ scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
61
61
  y: categoriesLayout[`cat_${category?.id}`]?.y + productListLayout?.y - 70,
62
62
  animated: true
63
63
  })
64
64
  } else {
65
- scrollViewRef.current.scrollTo({
65
+ scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
66
66
  y: productListLayout?.y - 70,
67
67
  animated: true
68
68
  })
@@ -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
  {
@@ -0,0 +1,44 @@
1
+ import React from 'react'
2
+ import { OModal, OText, OIcon } from '../../shared'
3
+ import { ScrollView } from 'react-native'
4
+ import { useUtils } from 'ordering-components/native'
5
+
6
+ interface CategoryDescriptionParams {
7
+ openDescription?: {name: string, image: string, description: string} | null,
8
+ setOpenDescription: any;
9
+ }
10
+
11
+ function categoryDescriptionPropsAreEqual(prev : any, next : any) {
12
+ return prev.openDescription === next.openDescription
13
+ }
14
+
15
+ const CategoryDescription = (props : CategoryDescriptionParams) => {
16
+ const [{ optimizeImage }] = useUtils()
17
+ return (
18
+ <OModal
19
+ open={!!props.openDescription}
20
+ onClose={() => props.setOpenDescription(null)}
21
+ styleContainerCloseButton={{
22
+ marginLeft: -37,
23
+ width: 55,
24
+ height: 55,
25
+ marginTop: 2
26
+ }}
27
+ >
28
+ <OText size={20} style={{ paddingLeft: 70, paddingRight: 20, bottom: 25 }}>{props.openDescription?.name}</OText>
29
+ <ScrollView style={{ padding: 20 }}>
30
+ {!!props.openDescription?.image && (
31
+ <OIcon
32
+ url={optimizeImage(props.openDescription?.image, 'h_100,c_limit')}
33
+ width={240}
34
+ height={240}
35
+ style={{ borderRadius: 7.6 }}
36
+ />
37
+ )}
38
+ <OText mBottom={60}>{props.openDescription?.description}</OText>
39
+ </ScrollView>
40
+ </OModal>
41
+ )
42
+ }
43
+
44
+ export const CategoryDescriptionMemoized = React.memo(CategoryDescription,categoryDescriptionPropsAreEqual)
@@ -4,11 +4,13 @@ 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
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'
13
+ import { CategoryDescriptionMemoized } from './CategoryDescription';
12
14
 
13
15
  const BusinessProductsListUI = (props: BusinessProductsListParams) => {
14
16
  const {
@@ -27,7 +29,13 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
27
29
  handleCancelSearch,
28
30
  categoriesLayout,
29
31
  setCategoriesLayout,
30
- currentCart
32
+ currentCart,
33
+ setSubcategoriesSelected,
34
+ subcategoriesSelected,
35
+ onClickCategory,
36
+ lazyLoadProductsRecommended,
37
+ handleUpdateProducts,
38
+ isFiltMode
31
39
  } = props;
32
40
 
33
41
  const [, t] = useLanguage();
@@ -43,20 +51,86 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
43
51
  setCategoriesLayout(_categoriesLayout)
44
52
  }
45
53
 
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)}
54
+ const onClickSubcategory = (subCategory: any, parentCategory: any) => {
55
+ if (parentCategory && lazyLoadProductsRecommended) {
56
+ onClickCategory(parentCategory)
57
+ }
58
+ if (!subCategory) {
59
+ setSubcategoriesSelected?.(subcategoriesSelected.filter((_subcategory: any) => _subcategory?.parent_category_id !== parentCategory?.id))
60
+ return
61
+ }
62
+ const categoryFounded = subcategoriesSelected.find((_subcategory: any) => subCategory?.id === _subcategory?.id)
63
+ if (categoryFounded) {
64
+ setSubcategoriesSelected?.(subcategoriesSelected.filter((_subcategory: any) => subCategory?.id !== _subcategory?.id))
65
+ } else {
66
+ setSubcategoriesSelected?.([...subcategoriesSelected, subCategory])
67
+ }
68
+ }
69
+
70
+ const SubcategoriesComponent = ({ category }: any) => {
71
+ const allsubcategorySelected = !subcategoriesSelected?.some((subcategory: any) => category?.id === subcategory?.parent_category_id)
72
+
73
+ return (
74
+ <SubCategoriesContainer>
75
+ <ContainerButton
76
+ isSelected={allsubcategorySelected}
77
+ >
78
+ <OButton
79
+ onClick={() => onClickSubcategory(null, category)}
80
+ bgColor={allsubcategorySelected ? theme.colors.primary : theme.colors.backgroundGray}
81
+ text={`${t('ALL', 'All')} ${allsubcategorySelected ? 'X' : ''}`}
82
+ style={bpStyles.categoryButtonStyle}
83
+ textStyle={{ color: allsubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
57
84
  />
58
- ))}
85
+ </ContainerButton>
86
+ {category?.subcategories?.map((subcategory: any) => {
87
+ const isSubcategorySelected = subcategoriesSelected?.find((_subcategory: any) => _subcategory?.id === subcategory?.id)
88
+ return (
89
+ <ContainerButton
90
+ key={subcategory?.id}
91
+ isSelected={isSubcategorySelected}
92
+ >
93
+ <OButton
94
+ onClick={() => onClickSubcategory(subcategory, category)}
95
+ bgColor={isSubcategorySelected ? theme.colors.primary : theme.colors.backgroundGray}
96
+ text={`${subcategory?.name} ${isSubcategorySelected ? 'X' : ''}`}
97
+ style={bpStyles.categoryButtonStyle}
98
+ textStyle={{ color: isSubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
99
+ />
100
+ </ContainerButton>
101
+ )
102
+ }
103
+ )}
104
+ </SubCategoriesContainer>
105
+ )
106
+ }
59
107
 
108
+ return (
109
+ <ProductsContainer renderToHardwareTextureAndroid={categoryState.loading || isBusinessLoading}>
110
+ <HeaderWrapper>
111
+ {category?.subcategories?.length > 0 && (
112
+ <SubcategoriesComponent category={category} />
113
+ )}
114
+ </HeaderWrapper>
115
+ {category.id &&
116
+ categoryState.products
117
+ ?.filter((product: any) =>
118
+ !subcategoriesSelected.find((subcategory: any) => subcategory?.parent_category_id === category?.id) ||
119
+ subcategoriesSelected?.some((subcategory: any) => subcategory.id === product?.category_id))
120
+ ?.sort((a: any, b: any) => a.rank - b.rank)
121
+ ?.map((product: any, i: number) => (
122
+ <SingleProductCard
123
+ key={'prod_' + product.id + `_${i}`}
124
+ isSoldOut={product.inventoried && !product.quantity}
125
+ product={product}
126
+ businessId={businessId}
127
+ categoryState={categoryState}
128
+ onProductClick={() => onProductClick(product)}
129
+ productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
130
+ handleUpdateProducts={handleUpdateProducts}
131
+ />
132
+ ))
133
+ }
60
134
  {!category.id &&
61
135
  featured &&
62
136
  categoryState?.products?.find((product: any) => product.featured) && (
@@ -71,11 +145,13 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
71
145
  (product: any, i: any) =>
72
146
  product.featured && (
73
147
  <SingleProductCard
74
- key={i}
148
+ key={'feat_' + product.id + `_${i}`}
75
149
  isSoldOut={product.inventoried && !product.quantity}
76
150
  product={product}
77
151
  businessId={businessId}
152
+ categoryState={categoryState}
78
153
  onProductClick={onProductClick}
154
+ handleUpdateProducts={handleUpdateProducts}
79
155
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
80
156
  />
81
157
  ),
@@ -85,9 +161,14 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
85
161
  )}
86
162
 
87
163
  {!category?.id && categories.filter(category => category?.id !== null).map((category, i, _categories) => {
88
- const products = !isUseParentCategory
164
+ const _products = !isUseParentCategory
89
165
  ? categoryState?.products?.filter((product: any) => product?.category_id === category?.id) ?? []
90
166
  : categoryState?.products?.filter((product: any) => category?.children?.some((cat: any) => cat.category_id === product?.category_id)) ?? []
167
+ const products = subcategoriesSelected?.length > 0
168
+ ? _products?.filter((product: any) =>
169
+ !subcategoriesSelected.find((subcategory: any) => subcategory?.parent_category_id === category?.id) ||
170
+ subcategoriesSelected?.some((subcategory: any) => subcategory.id === product?.category_id))
171
+ : _products
91
172
 
92
173
  const shortCategoryDescription = category?.description?.length > 80 ? `${category?.description?.substring(0, 80)}...` : category?.description
93
174
 
@@ -110,15 +191,33 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
110
191
  <OText size={16} weight="600">
111
192
  {category.name}
112
193
  </OText>
194
+ {category?.ribbon?.enabled && (
195
+ <RibbonBox
196
+ bgColor={category?.ribbon?.color}
197
+ isRoundRect={category?.ribbon?.shape === shape?.rectangleRound}
198
+ isCapsule={category?.ribbon?.shape === shape?.capsuleShape}
199
+ >
200
+ <OText
201
+ size={10}
202
+ weight={'400'}
203
+ color={theme.colors.white}
204
+ numberOfLines={2}
205
+ ellipsizeMode='tail'
206
+ lineHeight={13}
207
+ >
208
+ {category?.ribbon?.text}
209
+ </OText>
210
+ </RibbonBox>
211
+ )}
113
212
  </View>
114
213
  {!!category?.description && (
115
214
  <View style={{ position: 'relative' }}>
116
- <OText size={12} weight={'500'} mBottom={5}>
215
+ <OText size={12} weight={'500'} mBottom={10} color='#909BA9'>
117
216
  {shortCategoryDescription}
118
217
  {category?.description?.length > 80 && (
119
218
  <OButton
120
219
  style={{ height: 15, paddingRight: 0, paddingLeft: 0, borderWidth: 0 }}
121
- text={t('SEE_MORE', 'See more')}
220
+ text={t('VIEW_MORE', 'View more')}
122
221
  parentStyle={{ padding: 0 }}
123
222
  onClick={() => setOpenDescription(category)}
124
223
  bgColor='transparent'
@@ -133,14 +232,19 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
133
232
  </OText>
134
233
  </View>
135
234
  )}
235
+ {category?.subcategories?.length > 0 && !isFiltMode && (
236
+ <SubcategoriesComponent category={category} />
237
+ )}
136
238
  <>
137
239
  {products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
138
240
  <SingleProductCard
139
- key={i}
241
+ key={`${product?.id}_${i}`}
140
242
  isSoldOut={product.inventoried && !product.quantity}
141
243
  businessId={businessId}
142
244
  product={product}
245
+ categoryState={categoryState}
143
246
  onProductClick={onProductClick}
247
+ handleUpdateProducts={handleUpdateProducts}
144
248
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
145
249
  />
146
250
  ))}
@@ -176,6 +280,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
176
280
  !isBusinessLoading &&
177
281
  categoryState.products.length === 0 &&
178
282
  !errors &&
283
+ !isFiltMode &&
179
284
  !(
180
285
  (searchValue && errorQuantityProducts) ||
181
286
  (!searchValue && !errorQuantityProducts)
@@ -215,23 +320,12 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
215
320
  <OText>{e}</OText>
216
321
  </ErrorMessage>
217
322
  ))}
218
- <OModal
219
- open={!!openDescription}
220
- title={openDescription?.name}
221
- onClose={() => setOpenDescription(null)}
222
- >
223
- <ScrollView style={{ padding: 20 }}>
224
- {!!openDescription?.image && (
225
- <OIcon
226
- url={optimizeImage(openDescription?.image, 'h_100,c_limit')}
227
- width={240}
228
- height={240}
229
- style={{ borderRadius: 7.6 }}
230
- />
231
- )}
232
- <OText>{openDescription?.description}</OText>
233
- </ScrollView>
234
- </OModal>
323
+ {!!openDescription && (
324
+ <CategoryDescriptionMemoized
325
+ openDescription={openDescription}
326
+ setOpenDescription={setOpenDescription}
327
+ />
328
+ )}
235
329
  </ProductsContainer>
236
330
  );
237
331
  };
@@ -246,6 +340,15 @@ const bpStyles = StyleSheet.create({
246
340
  shadowRadius: 1,
247
341
  marginEnd: 13,
248
342
  },
343
+ categoryButtonStyle: {
344
+ borderWidth: 0,
345
+ marginLeft: 5,
346
+ marginRight: 5,
347
+ marginBottom: 10,
348
+ height: 35,
349
+ paddingLeft: 3,
350
+ paddingRight: 3,
351
+ }
249
352
  });
250
353
 
251
354
  export const BusinessProductsList = (props: BusinessProductsListParams) => {