ordering-ui-react-native 0.15.58 → 0.15.59-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 (186) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessController/index.tsx +16 -8
  5. package/src/components/BusinessTypeFilter/index.tsx +3 -1
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/Checkout/index.tsx +23 -2
  8. package/src/components/DriverTips/index.tsx +11 -6
  9. package/src/components/LanguageSelector/index.tsx +7 -2
  10. package/src/components/LoginForm/index.tsx +120 -30
  11. package/src/components/LoginForm/styles.tsx +6 -0
  12. package/src/components/OrderDetails/index.tsx +7 -21
  13. package/src/components/PaymentOptions/index.tsx +67 -50
  14. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  15. package/src/components/ReviewDriver/index.tsx +1 -1
  16. package/src/components/ReviewOrder/index.tsx +2 -1
  17. package/src/components/ReviewProducts/index.tsx +11 -0
  18. package/src/components/SignupForm/index.tsx +145 -61
  19. package/src/components/SingleProductCard/index.tsx +16 -4
  20. package/src/components/SingleProductReview/index.tsx +1 -1
  21. package/src/components/StripeMethodForm/index.tsx +1 -2
  22. package/src/components/UpsellingProducts/index.tsx +1 -1
  23. package/src/components/UserProfileForm/index.tsx +63 -6
  24. package/src/components/UserProfileForm/styles.tsx +8 -0
  25. package/src/components/VerifyPhone/styles.tsx +1 -2
  26. package/src/components/shared/OModal.tsx +1 -1
  27. package/src/hooks/useCountdownTimer.tsx +26 -0
  28. package/src/navigators/CheckoutNavigator.tsx +6 -0
  29. package/src/navigators/HomeNavigator.tsx +12 -0
  30. package/src/pages/BusinessesListing.tsx +1 -1
  31. package/src/pages/MultiCheckout.tsx +31 -0
  32. package/src/pages/MultiOrdersDetails.tsx +27 -0
  33. package/src/pages/Sessions.tsx +22 -0
  34. package/src/theme.json +0 -1
  35. package/src/types/index.tsx +18 -11
  36. package/src/utils/index.tsx +68 -1
  37. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  38. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  39. package/themes/business/src/components/Chat/index.tsx +42 -90
  40. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  41. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  42. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  43. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  44. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  45. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  46. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  47. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +41 -7
  48. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  49. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  50. package/themes/business/src/components/OrdersOption/index.tsx +5 -2
  51. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  52. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  53. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  54. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  55. package/themes/business/src/components/shared/OModal.tsx +1 -1
  56. package/themes/business/src/types/index.tsx +6 -1
  57. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  58. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  59. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  60. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  61. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  62. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  63. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  64. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  65. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  66. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  67. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  68. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  69. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  70. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  71. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  72. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  73. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  74. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  75. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  76. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  77. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  78. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  79. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  80. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  81. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  82. package/themes/kiosk/src/types/index.d.ts +1 -0
  83. package/themes/original/index.tsx +22 -8
  84. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  85. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  86. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  87. package/themes/original/src/components/AddressList/index.tsx +30 -18
  88. package/themes/original/src/components/AppleLogin/index.tsx +9 -13
  89. package/themes/original/src/components/BusinessBasicInformation/index.tsx +136 -45
  90. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  91. package/themes/original/src/components/BusinessController/index.tsx +48 -11
  92. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  93. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  94. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  95. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  96. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  97. package/themes/original/src/components/BusinessListingSearch/index.tsx +196 -58
  98. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  99. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  100. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  101. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  102. package/themes/original/src/components/BusinessProductsList/index.tsx +51 -53
  103. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  104. package/themes/original/src/components/BusinessProductsListing/index.tsx +105 -22
  105. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  106. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  107. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  108. package/themes/original/src/components/BusinessesListing/index.tsx +126 -65
  109. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  110. package/themes/original/src/components/Cart/index.tsx +60 -41
  111. package/themes/original/src/components/Checkout/index.tsx +48 -32
  112. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  113. package/themes/original/src/components/Favorite/index.tsx +92 -0
  114. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  115. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  116. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  117. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  118. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  119. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  120. package/themes/original/src/components/Help/index.tsx +21 -4
  121. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  122. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  123. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  124. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  125. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  126. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  127. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  128. package/themes/original/src/components/Messages/index.tsx +1 -1
  129. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  130. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  131. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  132. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  133. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  134. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  135. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  136. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  137. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  138. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  139. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  140. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  141. package/themes/original/src/components/OrderDetails/index.tsx +135 -49
  142. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  143. package/themes/original/src/components/OrderSummary/index.tsx +2 -2
  144. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  145. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  146. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  147. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  148. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  149. package/themes/original/src/components/OrdersOption/index.tsx +130 -38
  150. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  151. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  152. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  153. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  154. package/themes/original/src/components/PaymentOptions/index.tsx +57 -36
  155. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  156. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  157. package/themes/original/src/components/ProductForm/index.tsx +70 -62
  158. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  159. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  160. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  161. package/themes/original/src/components/Promotions/index.tsx +151 -133
  162. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  163. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  164. package/themes/original/src/components/Sessions/index.tsx +160 -0
  165. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  166. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  167. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  168. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  169. package/themes/original/src/components/SingleProductCard/index.tsx +59 -17
  170. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  171. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  172. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  173. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  174. package/themes/original/src/components/UserFormDetails/index.tsx +25 -26
  175. package/themes/original/src/components/UserProfile/index.tsx +52 -5
  176. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  177. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  178. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  179. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  180. package/themes/original/src/components/Wallets/index.tsx +76 -9
  181. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  182. package/themes/original/src/components/shared/OModal.tsx +4 -2
  183. package/themes/original/src/types/index.tsx +189 -35
  184. package/themes/original/src/utils/index.tsx +85 -2
  185. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  186. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -12,11 +12,9 @@ export const FormSide = styled.View`
12
12
  margin: auto;
13
13
  `;
14
14
 
15
- export const OTabs = styled.View`
15
+ export const OTabs = styled.ScrollView`
16
16
  flex-direction: row;
17
17
  width: 100%;
18
- flex-wrap: wrap;
19
- justify-content: flex-start;
20
18
  margin-bottom: -1px;
21
19
  `;
22
20
 
@@ -36,7 +36,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
36
36
  loadOrders,
37
37
  setSelectedOrderId,
38
38
  setOrderList,
39
- setOpenMessges
39
+ setOpenMessges,
40
+ setRefreshOrders,
41
+ refreshOrders
40
42
  } = props
41
43
 
42
44
  const theme = useTheme();
@@ -99,6 +101,13 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
99
101
  setOrderList(orderList)
100
102
  }, [orderList, loading])
101
103
 
104
+ useEffect(() => {
105
+ if(refreshOrders){
106
+ loadOrders(false, false, false, true)
107
+ setRefreshOrders && setRefreshOrders(false)
108
+ }
109
+ }, [refreshOrders])
110
+
102
111
  return (
103
112
  <>
104
113
  {!loading && orders.length === 0 && (
@@ -39,7 +39,7 @@ const ORDER_STATUS: any = {
39
39
  23: 'ORDER_DRIVER_ON_WAY'
40
40
  }
41
41
 
42
- const filterSpecialStatus = ['prepared_in', 'delivered_in']
42
+ const filterSpecialStatus = ['prepared_in', 'delivered_in', 'delivery_datetime']
43
43
 
44
44
 
45
45
  const MessagesUI = (props: MessagesParams) => {
@@ -4,6 +4,7 @@ import CalendarStrip from 'react-native-calendar-strip'
4
4
  import {
5
5
  useLanguage,
6
6
  useConfig,
7
+ useUtils,
7
8
  useOrder,
8
9
  MomentOption as MomentOptionController,
9
10
  } from 'ordering-components/native';
@@ -132,6 +133,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
132
133
 
133
134
  const [, t] = useLanguage();
134
135
  const [{ configs }] = useConfig();
136
+ const [{ parseTime }] = useUtils()
135
137
  const [orderState] = useOrder();
136
138
  const [optionSelected, setOptionSelected] = useState({
137
139
  isAsap: false,
@@ -143,6 +145,8 @@ const MomentOptionUI = (props: MomentOptionParams) => {
143
145
  });
144
146
  const { bottom } = useSafeAreaInsets();
145
147
 
148
+ const is12hours = configs?.dates_moment_format?.value?.includes('hh:mm')
149
+
146
150
  const [selectedTime, setSelectedTime] = useState(null);
147
151
  const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
148
152
  const [selectDate, setSelectedDate] = useState<any>(null)
@@ -338,7 +342,12 @@ const MomentOptionUI = (props: MomentOptionParams) => {
338
342
  style={{
339
343
  lineHeight: 24
340
344
  }}
341
- >{time.startTime}</OText>
345
+ >{is12hours ? (
346
+ time.startTime.includes('12')
347
+ ? `${time.startTime}PM`
348
+ : parseTime(moment(time.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
349
+ ) : time.startTime
350
+ }</OText>
342
351
  </TimeItem>
343
352
  </TouchableOpacity>
344
353
  ))}
@@ -18,7 +18,7 @@ export const OrderTimeWrapper = styled.View`
18
18
 
19
19
  export const TimeListWrapper = styled.ScrollView`
20
20
  margin-top: 30px;
21
- max-height: 160px;
21
+ max-height: 210px;
22
22
  `
23
23
 
24
24
  export const TimeContentWrapper = styled.View`
@@ -0,0 +1,243 @@
1
+ import React, { useState } from 'react'
2
+ import {
3
+ useLanguage,
4
+ useConfig,
5
+ useUtils,
6
+ MultiCartsPaymethodsAndWallets as MultiCartsPaymethodsAndWalletsController
7
+ } from 'ordering-components/native'
8
+ import { useTheme } from 'styled-components/native'
9
+ import { View, TouchableOpacity, FlatList, StyleSheet, KeyboardAvoidingView, Platform } from 'react-native'
10
+ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder'
11
+ import { OText, OIcon, OModal, OButton } from '../shared'
12
+ import { getIconCard, flatArray } from '../../utils'
13
+ import { StripeElementsForm } from '../StripeElementsForm'
14
+ import { StripeCardsList } from '../StripeCardsList'
15
+ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
16
+
17
+ import {
18
+ PMContainer,
19
+ PMItem,
20
+ WalletItem
21
+ } from './styles'
22
+
23
+ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
24
+ const {
25
+ businessIds,
26
+ paymethodsAndWallets,
27
+ walletsState,
28
+ businessPaymethods,
29
+ paymethodSelected,
30
+ handleSelectPaymethod,
31
+ handleSelectWallet,
32
+ handlePaymethodDataChange
33
+ } = props
34
+
35
+ const theme = useTheme()
36
+ const [, t] = useLanguage()
37
+ const [{ configs }] = useConfig()
38
+ const [{ parsePrice }] = useUtils()
39
+
40
+ const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
41
+
42
+ const isWalletCashEnabled = configs?.wallet_cash_enabled?.value === '1'
43
+ const isWalletPointsEnabled = configs?.wallet_credit_point_enabled?.value === '1'
44
+
45
+ const walletName: any = {
46
+ cash: {
47
+ name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
48
+ isActive: isWalletCashEnabled
49
+ },
50
+ credit_point: {
51
+ name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
52
+ isActive: isWalletPointsEnabled
53
+ }
54
+ }
55
+
56
+ const getPayIcon = (method: string) => {
57
+ switch (method) {
58
+ case 'cash':
59
+ return theme.images.general.cash
60
+ case 'card_delivery':
61
+ return theme.images.general.carddelivery
62
+ case 'paypal':
63
+ return theme.images.general.paypal
64
+ case 'stripe':
65
+ return theme.images.general.stripe
66
+ case 'stripe_direct':
67
+ return theme.images.general.stripecc
68
+ case 'stripe_connect':
69
+ return theme.images.general.stripes
70
+ case 'stripe_redirect':
71
+ return theme.images.general.stripesb
72
+ default:
73
+ return theme.images.general.creditCard
74
+ }
75
+ }
76
+
77
+ const renderPaymethods = ({ item }: any) => {
78
+ return (
79
+ <TouchableOpacity
80
+ onPress={() => handleSelectPaymethod(item)}
81
+ >
82
+ <PMItem
83
+ key={item.id}
84
+ isActive={paymethodSelected?.paymethod_id === item.paymethod_id}
85
+ >
86
+ <OIcon
87
+ src={getPayIcon(item.paymethod?.gateway)}
88
+ width={20}
89
+ height={20}
90
+ color={paymethodSelected?.paymethod_id === item.paymethod_id ? theme.colors.white : theme.colors.backgroundDark}
91
+ />
92
+ <OText
93
+ size={10}
94
+ style={{ margin: 0, marginTop: 4 }}
95
+ color={paymethodSelected?.paymethod_id === item.paymethod_id ? theme.colors.white : '#000'}
96
+ >
97
+ {t(item?.paymethod?.gateway.toUpperCase(), item?.paymethod?.name)}
98
+ </OText>
99
+ </PMItem>
100
+ </TouchableOpacity>
101
+ )
102
+ }
103
+
104
+ return (
105
+ <PMContainer>
106
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
107
+ {t('PAYMENT_METHODS', 'Payment Methods')}
108
+ </OText>
109
+ {paymethodsAndWallets.loading ? (
110
+ <Placeholder style={{ marginTop: 10, marginBottom: 10 }} Animation={Fade}>
111
+ <View style={{ display: 'flex', flexDirection: 'row' }}>
112
+ {[...Array(3)].map((_, i) => (
113
+ <PlaceholderLine
114
+ key={i}
115
+ width={37}
116
+ height={80}
117
+ noMargin
118
+ style={{ borderRadius: 10, marginRight: 10, }}
119
+ />
120
+ ))}
121
+ </View>
122
+ </Placeholder>
123
+ ) : (
124
+ <FlatList
125
+ horizontal
126
+ showsHorizontalScrollIndicator={false}
127
+ data={businessPaymethods.result.filter((paymethod: any) => paymethodsAndWallets.paymethods.find((item: any) => item.id === paymethod.paymethod_id))}
128
+ renderItem={renderPaymethods}
129
+ keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
130
+ />
131
+ )}
132
+ {!paymethodsAndWallets.loading && !paymethodsAndWallets.error && paymethodsAndWallets.paymethods.length === 0 && (
133
+ <OText size={12} style={{ margin: 0 }}>
134
+ {t('NO_PAYMENT_METHODS', 'No payment methods!')}
135
+ </OText>
136
+ )}
137
+
138
+ {paymethodSelected?.paymethod?.gateway === 'stripe' && (
139
+ <View>
140
+ <OButton
141
+ text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
142
+ bgColor={theme.colors.white}
143
+ borderColor={theme.colors.primary}
144
+ style={styles.btnAddStyle}
145
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
146
+ imgRightSrc={null}
147
+ onClick={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
148
+ />
149
+ <StripeCardsList
150
+ paymethod={paymethodSelected?.paymethod}
151
+ businessId={businessIds[0]}
152
+ businessIds={businessIds}
153
+ publicKey={paymethodSelected?.data?.publishable}
154
+ payType={paymethodSelected?.paymethod?.name}
155
+ onSelectCard={handlePaymethodDataChange}
156
+ />
157
+ </View>
158
+ )}
159
+
160
+ {(paymethodsAndWallets.loading || walletsState.loading) ? (
161
+ <>
162
+ {[...Array(2).keys()].map(i => (
163
+ <PlaceholderLine
164
+ key={i}
165
+ height={40}
166
+ noMargin
167
+ style={{ marginBottom: 10 }}
168
+ />
169
+ ))}
170
+ </>
171
+ ) : (
172
+ <>
173
+ {walletsState.result.filter((wallet: any) => paymethodsAndWallets.wallets.find((item: any) => item.type === wallet.type)).map((wallet: any, idx: any) => walletName[wallet.type]?.isActive && (
174
+ <WalletItem
175
+ key={wallet.type}
176
+ isBottomBorder={idx === paymethodsAndWallets.wallets?.length - 1}
177
+ onPress={() => handleSelectWallet(paymethodSelected.wallet_id === wallet.id ? false : true, wallet)}
178
+ >
179
+ {paymethodSelected.wallet_id === wallet.id ? (
180
+ <MaterialCommunityIcons
181
+ name="checkbox-marked"
182
+ size={25}
183
+ color={theme.colors.primary}
184
+ />
185
+ ) : (
186
+ <MaterialCommunityIcons
187
+ name="checkbox-blank-outline"
188
+ size={25}
189
+ color={theme.colors.disabled}
190
+ />
191
+ )}
192
+ <OText size={12} style={{ flex: 1, marginLeft: 15 }}>{walletName[wallet.type]?.name}</OText>
193
+ <OText size={12}>{parsePrice(wallet.balance)}</OText>
194
+ </WalletItem>
195
+ ))}
196
+ </>
197
+ )}
198
+
199
+ <OModal
200
+ entireModal
201
+ title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
202
+ open={addCardOpen.stripe}
203
+ onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
204
+ style={{ backgroundColor: 'red' }}
205
+ >
206
+ <KeyboardAvoidingView
207
+ behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
208
+ keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
209
+ enabled={Platform.OS === 'ios' ? true : false}
210
+ >
211
+ <StripeElementsForm
212
+ toSave
213
+ businessId={businessIds[0]}
214
+ businessIds={businessIds}
215
+ publicKey={paymethodSelected?.data?.publishable}
216
+ requirements={props.clientSecret}
217
+ onSelectCard={handlePaymethodDataChange}
218
+ onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
219
+ />
220
+ </KeyboardAvoidingView>
221
+ </OModal>
222
+ </PMContainer>
223
+ )
224
+ }
225
+
226
+ const styles = StyleSheet.create({
227
+ btnAddStyle: {
228
+ marginVertical: 20,
229
+ borderRadius: 7.6,
230
+ shadowOpacity: 0,
231
+ height: 44,
232
+ borderWidth: 1
233
+ },
234
+ })
235
+
236
+
237
+ export const MultiCartsPaymethodsAndWallets = (props: any) => {
238
+ const multiCartsPaymethodsAndWalletsProps = {
239
+ ...props,
240
+ UIComponent: MultiCartsPaymethodsAndWalletsUI
241
+ }
242
+ return <MultiCartsPaymethodsAndWalletsController {...multiCartsPaymethodsAndWalletsProps} />
243
+ }
@@ -0,0 +1,46 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const PMContainer = styled.View`
4
+ display: flex;
5
+ flex-direction: column;
6
+ width: 100%;
7
+ `
8
+ export const PMItem = styled.View`
9
+ width: 120px;
10
+ height: 50px;
11
+ display: flex;
12
+ flex-direction: column;
13
+ align-items: center;
14
+ justify-content: center;
15
+ border-radius: 10px;
16
+ margin-right: 10px;
17
+ margin-top: 10px;
18
+ text-align: center;
19
+ background-color: ${(props: any) => props.theme.colors.inputDisabled};
20
+
21
+ ${(props: any) => props.theme?.rtl && css`
22
+ margin-left: 10px;
23
+ margin-right: 0;
24
+ `}
25
+
26
+ ${(props: any) => props.isActive ? css`
27
+ background-color: ${(props: any) => props.theme.colors.primary};
28
+ ` : css`
29
+ border: 1px solid #EAEAEA;
30
+ `}
31
+ `
32
+ export const WalletItem = styled.TouchableOpacity`
33
+ width: 100%;
34
+ display: flex;
35
+ padding: 20px 0;
36
+ margin-top: 10px;
37
+ flex-direction: row;
38
+ justify-content: space-between;
39
+ align-items: center;
40
+ border-top-width: 1px;
41
+ border-top-color: ${(props: any) => props.theme.colors.backgroundGray200};
42
+ ${(props: any) => props.isBottomBorder && css`
43
+ border-bottom-width: 1px;
44
+ border-bottom-color: ${(props: any) => props.theme.colors.backgroundGray200};
45
+ `}
46
+ `
@@ -0,0 +1,298 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import {
3
+ useLanguage,
4
+ useConfig,
5
+ useUtils,
6
+ useOrder,
7
+ useValidationFields,
8
+ useSession,
9
+ useToast,
10
+ ToastType,
11
+ MultiCheckout as MultiCheckoutController
12
+ } from 'ordering-components/native'
13
+ import { View, StyleSheet, Platform } from 'react-native'
14
+ import { useTheme } from 'styled-components/native';
15
+ import { Container } from '../../layouts/Container';
16
+ import NavBar from '../NavBar';
17
+ import { OText, OIcon, OModal } from '../shared';
18
+ import { getTypesText } from '../../utils';
19
+ import { UserDetails } from '../UserDetails'
20
+ import { AddressDetails } from '../AddressDetails'
21
+ import { MultiCartsPaymethodsAndWallets } from '../MultiCartsPaymethodsAndWallets'
22
+ import { Cart } from '../Cart'
23
+ import { FloatingButton } from '../FloatingButton'
24
+
25
+ import {
26
+ ChContainer,
27
+ ChSection,
28
+ ChHeader,
29
+ CHMomentWrapper,
30
+ ChUserDetails,
31
+ ChAddress,
32
+ ChCarts,
33
+ CartsHeader,
34
+ CCNotCarts,
35
+ ChCartsTotal
36
+ } from './styles'
37
+
38
+ const mapConfigs = {
39
+ mapZoom: 16,
40
+ mapSize: {
41
+ width: 640,
42
+ height: 190
43
+ }
44
+ }
45
+
46
+ const MultiCheckoutUI = (props: any) => {
47
+ const {
48
+ navigation,
49
+ placing,
50
+ openCarts,
51
+ totalCartsPrice,
52
+ handleGroupPlaceOrder,
53
+ paymethodSelected,
54
+ handleSelectPaymethod,
55
+ handleSelectWallet,
56
+ handlePaymethodDataChange
57
+ } = props
58
+
59
+ const theme = useTheme();
60
+ const styles = StyleSheet.create({
61
+ pagePadding: {
62
+ paddingLeft: 40,
63
+ paddingRight: 40
64
+ },
65
+ wrapperNavbar: Platform.OS === 'ios'
66
+ ? { paddingVertical: 0, paddingHorizontal: 40 }
67
+ : { paddingVertical: 20, paddingHorizontal: 40 }
68
+ })
69
+
70
+ const [, { showToast }] = useToast();
71
+ const [, t] = useLanguage()
72
+ const [{ configs }] = useConfig();
73
+ const [{ parsePrice, parseDate }] = useUtils();
74
+ const [{ options, carts, loading }, { confirmCart }] = useOrder();
75
+ const [validationFields] = useValidationFields();
76
+ const [{ user }] = useSession()
77
+
78
+ const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
79
+ const isPreOrder = configs?.preorder_status_enabled?.value === '1'
80
+ const maximumCarts = 5
81
+ const isDisablePlaceOrderButton = !(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) || openCarts.length > maximumCarts
82
+
83
+ const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
84
+ const [phoneUpdate, setPhoneUpdate] = useState(false);
85
+ const [userErrors, setUserErrors] = useState<any>([]);
86
+ const handleMomentClick = () => {
87
+ if (isPreOrder) {
88
+ navigation.navigate('MomentOption')
89
+ }
90
+ }
91
+
92
+ const checkValidationFields = () => {
93
+ setUserErrors([])
94
+ const errors = []
95
+ const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
96
+
97
+ Object.values(validationFields?.fields?.checkout).map((field: any) => {
98
+ if (field?.required && !notFields.includes(field.code)) {
99
+ if (!user[field?.code]) {
100
+ errors.push(t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `The field ${field?.name} is required`))
101
+ }
102
+ }
103
+ })
104
+
105
+ if (
106
+ !user?.cellphone &&
107
+ ((validationFields?.fields?.checkout?.cellphone?.enabled &&
108
+ validationFields?.fields?.checkout?.cellphone?.required) ||
109
+ configs?.verification_phone_required?.value === '1')
110
+ ) {
111
+ errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone number is required'))
112
+ }
113
+
114
+ if (phoneUpdate) {
115
+ errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
116
+ }
117
+
118
+ setUserErrors(errors)
119
+ }
120
+
121
+ const togglePhoneUpdate = (val: boolean) => {
122
+ setPhoneUpdate(val)
123
+ }
124
+
125
+ const handlePlaceOrder = () => {
126
+ if (!userErrors.length) {
127
+ handleGroupPlaceOrder && handleGroupPlaceOrder()
128
+ return
129
+ }
130
+ let stringError = ''
131
+ Object.values(userErrors).map((item: any, i: number) => {
132
+ stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
133
+ })
134
+ showToast(ToastType.Error, stringError)
135
+ setIsUserDetailsEdit(true)
136
+ }
137
+
138
+ useEffect(() => {
139
+ if (validationFields && validationFields?.fields?.checkout) {
140
+ checkValidationFields()
141
+ }
142
+ }, [validationFields, user])
143
+
144
+ return (
145
+ <>
146
+ <Container noPadding>
147
+ <View style={styles.wrapperNavbar}>
148
+ <NavBar
149
+ isVertical
150
+ title={t('CHECKOUT', 'Checkout')}
151
+ titleAlign={'center'}
152
+ onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
153
+ showCall={false}
154
+ btnStyle={{ paddingLeft: 0 }}
155
+ style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
156
+ titleWrapStyle={{ paddingHorizontal: 0 }}
157
+ titleStyle={{ marginRight: 0, marginLeft: 0 }}
158
+ />
159
+ </View>
160
+ <ChContainer style={styles.pagePadding}>
161
+ <ChSection style={{ paddingTop: 0 }}>
162
+ <ChHeader>
163
+ <CHMomentWrapper onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
164
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(options?.type || 1), 'Delivery')}</OText>
165
+ <OIcon
166
+ src={theme.images.general.arrow_down}
167
+ width={10}
168
+ style={{ marginStart: 8 }}
169
+ />
170
+ </CHMomentWrapper>
171
+ <CHMomentWrapper
172
+ onPress={() => handleMomentClick()}
173
+ disabled={loading}
174
+ >
175
+ <OText size={12} numberOfLines={1} ellipsizeMode='tail' color={theme.colors.textSecondary}>
176
+ {options?.moment
177
+ ? parseDate(options?.moment, { outputFormat: configs?.dates_moment_format?.value })
178
+ : t('ASAP_ABBREVIATION', 'ASAP')}
179
+ </OText>
180
+ {isPreOrder && (
181
+ <OIcon
182
+ src={theme.images.general.arrow_down}
183
+ width={10}
184
+ style={{ marginStart: 8 }}
185
+ />
186
+ )}
187
+ </CHMomentWrapper>
188
+ </ChHeader>
189
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 18, marginHorizontal: -40 }} />
190
+ </ChSection>
191
+
192
+ <ChSection>
193
+ <ChUserDetails>
194
+ <UserDetails
195
+ isUserDetailsEdit={isUserDetailsEdit}
196
+ useValidationFields
197
+ useDefualtSessionManager
198
+ useSessionUser
199
+ isCheckout
200
+ phoneUpdate={phoneUpdate}
201
+ togglePhoneUpdate={togglePhoneUpdate}
202
+ />
203
+ </ChUserDetails>
204
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
205
+ </ChSection>
206
+
207
+ <ChSection>
208
+ <ChAddress>
209
+ <AddressDetails
210
+ navigation={navigation}
211
+ isMultiCheckout
212
+ openCarts={openCarts}
213
+ apiKey={configs?.google_maps_api_key?.value}
214
+ mapConfigs={mapConfigs}
215
+ />
216
+ </ChAddress>
217
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
218
+ </ChSection>
219
+
220
+ <ChSection>
221
+ <MultiCartsPaymethodsAndWallets
222
+ openCarts={openCarts}
223
+ paymethodSelected={paymethodSelected}
224
+ handleSelectPaymethod={handleSelectPaymethod}
225
+ handleSelectWallet={handleSelectWallet}
226
+ handlePaymethodDataChange={handlePaymethodDataChange}
227
+ />
228
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
229
+ </ChSection>
230
+
231
+ <ChSection>
232
+ <ChCarts>
233
+ <CartsHeader>
234
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} style={{ fontWeight: '500' }}>
235
+ {t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
236
+ </OText>
237
+ </CartsHeader>
238
+ {openCarts.map((cart: any) => (
239
+ <React.Fragment key={cart.uuid}>
240
+ <Cart
241
+ cart={cart}
242
+ cartuuid={cart.uuid}
243
+ isMultiCheckout
244
+ onNavigationRedirect={(route: string, params: any) => props.navigation.navigate(route, params)}
245
+ />
246
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
247
+ </React.Fragment>
248
+ ))}
249
+ {openCarts.length === 0 && (
250
+ <CCNotCarts>
251
+ <OText size={24} style={{ textAlign: 'center' }}>
252
+ {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
253
+ </OText>
254
+ </CCNotCarts>
255
+ )}
256
+ {openCarts.length > 0 && (
257
+ <ChCartsTotal>
258
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
259
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
260
+ {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
261
+ </OText>
262
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
263
+ </View>
264
+ <OText size={12} color={theme.colors.mediumGray} mRight={70} style={{ marginTop: 10 }}>
265
+ {t('MULTI_CHECKOUT_DESCRIPTION', 'You will receive a receipt for each business. The payment is not combined between multiple stores. Each payment is processed by the store')}
266
+ </OText>
267
+ </ChCartsTotal>
268
+ )}
269
+ {openCarts.length > maximumCarts && (
270
+ <OText size={14} color={theme.colors.danger5} style={{ marginVertical: 20 }}>
271
+ {t('WARNING_MAXIMUM_CARTS', 'You can only pay for a maximum of 5 carts, please discard one or more to continue.')}
272
+ </OText>
273
+ )}
274
+ </ChCarts>
275
+ </ChSection>
276
+ </ChContainer>
277
+ </Container>
278
+
279
+ <FloatingButton
280
+ handleClick={() => handlePlaceOrder()}
281
+ isSecondaryBtn={isDisablePlaceOrderButton}
282
+ disabled={isDisablePlaceOrderButton}
283
+ btnText={placing ? t('PLACING', 'Placing') : t('PLACE_ORDER', 'Place Order')}
284
+ btnRightValueShow
285
+ btnRightValue={parsePrice(totalCartsPrice)}
286
+ iosBottom={30}
287
+ />
288
+ </>
289
+ )
290
+ }
291
+
292
+ export const MultiCheckout = (props: any) => {
293
+ const multiCheckoutProps = {
294
+ ...props,
295
+ UIComponent: MultiCheckoutUI
296
+ }
297
+ return <MultiCheckoutController {...multiCheckoutProps} />
298
+ }