ordering-ui-react-native 0.15.36 → 0.15.37-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 (187) 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/StripeMethodForm/index.tsx +1 -2
  17. package/src/components/UpsellingProducts/index.tsx +1 -1
  18. package/src/components/UserProfileForm/index.tsx +63 -6
  19. package/src/components/UserProfileForm/styles.tsx +8 -0
  20. package/src/components/VerifyPhone/styles.tsx +1 -2
  21. package/src/components/shared/OModal.tsx +1 -1
  22. package/src/config.json +0 -2
  23. package/src/hooks/useCountdownTimer.tsx +26 -0
  24. package/src/navigators/CheckoutNavigator.tsx +6 -0
  25. package/src/navigators/HomeNavigator.tsx +12 -0
  26. package/src/pages/BusinessProductsList.tsx +1 -0
  27. package/src/pages/BusinessesListing.tsx +1 -1
  28. package/src/pages/Checkout.tsx +1 -1
  29. package/src/pages/MultiCheckout.tsx +31 -0
  30. package/src/pages/MultiOrdersDetails.tsx +27 -0
  31. package/src/pages/Sessions.tsx +22 -0
  32. package/src/types/index.tsx +5 -11
  33. package/src/utils/index.tsx +68 -1
  34. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  35. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  36. package/themes/business/src/components/Chat/index.tsx +38 -86
  37. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  38. package/themes/business/src/components/Home/index.tsx +128 -55
  39. package/themes/business/src/components/Home/styles.tsx +8 -1
  40. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  41. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  42. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  43. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  44. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  45. package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
  46. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +157 -89
  47. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  48. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  49. package/themes/business/src/components/OrdersListManager/index.tsx +52 -49
  50. package/themes/business/src/components/OrdersOption/index.tsx +57 -50
  51. package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
  52. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  53. package/themes/business/src/components/shared/OModal.tsx +1 -1
  54. package/themes/business/src/types/index.tsx +5 -1
  55. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  57. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  58. package/themes/kiosk/src/components/Cart/index.tsx +99 -25
  59. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  60. package/themes/kiosk/src/components/Checkout/index.tsx +34 -22
  61. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  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/shared/OButton.tsx +5 -18
  70. package/themes/kiosk/src/types/index.d.ts +2 -0
  71. package/themes/original/index.tsx +190 -1
  72. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  73. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  74. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  75. package/themes/original/src/components/AddressList/index.tsx +56 -18
  76. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  77. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  78. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  79. package/themes/original/src/components/BusinessController/index.tsx +56 -19
  80. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  81. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  82. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  83. package/themes/original/src/components/BusinessItemAccordion/index.tsx +4 -3
  84. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  85. package/themes/original/src/components/BusinessListingSearch/index.tsx +200 -58
  86. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  87. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  88. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
  89. package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
  90. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  91. package/themes/original/src/components/BusinessProductsList/index.tsx +139 -36
  92. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  93. package/themes/original/src/components/BusinessProductsListing/index.tsx +116 -26
  94. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  95. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  96. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  97. package/themes/original/src/components/BusinessesListing/index.tsx +127 -67
  98. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  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/MyOrders/index.tsx +120 -32
  132. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  133. package/themes/original/src/components/OrderDetails/index.tsx +50 -35
  134. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  135. package/themes/original/src/components/OrderProgress/index.tsx +3 -3
  136. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  137. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  138. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  139. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  140. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  141. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  142. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  143. package/themes/original/src/components/OrdersOption/index.tsx +133 -41
  144. package/themes/original/src/components/OrdersOption/styles.tsx +4 -7
  145. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  146. package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
  147. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  148. package/themes/original/src/components/PaymentOptions/index.tsx +9 -21
  149. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  150. package/themes/original/src/components/PreviousOrders/index.tsx +18 -145
  151. package/themes/original/src/components/ProductForm/index.tsx +76 -61
  152. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  153. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  154. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  155. package/themes/original/src/components/Promotions/index.tsx +250 -0
  156. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  157. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  158. package/themes/original/src/components/Sessions/index.tsx +160 -0
  159. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  160. package/themes/original/src/components/SignupForm/index.tsx +9 -4
  161. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  162. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  163. package/themes/original/src/components/SingleProductCard/index.tsx +95 -32
  164. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  165. package/themes/original/src/components/StripeElementsForm/index.tsx +10 -2
  166. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  167. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  168. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  169. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  170. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  171. package/themes/original/src/components/UserProfile/index.tsx +62 -8
  172. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  173. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  174. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  175. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  176. package/themes/original/src/components/Wallets/index.tsx +76 -9
  177. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  178. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  179. package/themes/original/src/components/shared/OModal.tsx +4 -2
  180. package/themes/original/src/components/shared/index.tsx +2 -0
  181. package/themes/original/src/config/constants.tsx +6 -6
  182. package/themes/original/src/types/index.tsx +132 -9
  183. package/themes/original/src/utils/index.tsx +28 -2
  184. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  185. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  186. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  187. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -85,8 +85,7 @@ const CheckoutUI = (props: any) => {
85
85
  deliveryOptionSelected,
86
86
  instructionsOptions,
87
87
  handleChangeDeliveryOption,
88
- currency,
89
- merchantId
88
+ currency
90
89
  } = props
91
90
 
92
91
  const theme = useTheme();
@@ -113,7 +112,10 @@ const CheckoutUI = (props: any) => {
113
112
  right: Platform.OS === 'ios' ? 5 : (I18nManager.isRTL ? 30 : 0),
114
113
  position: 'absolute',
115
114
  fontSize: 20
116
- }
115
+ },
116
+ wrapperNavbar: Platform.OS === 'ios'
117
+ ? { paddingVertical: 0, paddingHorizontal: 40 }
118
+ : { paddingVertical: 20, paddingHorizontal: 40 }
117
119
  })
118
120
 
119
121
  const [, { showToast }] = useToast();
@@ -133,11 +135,20 @@ const CheckoutUI = (props: any) => {
133
135
  const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
134
136
  const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
135
137
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
136
-
138
+
137
139
  const placeSpotTypes = [3, 4]
138
- const isWalletEnabled = configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
140
+ const businessConfigs = businessDetails?.business?.configs ?? []
141
+ const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
142
+ const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
143
+ const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (isWalletCashEnabled || isWalletCreditPointsEnabled)
144
+
139
145
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
140
- const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) || placing || errorCash || cart?.subtotal < cart?.minimum || (placeSpotTypes.includes(options?.type) && !cart?.place)
146
+ const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) || placing || errorCash ||
147
+ cart?.subtotal < cart?.minimum || (placeSpotTypes.includes(options?.type) && !cart?.place) ||
148
+ (options.type === 1 &&
149
+ validationFields?.fields?.checkout?.driver_tip?.enabled &&
150
+ validationFields?.fields?.checkout?.driver_tip?.required &&
151
+ (Number(cart?.driver_tip) <= 0))
141
152
 
142
153
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
143
154
  ? JSON.parse(configs?.driver_tip_options?.value) || []
@@ -239,7 +250,7 @@ const CheckoutUI = (props: any) => {
239
250
 
240
251
  useEffect(() => {
241
252
  if (cart?.products?.length === 0) {
242
- navigation?.canGoBack() && navigation.goBack();
253
+ onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null })
243
254
  }
244
255
  }, [cart?.products])
245
256
 
@@ -250,13 +261,18 @@ const CheckoutUI = (props: any) => {
250
261
  return (
251
262
  <>
252
263
  <Container noPadding>
253
- <NavBar
254
- isVertical
255
- onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
256
- title={t('CHECKOUT', 'Checkout')}
257
- titleStyle={{ marginLeft: 0, marginRight: 0, paddingLeft: 40 }}
258
- btnStyle={{ marginLeft: 40, padding: 40 }}
259
- />
264
+ <View style={styles.wrapperNavbar}>
265
+ <NavBar
266
+ title={t('CHECKOUT', 'Checkout')}
267
+ titleAlign={'center'}
268
+ onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
269
+ showCall={false}
270
+ btnStyle={{ paddingLeft: 0 }}
271
+ style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
272
+ titleWrapStyle={{ paddingHorizontal: 0 }}
273
+ titleStyle={{ marginRight: 0, marginLeft: 0 }}
274
+ />
275
+ </View>
260
276
  <ChContainer style={styles.pagePadding}>
261
277
  <ChSection style={{ paddingTop: 0 }}>
262
278
  <ChHeader>
@@ -547,18 +563,17 @@ const CheckoutUI = (props: any) => {
547
563
  onNavigationRedirect={onNavigationRedirect}
548
564
  paySelected={paymethodSelected}
549
565
  handlePaymentMethodClickCustom={handlePaymentMethodClick}
550
- handlePlaceOrder={handlePlaceOrder}
551
- merchantId={merchantId}
552
566
  />
553
567
  </ChPaymethods>
554
568
  </ChSection>
555
569
  )}
556
570
 
557
- {!cartState.loading && cart && isWalletEnabled && (
571
+ {!cartState.loading && cart && isWalletEnabled && businessDetails?.business?.configs && (
558
572
  <WalletPaymentOptionContainer>
559
573
  <PaymentOptionWallet
560
574
  cart={cart}
561
575
  businessId={cart?.business_id}
576
+ businessConfigs={businessDetails?.business?.configs}
562
577
  />
563
578
  </WalletPaymentOptionContainer>
564
579
  )}
@@ -596,21 +611,19 @@ const CheckoutUI = (props: any) => {
596
611
  </OText>
597
612
  </TouchableOpacity>
598
613
  </CartHeader>
599
- {props.isFranchiseApp && (
600
- <TouchableOpacity
601
- onPress={() => setOpenChangeStore(true)}
602
- style={{ alignSelf: 'flex-start' }}
614
+ <TouchableOpacity
615
+ onPress={() => setOpenChangeStore(true)}
616
+ style={{ alignSelf: 'flex-start' }}
617
+ >
618
+ <OText
619
+ size={12}
620
+ lineHeight={18}
621
+ color={theme.colors.textSecondary}
622
+ style={{ textDecorationLine: 'underline' }}
603
623
  >
604
- <OText
605
- size={12}
606
- lineHeight={18}
607
- color={theme.colors.textSecondary}
608
- style={{ textDecorationLine: 'underline' }}
609
- >
610
- {t('CHANGE_STORE', 'Change store')}
611
- </OText>
612
- </TouchableOpacity>
613
- )}
624
+ {t('CHANGE_STORE', 'Change store')}
625
+ </OText>
626
+ </TouchableOpacity>
614
627
  <OrderSummary
615
628
  cart={cart}
616
629
  isCartPending={cart?.status === 2}
@@ -624,7 +637,7 @@ const CheckoutUI = (props: any) => {
624
637
 
625
638
  {!cartState.loading && cart && (
626
639
  <View>
627
- <ChErrors style={{ marginBottom: 0 }}>
640
+ <ChErrors style={{ marginBottom: 10 }}>
628
641
  {!cart?.valid_address && cart?.status !== 2 && (
629
642
  <OText
630
643
  color={theme.colors.error}
@@ -648,7 +661,7 @@ const CheckoutUI = (props: any) => {
648
661
  color={theme.colors.error}
649
662
  size={12}
650
663
  >
651
- {t('WARNING_INVALID_PRODUCTS', 'Some products are invalid, please check them.')}
664
+ {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
652
665
  </OText>
653
666
  )}
654
667
  {placeSpotTypes.includes(options?.type) && !cart?.place && (
@@ -659,11 +672,22 @@ const CheckoutUI = (props: any) => {
659
672
  {t('WARNING_PLACE_SPOT', 'Please, select your spot to place order.')}
660
673
  </OText>
661
674
  )}
675
+ {options.type === 1 &&
676
+ validationFields?.fields?.checkout?.driver_tip?.enabled &&
677
+ validationFields?.fields?.checkout?.driver_tip?.required &&
678
+ (Number(cart?.driver_tip) <= 0) && (
679
+ <OText
680
+ color={theme.colors.error}
681
+ size={12}
682
+ >
683
+ {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
684
+ </OText>
685
+ )}
662
686
  </ChErrors>
663
687
  </View>
664
688
  )}
665
689
  <OModal
666
- open={openChangeStore && props.isFranchiseApp}
690
+ open={openChangeStore}
667
691
  entireModal
668
692
  customClose
669
693
  onClose={() => setOpenChangeStore(false)}
@@ -707,19 +731,6 @@ const CheckoutUI = (props: any) => {
707
731
  setShowGateway={setShowGateway}
708
732
  />
709
733
  )}
710
- {webviewPaymethod?.gateway === 'square' && showGateway.open && (
711
- <PaymentOptionsWebView
712
- onNavigationRedirect={onNavigationRedirect}
713
- uri={`https://test-square-f50f7.web.app`}
714
- user={user}
715
- token={token}
716
- cart={cart}
717
- currency={currency}
718
- webviewPaymethod={webviewPaymethod}
719
- setShowGateway={setShowGateway}
720
- locationId={'L1NGAY5M6KJRX'}
721
- />
722
- )}
723
734
  </>
724
735
  )
725
736
  }
@@ -872,7 +883,7 @@ export const Checkout = (props: any) => {
872
883
  ...props,
873
884
  UIComponent: CheckoutUI,
874
885
  cartState,
875
- [props.isFranchiseApp ? 'uuid' : 'businessId']: props.isFranchiseApp ? cartUuid : cartState.cart?.business_id
886
+ uuid: cartUuid
876
887
  }
877
888
 
878
889
  return (
@@ -48,22 +48,28 @@ const DriverTipsUI = (props: any) => {
48
48
  }
49
49
  })
50
50
 
51
- const [value, setvalue] = useState(0);
51
+ const [value, setvalue] = useState('');
52
52
 
53
53
  const placeholderCurrency = (configs?.currency_position?.value || 'left') === 'left'
54
54
  ? `${configs?.format_number_currency?.value}0`
55
55
  : `0${configs?.format_number_currency?.value}`
56
56
 
57
57
  const handleChangeDriverTip = (val: any) => {
58
- let tip = parseFloat(val)
59
- tip = isNaN(tip) ? 0 : tip
60
- setvalue(tip)
58
+ const tip = Number(val)
59
+ if ((isNaN(tip) || tip < 0)) {
60
+ setvalue(value)
61
+ return
62
+ }
63
+ setvalue(val)
61
64
  }
62
-
65
+
63
66
  return (
64
67
  <DTContainer>
68
+ <DTLabel>
69
+ {t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
70
+ </DTLabel>
65
71
  <DTWrapperTips>
66
- {driverTipsOptions.map((option: any, i: number) => (
72
+ {!isDriverTipUseCustom && driverTipsOptions.map((option: any, i: number) => (
67
73
  <TouchableOpacity
68
74
  key={i}
69
75
  onPress={() => handlerChangeOption(option)}
@@ -79,7 +85,7 @@ const DriverTipsUI = (props: any) => {
79
85
  </TouchableOpacity>
80
86
  ))}
81
87
  </DTWrapperTips>
82
- {!driverTipsOptions.includes(driverTip) && driverTip > 0 && (
88
+ {(!isDriverTipUseCustom && !driverTipsOptions.includes(driverTip) && driverTip > 0) && (
83
89
  <OText
84
90
  color={theme.colors.error}
85
91
  size={16}
@@ -90,13 +96,12 @@ const DriverTipsUI = (props: any) => {
90
96
  )}
91
97
  {isDriverTipUseCustom && (
92
98
  <DTForm>
93
- <DTLabel>
94
- {t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
95
- </DTLabel>
96
99
  <DTWrapperInput>
97
100
  <OInput
98
101
  placeholder={placeholderCurrency}
99
102
  style={style.inputStyle}
103
+ value={value}
104
+ type={'numeric'}
100
105
  onChange={handleChangeDriverTip}
101
106
  autoCapitalize='none'
102
107
  autoCorrect={false}
@@ -108,10 +113,10 @@ const DriverTipsUI = (props: any) => {
108
113
  textStyle={{ color: 'white', fontSize: 14 }}
109
114
  imgRightSrc={null}
110
115
  style={{ borderRadius: 5, height: 44 }}
111
- isDisabled={!(value > 0 && value !== driverTip) || !value}
116
+ isDisabled={parseFloat(value || '0') < 0 || parseFloat(value || '0') === driverTip || value === ''}
112
117
  onClick={() => {
113
118
  handlerChangeOption(value)
114
- setvalue(0)
119
+ setvalue('')
115
120
  }}
116
121
  />
117
122
  </DTWrapperInput>
@@ -0,0 +1,91 @@
1
+ import React, { useState } from 'react'
2
+ import { useLanguage, useOrder } from 'ordering-components/native'
3
+ import { useTheme } from 'styled-components/native'
4
+ import { FavoriteList } from '../FavoriteList'
5
+ import NavBar from '../NavBar'
6
+ import { OText } from '../shared'
7
+
8
+ import {
9
+ TabContainer,
10
+ Tab,
11
+ Container
12
+ } from './styles'
13
+
14
+ export const Favorite = (props: any) => {
15
+ const {
16
+ navigation
17
+ } = props
18
+ const [, t] = useLanguage()
19
+ const theme = useTheme()
20
+ const [orderState] = useOrder()
21
+ const [tabSelected, setTabSelected] = useState('businesses')
22
+
23
+ const tabList = [
24
+ { key: 'businesses', name: t('BUSINESSES', 'Businesses') },
25
+ { key: 'products', name: t('PRODUCTS', 'Products') },
26
+ { key: 'orders', name: t('ORDERS', 'Orders') }
27
+ ]
28
+
29
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
30
+
31
+ const onRedirect = (route: string, params?: any) => {
32
+ navigation.navigate(route, params)
33
+ }
34
+
35
+ return (
36
+ <Container>
37
+ <NavBar
38
+ title={t('FAVORITE', 'Favorite')}
39
+ titleAlign={'center'}
40
+ onActionLeft={goToBack}
41
+ showCall={false}
42
+ paddingTop={10}
43
+ btnStyle={{ paddingLeft: 0 }}
44
+ />
45
+ <TabContainer>
46
+ {tabList.map((menu, i) => (
47
+ <Tab
48
+ key={i}
49
+ active={menu.key === tabSelected}
50
+ onPress={() => setTabSelected(menu.key)}
51
+ >
52
+ <OText
53
+ color={menu.key === tabSelected ? theme.colors.textNormal : theme.colors.disabled}
54
+ size={14}
55
+ weight={menu.key === tabSelected ? '500' : '400'}
56
+ style={{ marginBottom: 12 }}
57
+ >
58
+ {menu.name}
59
+ </OText>
60
+ </Tab>
61
+ ))}
62
+ </TabContainer>
63
+ {tabSelected === 'businesses' && (
64
+ <FavoriteList
65
+ navigation={navigation}
66
+ onNavigationRedirect={onRedirect}
67
+ isBusiness
68
+ favoriteURL='favorite_businesses'
69
+ originalURL='business'
70
+ location={`${orderState.options?.address?.location?.lat},${orderState.options?.address?.location?.lng}`}
71
+ propsToFetch={['id', 'name', 'header', 'logo', 'location', 'address', 'ribbon', 'timezone', 'schedule', 'open', 'delivery_price', 'distance', 'delivery_time', 'pickup_time', 'reviews', 'featured', 'offers', 'food', 'laundry', 'alcohol', 'groceries', 'slug']}
72
+ />
73
+ )}
74
+ {tabSelected === 'products' && (
75
+ <FavoriteList
76
+ favoriteURL='favorite_products'
77
+ originalURL='products'
78
+ isProduct
79
+ />
80
+ )}
81
+ {tabSelected === 'orders' && (
82
+ <FavoriteList
83
+ onNavigationRedirect={onRedirect}
84
+ favoriteURL='favorite_orders'
85
+ originalURL='orders'
86
+ isOrder
87
+ />
88
+ )}
89
+ </Container>
90
+ )
91
+ }
@@ -0,0 +1,22 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const TabContainer = styled.View`
4
+ flex-direction: row;
5
+ border-bottom-color: ${(props: any) => props.theme.colors.border};
6
+ border-bottom-width: 1px;
7
+ margin-bottom: 25px;
8
+ `
9
+
10
+ export const Tab = styled.TouchableOpacity`
11
+ margin-right: 32px;
12
+ ${(props: any) => props.active && css`
13
+ border-bottom-color: ${(props: any) => props.theme.colors.textNormal};
14
+ border-bottom-width: 1px;
15
+ `}
16
+ `
17
+
18
+ export const Container = styled.View`
19
+ padding-horizontal: 40px;
20
+ padding-bottom: 20px;
21
+ padding-top: 30px;
22
+ `
@@ -0,0 +1,287 @@
1
+ import React, { useEffect } from 'react';
2
+ import { View } from 'react-native';
3
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
4
+ import { FavoriteParams } from '../../types';
5
+ import { SingleOrderCard } from '../SingleOrderCard';
6
+ import {
7
+ FavoriteList as FavoriteListController,
8
+ useOrder,
9
+ useLanguage
10
+ } from 'ordering-components/native';
11
+ import { useTheme } from 'styled-components/native';
12
+ import { _setStoreData } from '../../providers/StoreUtil';
13
+ import { Container, WrappButton } from './styles'
14
+ import { OButton } from '../shared';
15
+ import { BusinessController } from '../BusinessController';
16
+ import { SingleProductCard } from '../SingleProductCard';
17
+ import moment from 'moment';
18
+
19
+
20
+ const FavoriteListUI = (props: FavoriteParams) => {
21
+ const {
22
+ favoriteList,
23
+ handleUpdateFavoriteList,
24
+ pagination,
25
+ getFavoriteList,
26
+ navigation,
27
+ onNavigationRedirect,
28
+ reorderState,
29
+ handleReorder,
30
+ isBusiness,
31
+ isOrder,
32
+ isProduct
33
+ } = props
34
+
35
+ const theme = useTheme();
36
+ const [, t] = useLanguage()
37
+ const [orderState] = useOrder();
38
+ const [{ carts }] = useOrder()
39
+
40
+ const pastOrders = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
41
+
42
+ const getOrderStatus = (s: any) => {
43
+ const status = parseInt(s)
44
+ const orderStatus = [
45
+ { key: 0, value: t('PENDING', theme?.defaultLanguages?.PENDING || 'Pending') },
46
+ { key: 1, value: t('COMPLETED', theme?.defaultLanguages?.COMPLETED || 'Completed') },
47
+ { key: 2, value: t('REJECTED', theme?.defaultLanguages?.REJECTED || 'Rejected') },
48
+ { key: 3, value: t('DRIVER_IN_BUSINESS', theme?.defaultLanguages?.DRIVER_IN_BUSINESS || 'Driver in business') },
49
+ { key: 4, value: t('PREPARATION_COMPLETED', theme?.defaultLanguages?.PREPARATION_COMPLETED || 'Preparation Completed') },
50
+ { key: 5, value: t('REJECTED_BY_BUSINESS', theme?.defaultLanguages?.REJECTED_BY_BUSINESS || 'Rejected by business') },
51
+ { key: 6, value: t('REJECTED_BY_DRIVER', theme?.defaultLanguages?.REJECTED_BY_DRIVER || 'Rejected by Driver') },
52
+ { key: 7, value: t('ACCEPTED_BY_BUSINESS', theme?.defaultLanguages?.ACCEPTED_BY_BUSINESS || 'Accepted by business') },
53
+ { key: 8, value: t('ACCEPTED_BY_DRIVER', theme?.defaultLanguages?.ACCEPTED_BY_DRIVER || 'Accepted by driver') },
54
+ { key: 9, value: t('PICK_UP_COMPLETED_BY_DRIVER', theme?.defaultLanguages?.PICK_UP_COMPLETED_BY_DRIVER || 'Pick up completed by driver') },
55
+ { key: 10, value: t('PICK_UP_FAILED_BY_DRIVER', theme?.defaultLanguages?.PICK_UP_FAILED_BY_DRIVER || 'Pick up Failed by driver') },
56
+ { key: 11, value: t('DELIVERY_COMPLETED_BY_DRIVER', theme?.defaultLanguages?.DELIVERY_COMPLETED_BY_DRIVER || 'Delivery completed by driver') },
57
+ { key: 12, value: t('DELIVERY_FAILED_BY_DRIVER', theme?.defaultLanguages?.DELIVERY_FAILED_BY_DRIVER || 'Delivery Failed by driver') },
58
+ { key: 13, value: t('PREORDER', theme?.defaultLanguages?.PREORDER || 'PreOrder') },
59
+ { key: 14, value: t('ORDER_NOT_READY', theme?.defaultLanguages?.ORDER_NOT_READY || 'Order not ready') },
60
+ { key: 15, value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER || 'Order picked up completed by customer') },
61
+ { key: 16, value: t('ORDER_STATUS_CANCELLED_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_STATUS_CANCELLED_BY_CUSTOMER || 'Order cancelled by customer') },
62
+ { key: 17, value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_NOT_PICKEDUP_BY_CUSTOMER || 'Order not picked up by customer') },
63
+ { key: 18, value: t('ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS || 'Driver almost arrived to business') },
64
+ { key: 19, value: t('ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER', theme?.defaultLanguages?.ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER || 'Driver almost arrived to customer') },
65
+ { key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS || 'Customer almost arrived to business') },
66
+ { key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ARRIVED_BUSINESS || 'Customer arrived to business') },
67
+ { key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', theme?.defaultLanguages?.ORDER_LOOKING_FOR_DRIVER || 'Looking for driver') },
68
+ { key: 23, value: t('ORDER_DRIVER_ON_WAY', theme?.defaultLanguages?.ORDER_DRIVER_ON_WAY || 'Driver on way') }
69
+ ]
70
+
71
+ const objectStatus = orderStatus.find((o) => o.key === status)
72
+
73
+ return objectStatus && objectStatus
74
+ }
75
+
76
+ useEffect(() => {
77
+ const _businessId = 'businessId:' + reorderState?.result?.business_id
78
+ if (reorderState?.error) {
79
+ if (reorderState?.result?.business_id) {
80
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
81
+ onNavigationRedirect && onNavigationRedirect('Business', { store: reorderState?.result?.business?.slug })
82
+ }
83
+ }
84
+ if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
85
+ const cartProducts = carts?.[_businessId]?.products
86
+ const available = cartProducts.every((product: any) => product.valid === true)
87
+ const orderProducts = favoriteList?.favorites.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
88
+
89
+ if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
90
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
91
+ } else {
92
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
93
+ cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
94
+ onNavigationRedirect && onNavigationRedirect('Business', { store: reorderState?.result?.business?.slug })
95
+ }
96
+ }
97
+ }, [reorderState])
98
+
99
+ const handleBusinessClick = (business: any) => {
100
+ onNavigationRedirect && onNavigationRedirect('Business', {
101
+ store: business.slug,
102
+ header: business.header,
103
+ logo: business.logo,
104
+ });
105
+ }
106
+
107
+ const BusinessSkeleton = () => {
108
+ return (
109
+ <Placeholder
110
+ Animation={Fade}
111
+ style={{ marginBottom: 20 }}>
112
+ <View style={{ width: '100%' }}>
113
+ <PlaceholderLine
114
+ height={200}
115
+ style={{ marginBottom: 20, borderRadius: 25 }}
116
+ />
117
+ <View style={{ paddingHorizontal: 10 }}>
118
+ <View
119
+ style={{
120
+ flexDirection: 'row',
121
+ justifyContent: 'space-between',
122
+ }}>
123
+ <PlaceholderLine
124
+ height={25}
125
+ width={40}
126
+ style={{ marginBottom: 10 }}
127
+ />
128
+ <PlaceholderLine
129
+ height={25}
130
+ width={20}
131
+ style={{ marginBottom: 10 }}
132
+ />
133
+ </View>
134
+ <PlaceholderLine
135
+ height={20}
136
+ width={30}
137
+ style={{ marginBottom: 10 }}
138
+ />
139
+ <PlaceholderLine
140
+ height={20}
141
+ width={80}
142
+ style={{ marginBottom: 10 }}
143
+ />
144
+ </View>
145
+ </View>
146
+ </Placeholder>
147
+ )
148
+ }
149
+
150
+ const ProductSkeleton = () => {
151
+ return (
152
+ <Placeholder style={{ padding: 5 }} Animation={Fade}>
153
+ <View style={{ flexDirection: 'row' }}>
154
+ <PlaceholderLine
155
+ width={24}
156
+ height={70}
157
+ style={{ marginRight: 10, marginBottom: 10 }}
158
+ />
159
+ <Placeholder style={{ paddingVertical: 10 }}>
160
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
161
+ <PlaceholderLine width={20} />
162
+ </Placeholder>
163
+ </View>
164
+ </Placeholder>
165
+ )
166
+ }
167
+
168
+ const OrderSkeleton = () => {
169
+ return (
170
+ <Placeholder style={{ padding: 5 }} Animation={Fade}>
171
+ <View style={{ flexDirection: 'row' }}>
172
+ <PlaceholderLine
173
+ width={24}
174
+ height={70}
175
+ style={{ marginRight: 10, marginBottom: 10 }}
176
+ />
177
+ <Placeholder style={{ paddingVertical: 10 }}>
178
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
179
+ <PlaceholderLine width={20} />
180
+ </Placeholder>
181
+ </View>
182
+ </Placeholder>
183
+ )
184
+ }
185
+
186
+ return (
187
+ <Container>
188
+ {isBusiness && (
189
+ <>
190
+ {favoriteList?.favorites?.length > 0 && (
191
+ favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((business: any, i:number) => (
192
+ <BusinessController
193
+ key={`${business.id}_` + i}
194
+ business={business}
195
+ isBusinessOpen={business.open}
196
+ handleCustomClick={handleBusinessClick}
197
+ orderType={orderState?.options?.type}
198
+ navigation={navigation}
199
+ businessHeader={business?.header}
200
+ businessFeatured={business?.featured}
201
+ businessLogo={business?.logo}
202
+ businessReviews={business?.reviews}
203
+ businessDeliveryPrice={business?.delivery_price}
204
+ businessDeliveryTime={business?.delivery_time}
205
+ businessPickupTime={business?.pickup_time}
206
+ businessDistance={business?.distance}
207
+ handleUpdateBusinessList={handleUpdateFavoriteList}
208
+ />
209
+ ))
210
+ )}
211
+ {favoriteList?.loading && (
212
+ [...Array(5).keys()].map(i => (
213
+ <BusinessSkeleton key={i} />
214
+ ))
215
+ )}
216
+ </>
217
+ )}
218
+
219
+ {isOrder && (
220
+ <>
221
+ {favoriteList?.favorites?.length > 0 && (
222
+ favoriteList.favorites?.sort((a: any, b:any) => moment(a?.delivery_datetime_utc).valueOf() - moment(b?.delivery_datetime_utc).valueOf())
223
+ .map((order: any, i: number) => (
224
+ <SingleOrderCard
225
+ key={`${order?.id}_${i}`}
226
+ order={order}
227
+ getOrderStatus={getOrderStatus}
228
+ onNavigationRedirect={onNavigationRedirect}
229
+ pastOrders={pastOrders.includes(order?.status)}
230
+ handleUpdateOrderList={handleUpdateFavoriteList}
231
+ handleUpdateFavoriteList={handleUpdateFavoriteList}
232
+ handleReorder={handleReorder}
233
+ reorderLoading={reorderState?.loading}
234
+ />
235
+ ))
236
+ )}
237
+ {favoriteList?.loading && (
238
+ [...Array(5).keys()].map(i => (
239
+ <OrderSkeleton key={i} />
240
+ ))
241
+ )}
242
+ </>
243
+ )}
244
+
245
+ {isProduct && (
246
+ <>
247
+ {favoriteList?.favorites?.length > 0 && (
248
+ favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((product: any, i: number) => (
249
+ <SingleProductCard
250
+ key={`${product?.id}_${i}`}
251
+ isSoldOut={product.inventoried && !product.quantity}
252
+ product={product}
253
+ onProductClick={() => {}}
254
+ handleUpdateProducts={handleUpdateFavoriteList}
255
+ />
256
+ ))
257
+ )}
258
+ {favoriteList?.loading && (
259
+ [...Array(5).keys()].map(i => (
260
+ <ProductSkeleton key={i} />
261
+ ))
262
+ )}
263
+ </>
264
+ )}
265
+
266
+ {!favoriteList?.loading && pagination.totalPages && pagination.currentPage < pagination.totalPages && (
267
+ <WrappButton>
268
+ <OButton
269
+ onClick={() => getFavoriteList(pagination?.currentPage + 1)}
270
+ text={t('LOAD_MORE_ITEMS', 'Load more items')}
271
+ imgRightSrc={null}
272
+ textStyle={{ color: theme.colors.white }}
273
+ style={{ borderRadius: 7.6, shadowOpacity: 0, marginTop: 20 }}
274
+ />
275
+ </WrappButton>
276
+ )}
277
+ </Container>
278
+ )
279
+ }
280
+
281
+ export const FavoriteList = (props: any) => {
282
+ const favoriteBusinessesProps = {
283
+ ...props,
284
+ UIComponent: FavoriteListUI
285
+ }
286
+ return <FavoriteListController {...favoriteBusinessesProps} />
287
+ }
@@ -0,0 +1,5 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View``
4
+
5
+ export const WrappButton = styled.View``