ordering-ui-react-native 0.15.62 → 0.15.63-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 (210) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  5. package/src/components/BusinessController/index.tsx +16 -8
  6. package/src/components/BusinessInformation/index.tsx +14 -0
  7. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  8. package/src/components/BusinessesListing/index.tsx +1 -1
  9. package/src/components/Checkout/index.tsx +23 -2
  10. package/src/components/DriverTips/index.tsx +11 -6
  11. package/src/components/LanguageSelector/index.tsx +6 -2
  12. package/src/components/LoginForm/index.tsx +120 -30
  13. package/src/components/LoginForm/styles.tsx +6 -0
  14. package/src/components/OrderDetails/index.tsx +7 -21
  15. package/src/components/PaymentOptions/index.tsx +67 -50
  16. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  17. package/src/components/ReviewDriver/index.tsx +1 -1
  18. package/src/components/ReviewOrder/index.tsx +2 -1
  19. package/src/components/ReviewProducts/index.tsx +11 -0
  20. package/src/components/SignupForm/index.tsx +145 -61
  21. package/src/components/SingleProductCard/index.tsx +16 -4
  22. package/src/components/SingleProductReview/index.tsx +1 -1
  23. package/src/components/StripeMethodForm/index.tsx +22 -24
  24. package/src/components/UpsellingProducts/index.tsx +1 -1
  25. package/src/components/UserProfileForm/index.tsx +63 -6
  26. package/src/components/UserProfileForm/styles.tsx +8 -0
  27. package/src/components/VerifyPhone/styles.tsx +1 -2
  28. package/src/components/shared/OModal.tsx +1 -1
  29. package/src/hooks/useCountdownTimer.tsx +26 -0
  30. package/src/navigators/CheckoutNavigator.tsx +6 -0
  31. package/src/navigators/HomeNavigator.tsx +12 -0
  32. package/src/pages/BusinessesListing.tsx +7 -6
  33. package/src/pages/MultiCheckout.tsx +31 -0
  34. package/src/pages/MultiOrdersDetails.tsx +27 -0
  35. package/src/pages/OrderDetails.tsx +1 -1
  36. package/src/pages/ReviewDriver.tsx +2 -2
  37. package/src/pages/ReviewOrder.tsx +2 -2
  38. package/src/pages/Sessions.tsx +22 -0
  39. package/src/theme.json +0 -1
  40. package/src/types/index.tsx +18 -11
  41. package/src/utils/index.tsx +68 -1
  42. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  43. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  44. package/themes/business/src/components/Chat/index.tsx +42 -90
  45. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  46. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  47. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  48. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  49. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  50. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  51. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  52. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +14 -7
  53. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  54. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  55. package/themes/business/src/components/OrdersOption/index.tsx +8 -4
  56. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  57. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  58. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  59. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  60. package/themes/business/src/components/shared/OModal.tsx +1 -1
  61. package/themes/business/src/types/index.tsx +8 -2
  62. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  63. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  64. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  65. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  66. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  67. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  68. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  69. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  70. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  71. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  72. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  73. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  74. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  75. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  76. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  77. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  78. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  79. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  80. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  81. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  82. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  83. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  84. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  85. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  86. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  87. package/themes/kiosk/src/types/index.d.ts +1 -0
  88. package/themes/original/index.tsx +30 -8
  89. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  90. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  91. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  92. package/themes/original/src/components/AddressList/index.tsx +30 -18
  93. package/themes/original/src/components/AppleLogin/index.tsx +7 -12
  94. package/themes/original/src/components/BusinessBasicInformation/index.tsx +137 -46
  95. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  96. package/themes/original/src/components/BusinessController/index.tsx +168 -96
  97. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  98. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  99. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  100. package/themes/original/src/components/BusinessListingSearch/index.tsx +231 -63
  101. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  102. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  103. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  104. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  105. package/themes/original/src/components/BusinessProductsList/index.tsx +51 -52
  106. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  107. package/themes/original/src/components/BusinessProductsListing/index.tsx +291 -155
  108. package/themes/original/src/components/BusinessProductsListing/styles.tsx +27 -0
  109. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  110. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -39
  111. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  112. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +560 -0
  113. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +107 -0
  114. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +559 -0
  115. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Original/styles.tsx} +11 -3
  116. package/themes/original/src/components/BusinessesListing/index.tsx +99 -458
  117. package/themes/original/src/components/Cart/index.tsx +62 -43
  118. package/themes/original/src/components/Checkout/index.tsx +90 -39
  119. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  120. package/themes/original/src/components/Favorite/index.tsx +92 -0
  121. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  122. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  123. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  124. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  125. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  126. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  127. package/themes/original/src/components/Help/index.tsx +21 -4
  128. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  129. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  130. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  131. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  132. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  133. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  134. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  135. package/themes/original/src/components/Messages/index.tsx +1 -1
  136. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  137. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  138. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  139. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  140. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  141. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  142. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  143. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  144. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  145. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  146. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  147. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  148. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  149. package/themes/original/src/components/NavBar/index.tsx +4 -4
  150. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  151. package/themes/original/src/components/OrderDetails/index.tsx +151 -65
  152. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  153. package/themes/original/src/components/OrderSummary/index.tsx +6 -6
  154. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  155. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  156. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  157. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  158. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  159. package/themes/original/src/components/OrdersOption/index.tsx +137 -38
  160. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  161. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  162. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  163. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  164. package/themes/original/src/components/PaymentOptions/index.tsx +58 -37
  165. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  166. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  167. package/themes/original/src/components/ProductForm/index.tsx +718 -679
  168. package/themes/original/src/components/ProductForm/styles.tsx +6 -2
  169. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  170. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  171. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  172. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  173. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  174. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  175. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  176. package/themes/original/src/components/Promotions/index.tsx +151 -133
  177. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  178. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  179. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  180. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  181. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  182. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  183. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  184. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  185. package/themes/original/src/components/Sessions/index.tsx +160 -0
  186. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  187. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  188. package/themes/original/src/components/SingleOrderCard/index.tsx +275 -0
  189. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  190. package/themes/original/src/components/SingleProductCard/index.tsx +150 -84
  191. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  192. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  193. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  194. package/themes/original/src/components/UserDetails/index.tsx +15 -81
  195. package/themes/original/src/components/UserFormDetails/index.tsx +98 -66
  196. package/themes/original/src/components/UserProfile/index.tsx +11 -2
  197. package/themes/original/src/components/UserProfileForm/index.tsx +33 -22
  198. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  199. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  200. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  201. package/themes/original/src/components/Wallets/index.tsx +76 -9
  202. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  203. package/themes/original/src/components/shared/OBottomPopup.tsx +44 -13
  204. package/themes/original/src/components/shared/OInput.tsx +3 -2
  205. package/themes/original/src/components/shared/OModal.tsx +4 -2
  206. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  207. package/themes/original/src/types/index.tsx +184 -35
  208. package/themes/original/src/utils/index.tsx +96 -2
  209. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  210. 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,197 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import { StyleSheet, View, Platform } from 'react-native'
3
+ import SelectDropdown from 'react-native-select-dropdown'
4
+ import { useTheme } from 'styled-components/native'
5
+ import {
6
+ MomentOption as MomentOptionController,
7
+ useConfig,
8
+ useUtils
9
+ } from 'ordering-components/native'
10
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
11
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
12
+ import { Container } from './styles'
13
+ import moment from 'moment'
14
+
15
+ const MomentSelectorUI = (props: any) => {
16
+ const {
17
+ datesList,
18
+ hoursList,
19
+ dateSelected,
20
+ timeSelected,
21
+ handleChangeDate,
22
+ handleChangeTime,
23
+ } = props
24
+
25
+ const theme = useTheme()
26
+ const { top } = useSafeAreaInsets()
27
+ const [{ configs }] = useConfig()
28
+ const [{ parseTime }] = useUtils()
29
+
30
+ const [customizedDateList, setCustomizedDateList] = useState([])
31
+ const [customizedTimeList, setCustomizedTimeList] = useState([])
32
+
33
+ const is12hours = configs?.dates_moment_format?.value?.includes('hh:mm')
34
+
35
+ const styles = StyleSheet.create({
36
+ selectOption: {
37
+ width: '100%',
38
+ backgroundColor: theme.colors.backgroundGray100,
39
+ paddingVertical: 5,
40
+ paddingHorizontal: 14,
41
+ flexDirection: 'row-reverse',
42
+ alignItems: 'center',
43
+ justifyContent: 'space-between',
44
+ height: 30
45
+ },
46
+ selectWrapper: {
47
+ flex: 1
48
+ }
49
+ })
50
+
51
+ useEffect(() => {
52
+ const updatedDatesList = datesList?.map((date: any) => {
53
+ return { value: moment(date).format('MMM DD, YYYY'), key: date }
54
+ })
55
+ setCustomizedDateList(updatedDatesList)
56
+ }, [datesList])
57
+
58
+ useEffect(() => {
59
+ if (hoursList?.length > 0) {
60
+
61
+ const updatedHoursList = hoursList?.map((hour: any) => {
62
+ const timeValue = is12hours ? (
63
+ hour?.startTime?.includes('12')
64
+ ? `${hour.startTime}PM`
65
+ : parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
66
+ ) : (
67
+ parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
68
+ )
69
+ return { value: timeValue, key: hour.startTime }
70
+ })
71
+ setCustomizedTimeList(updatedHoursList)
72
+ }
73
+ }, [hoursList])
74
+
75
+ const dropDownIcon = () => {
76
+ return (
77
+ <IconAntDesign
78
+ name='down'
79
+ color={theme.colors.textThird}
80
+ size={12}
81
+ />
82
+ )
83
+ }
84
+
85
+ return (
86
+ <Container>
87
+ <View style={styles.selectWrapper}>
88
+ <SelectDropdown
89
+ defaultValue={customizedDateList?.find((item: any) => item.key === dateSelected)}
90
+ data={customizedDateList}
91
+ onSelect={(selectedItem, index) => {
92
+ handleChangeDate(selectedItem?.key)
93
+ }}
94
+ buttonTextAfterSelection={(selectedItem, index) => {
95
+ return selectedItem?.value
96
+ }}
97
+ rowTextForSelection={(item, index) => {
98
+ return item.value
99
+ }}
100
+ buttonStyle={{borderTopLeftRadius: 7.6, borderBottomLeftRadius: 7.6, ...styles.selectOption}}
101
+ buttonTextStyle={{
102
+ color: theme.colors.disabled,
103
+ fontSize: 12,
104
+ textAlign: 'left',
105
+ marginHorizontal: 0
106
+ }}
107
+ dropdownStyle={{
108
+ borderRadius: 8,
109
+ borderColor: theme.colors.lightGray,
110
+ marginTop: Platform.OS === 'ios' ? 12 : -top
111
+ }}
112
+ rowStyle={{
113
+ borderBottomColor: theme.colors.backgroundGray100,
114
+ backgroundColor: theme.colors.backgroundGray100,
115
+ height: 30,
116
+ flexDirection: 'column',
117
+ alignItems: 'flex-start',
118
+ paddingTop: 8,
119
+ paddingHorizontal: 12
120
+ }}
121
+ rowTextStyle={{
122
+ color: theme.colors.disabled,
123
+ fontSize: 12,
124
+ marginHorizontal: 0
125
+ }}
126
+ renderDropdownIcon={() => dropDownIcon()}
127
+ dropdownOverlayColor='transparent'
128
+ />
129
+ </View>
130
+ <View style={styles.selectWrapper}>
131
+ <SelectDropdown
132
+ defaultValue={customizedTimeList?.find((item: any) => item.key === timeSelected)}
133
+ data={customizedTimeList}
134
+ onSelect={(selectedItem, index) => {
135
+ handleChangeTime(selectedItem.key)
136
+ }}
137
+ buttonTextAfterSelection={(selectedItem, index) => {
138
+ return selectedItem.value
139
+ }}
140
+ rowTextForSelection={(item, index) => {
141
+ return item.value
142
+ }}
143
+ buttonStyle={{borderTopRightRadius: 7.6, borderBottomRightRadius: 7.6, ...styles.selectOption}}
144
+ buttonTextStyle={{
145
+ color: theme.colors.disabled,
146
+ fontSize: 12,
147
+ textAlign: 'left',
148
+ marginHorizontal: 0
149
+ }}
150
+ dropdownStyle={{
151
+ borderRadius: 8,
152
+ borderColor: theme.colors.lightGray,
153
+ marginTop: Platform.OS === 'ios' ? 12 : -top
154
+ }}
155
+ rowStyle={{
156
+ borderBottomColor: theme.colors.backgroundGray100,
157
+ backgroundColor: theme.colors.backgroundGray100,
158
+ height: 30,
159
+ flexDirection: 'column',
160
+ alignItems: 'flex-start',
161
+ paddingTop: 8,
162
+ paddingHorizontal: 14
163
+ }}
164
+ rowTextStyle={{
165
+ color: theme.colors.disabled,
166
+ fontSize: 12,
167
+ marginHorizontal: 0
168
+ }}
169
+ renderDropdownIcon={() => dropDownIcon()}
170
+ dropdownOverlayColor='transparent'
171
+ />
172
+ </View>
173
+ </Container>
174
+ )
175
+ }
176
+
177
+ export const MomentSelector = (props: any) => {
178
+ const [{ configs }] = useConfig()
179
+
180
+ const limitDays = parseInt(configs?.max_days_preorder?.value, 10)
181
+
182
+ const currentDate = new Date()
183
+ const time = limitDays > 1
184
+ ? currentDate.getTime() + ((limitDays - 1) * 24 * 60 * 60 * 1000)
185
+ : limitDays === 1 ? currentDate.getTime() : currentDate.getTime() + (6 * 24 * 60 * 60 * 1000)
186
+
187
+ currentDate.setTime(time)
188
+ currentDate.setHours(23)
189
+ currentDate.setMinutes(59)
190
+
191
+ const businessPreorderProps = {
192
+ ...props,
193
+ UIComponent: MomentSelectorUI,
194
+ maxDate: currentDate
195
+ }
196
+ return <MomentOptionController {...businessPreorderProps} />
197
+ }
@@ -0,0 +1,6 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View`
4
+ flex-direction: row;
5
+ width: 100%;
6
+ `
@@ -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
+ `