ordering-ui-react-native 0.16.54 → 0.16.55-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 (202) hide show
  1. package/package.json +6 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  5. package/src/components/BusinessInformation/index.tsx +33 -4
  6. package/src/components/BusinessInformation/styles.tsx +2 -2
  7. package/src/components/BusinessProductsList/index.tsx +10 -10
  8. package/src/components/BusinessesListing/index.tsx +1 -1
  9. package/src/components/Checkout/index.tsx +2 -1
  10. package/src/components/LanguageSelector/index.tsx +21 -16
  11. package/src/components/Messages/index.tsx +2 -2
  12. package/src/components/NotificationSetting/index.tsx +85 -0
  13. package/src/components/OrdersOption/index.tsx +54 -56
  14. package/src/components/PaymentOptions/index.tsx +298 -345
  15. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  16. package/src/components/SingleProductReview/index.tsx +7 -4
  17. package/src/components/StripeElementsForm/index.tsx +25 -16
  18. package/src/components/VerifyPhone/styles.tsx +1 -2
  19. package/src/components/shared/OBottomPopup.tsx +6 -2
  20. package/src/components/shared/OToast.tsx +4 -4
  21. package/src/index.tsx +2 -0
  22. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  23. package/src/utils/index.tsx +2 -1
  24. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +260 -238
  25. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  26. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  27. package/themes/business/src/components/Chat/index.tsx +40 -32
  28. package/themes/business/src/components/DriverMap/index.tsx +7 -5
  29. package/themes/business/src/components/DriverSchedule/index.tsx +36 -19
  30. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  31. package/themes/business/src/components/MapView/index.tsx +12 -1
  32. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  33. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -41
  34. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +40 -30
  35. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
  36. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  37. package/themes/business/src/components/OrdersOption/index.tsx +76 -77
  38. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  39. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  40. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  41. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  42. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  43. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  44. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  45. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  46. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  47. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  48. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  49. package/themes/business/src/components/PreviousOrders/index.tsx +440 -245
  50. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  51. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  52. package/themes/business/src/components/ReviewCustomer/index.tsx +39 -15
  53. package/themes/business/src/components/ScheduleBlocked/index.tsx +2 -2
  54. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  55. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  56. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  57. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  58. package/themes/business/src/components/shared/OLink.tsx +24 -12
  59. package/themes/business/src/components/shared/OText.tsx +3 -2
  60. package/themes/business/src/types/index.tsx +25 -11
  61. package/themes/business/src/utils/index.tsx +10 -0
  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/BusinessesListing/index.tsx +2 -1
  66. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  67. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  68. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  69. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  70. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  71. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  72. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  73. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  74. package/themes/kiosk/src/types/index.d.ts +2 -0
  75. package/themes/original/index.tsx +8 -0
  76. package/themes/original/src/components/AddressDetails/index.tsx +10 -8
  77. package/themes/original/src/components/AddressForm/index.tsx +157 -140
  78. package/themes/original/src/components/AddressList/index.tsx +1 -1
  79. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  80. package/themes/original/src/components/BusinessBasicInformation/index.tsx +53 -37
  81. package/themes/original/src/components/BusinessController/index.tsx +193 -91
  82. package/themes/original/src/components/BusinessController/styles.tsx +14 -9
  83. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  84. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
  85. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  86. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  87. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  88. package/themes/original/src/components/BusinessListingSearch/index.tsx +85 -137
  89. package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
  90. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  91. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  92. package/themes/original/src/components/BusinessProductsList/index.tsx +59 -61
  93. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  94. package/themes/original/src/components/BusinessProductsListing/index.tsx +184 -86
  95. package/themes/original/src/components/BusinessProductsListing/styles.tsx +14 -12
  96. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
  97. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +28 -29
  98. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +137 -135
  99. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  100. package/themes/original/src/components/BusinessesListing/index.tsx +17 -10
  101. package/themes/original/src/components/Cart/index.tsx +82 -15
  102. package/themes/original/src/components/Cart/styles.tsx +4 -0
  103. package/themes/original/src/components/CartContent/index.tsx +27 -17
  104. package/themes/original/src/components/CartContent/styles.tsx +1 -1
  105. package/themes/original/src/components/Checkout/index.tsx +115 -118
  106. package/themes/original/src/components/Checkout/styles.tsx +4 -3
  107. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  108. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  109. package/themes/original/src/components/DriverTips/index.tsx +4 -4
  110. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  111. package/themes/original/src/components/FavoriteList/index.tsx +69 -45
  112. package/themes/original/src/components/FloatingButton/index.tsx +0 -1
  113. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  114. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  115. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  116. package/themes/original/src/components/GoogleMap/index.tsx +10 -1
  117. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +25 -10
  118. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +4 -0
  119. package/themes/original/src/components/HelpGuide/index.tsx +9 -8
  120. package/themes/original/src/components/HelpOrder/index.tsx +9 -8
  121. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  122. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  123. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  124. package/themes/original/src/components/LoginForm/index.tsx +98 -41
  125. package/themes/original/src/components/LottieAnimation/index.tsx +69 -0
  126. package/themes/original/src/components/Messages/index.tsx +35 -20
  127. package/themes/original/src/components/MomentOption/index.tsx +8 -6
  128. package/themes/original/src/components/MultiCart/index.tsx +63 -0
  129. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
  130. package/themes/original/src/components/MultiCheckout/index.tsx +10 -2
  131. package/themes/original/src/components/MultiOrdersDetails/index.tsx +34 -16
  132. package/themes/original/src/components/MyOrders/index.tsx +89 -25
  133. package/themes/original/src/components/NavBar/index.tsx +11 -5
  134. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  135. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  136. package/themes/original/src/components/Notifications/index.tsx +148 -0
  137. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  138. package/themes/original/src/components/OrderDetails/index.tsx +132 -18
  139. package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
  140. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  141. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  142. package/themes/original/src/components/OrderProgress/index.tsx +77 -66
  143. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  144. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  145. package/themes/original/src/components/OrderTypeSelector/index.tsx +85 -36
  146. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  147. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +94 -98
  148. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  149. package/themes/original/src/components/OrdersOption/index.tsx +95 -55
  150. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  151. package/themes/original/src/components/PaymentOptions/index.tsx +1 -2
  152. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  153. package/themes/original/src/components/PlaceSpot/index.tsx +249 -47
  154. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  155. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  156. package/themes/original/src/components/ProductForm/index.tsx +367 -384
  157. package/themes/original/src/components/ProductForm/styles.tsx +7 -12
  158. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  159. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  160. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  161. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +0 -1
  162. package/themes/original/src/components/ProfessionalFilter/index.tsx +2 -1
  163. package/themes/original/src/components/ProfessionalProfile/index.tsx +19 -8
  164. package/themes/original/src/components/Promotions/index.tsx +232 -219
  165. package/themes/original/src/components/Promotions/styles.tsx +7 -2
  166. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  167. package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
  168. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  169. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  170. package/themes/original/src/components/ReviewTrigger/index.tsx +28 -10
  171. package/themes/original/src/components/ReviewTrigger/styles.tsx +10 -3
  172. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  173. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  174. package/themes/original/src/components/ServiceForm/index.tsx +330 -266
  175. package/themes/original/src/components/SignupForm/index.tsx +134 -89
  176. package/themes/original/src/components/SingleOrderCard/index.tsx +219 -129
  177. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  178. package/themes/original/src/components/SingleProductCard/index.tsx +120 -62
  179. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -9
  180. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  181. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  182. package/themes/original/src/components/StripeElementsForm/index.tsx +13 -2
  183. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -5
  184. package/themes/original/src/components/UserDetails/index.tsx +5 -3
  185. package/themes/original/src/components/UserFormDetails/index.tsx +6 -48
  186. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  187. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  188. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  189. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  190. package/themes/original/src/components/Wallets/index.tsx +176 -164
  191. package/themes/original/src/components/Wallets/styles.tsx +12 -8
  192. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  193. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  194. package/themes/original/src/components/shared/OBottomPopup.tsx +32 -21
  195. package/themes/original/src/components/shared/OButton.tsx +8 -3
  196. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  197. package/themes/original/src/components/shared/OInput.tsx +10 -1
  198. package/themes/original/src/layouts/Container.tsx +13 -9
  199. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  200. package/themes/original/src/types/index.tsx +63 -8
  201. package/themes/original/src/utils/index.tsx +103 -58
  202. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -45,7 +45,7 @@ const PaymentOptionWalletUI = (props: any) => {
45
45
  new Array(walletsState.result?.length).fill(false)
46
46
  );
47
47
 
48
- const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate, { isTruncable: true })}`
48
+ const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate)}`
49
49
 
50
50
  const walletName: any = {
51
51
  cash: {
@@ -87,65 +87,65 @@ const PaymentOptionWalletUI = (props: any) => {
87
87
  {!walletsState.loading &&
88
88
  !walletsState.error &&
89
89
  walletsState.result?.length > 0 &&
90
- (
91
- <>
92
- {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
93
- <Container
94
- key={wallet.id}
95
- isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
- onPress={() => handleOnChange(idx, wallet)}
97
- disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
98
- >
99
- <SectionLeft>
100
- {checkedState[idx] ? (
101
- <MaterialCommunityIcons
102
- name="checkbox-marked"
103
- size={25}
104
- color={theme.colors.primary}
105
- />
106
- ) : (
107
- <MaterialCommunityIcons
108
- name="checkbox-blank-outline"
109
- size={25}
110
- color={theme.colors.disabled}
111
- />
112
- )}
113
- <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
114
- <View>
115
- <OText
116
- style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ? {
117
- color: theme.colors.disabled
118
- } : {}}
119
- >
120
- {walletName[wallet.type]?.name}
121
- </OText>
122
- </View>
90
+ (
91
+ <>
92
+ {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
93
+ <Container
94
+ key={wallet.id}
95
+ isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
+ onPress={() => handleOnChange(idx, wallet)}
97
+ disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
98
+ >
99
+ <SectionLeft>
100
+ {checkedState[idx] ? (
101
+ <MaterialCommunityIcons
102
+ name="checkbox-marked"
103
+ size={25}
104
+ color={theme.colors.primary}
105
+ />
106
+ ) : (
107
+ <MaterialCommunityIcons
108
+ name="checkbox-blank-outline"
109
+ size={25}
110
+ color={theme.colors.disabled}
111
+ />
112
+ )}
113
+ <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
114
+ <View>
115
+ <OText
116
+ style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ?{
117
+ color: theme.colors.disabled
118
+ } : {}}
119
+ >
120
+ {walletName[wallet.type]?.name}
121
+ </OText>
123
122
  </View>
124
- </SectionLeft>
125
-
126
- <View style={{ maxWidth: '35%', alignItems: 'flex-end' }}>
127
- {wallet.type === 'cash' && (
128
- <OText>
129
- {parsePrice(wallet?.balance, { isTruncable: true })}
123
+ </View>
124
+ </SectionLeft>
125
+
126
+ <View style={{maxWidth: '35%', alignItems: 'flex-end' }}>
127
+ {wallet.type === 'cash' && (
128
+ <OText>
129
+ {parsePrice(wallet?.balance)}
130
+ </OText>
131
+ )}
132
+ {wallet.type === 'credit_point' && (
133
+ <OText>
134
+ <OText color={theme.colors.primary} weight='bold'>
135
+ {`${wallet?.balance} ${t('POINTS', 'Points')}`}
130
136
  </OText>
131
- )}
132
- {wallet.type === 'credit_point' && (
133
137
  <OText>
134
- <OText color={theme.colors.primary} weight='bold'>
135
- {`${wallet?.balance} ${t('POINTS', 'Points')}`}
136
- </OText>
137
- <OText>
138
- {wallet?.balance > 0
139
- ? creditBalance(wallet)
140
- : null}
141
- </OText>
138
+ {wallet?.balance > 0
139
+ ? creditBalance(wallet)
140
+ : null}
142
141
  </OText>
143
- )}
144
- </View>
145
- </Container>
146
- ))}
147
- </>
148
- )}
142
+ </OText>
143
+ )}
144
+ </View>
145
+ </Container>
146
+ ))}
147
+ </>
148
+ )}
149
149
 
150
150
  {walletsState?.loading && (
151
151
  <View>
@@ -160,7 +160,6 @@ const PaymentOptionsUI = (props: any) => {
160
160
  <TouchableOpacity
161
161
  onPress={() => handlePaymentMethodClick(item)}
162
162
  >
163
- {console.log(item?.gateway)}
164
163
  <PMItem
165
164
  key={item.id}
166
165
  isDisabled={isDisabled}
@@ -187,7 +186,7 @@ const PaymentOptionsUI = (props: any) => {
187
186
  )
188
187
  }
189
188
 
190
- const excludeIds: any = [32]; //exclude paypal & connect & redirect
189
+ const excludeIds: any = [32, 66]; //exclude paypal & connect & redirect
191
190
 
192
191
  return (
193
192
  <PMContainer>
@@ -124,7 +124,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
124
124
  flagButtonStyle={flagStyle}
125
125
  countryPickerButtonStyle={{ ...style.countryBtn, ...boxStyle ? boxStyle : {} }}
126
126
  placeholder={t('PHONE_NUMBER', 'Phone Number')}
127
- textInputProps={{ autoCompleteType: 'tel', ref: forwardRef, ...textInputProps }}
127
+ textInputProps={{ keyboardType: 'number-pad', autoCompleteType: 'tel', textContentType: 'telephoneNumber', dataDetectorTypes: 'phoneNumber', ref: forwardRef, ...textInputProps }}
128
128
  containerStyle={{ width: '100%' }}
129
129
  renderDropdownImage={noDropIcon ? <View /> : <OIcon src={theme.images.general.arrow_down} width={13} color={'#B1BCCC'}></OIcon>}
130
130
  />
@@ -1,24 +1,79 @@
1
1
  import React, { useEffect, useState } from 'react'
2
- import { View } from 'react-native'
3
- import { PlaceSpot as PlaceSpotController, useLanguage } from 'ordering-components/native'
2
+ import { View, StyleSheet } from 'react-native'
3
+ import { PlaceSpot as PlaceSpotController, useLanguage, useOrder, useToast, ToastType } from 'ordering-components/native'
4
4
  import { PlaceGroupContainer, PlaceSpotContainer } from './styles'
5
5
  import { NotFoundSource } from '../NotFoundSource'
6
- import { OText, ODropDown } from '../shared'
6
+ import { OText, ODropDown, OInput, OButton } from '../shared'
7
7
  import { Placeholder, PlaceholderLine } from 'rn-placeholder'
8
8
  import { PlaceSpotParams } from '../../types'
9
+ import { useTheme } from 'styled-components/native'
10
+ import SelectDropdown from 'react-native-select-dropdown'
11
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
9
12
 
10
13
  const PlaceSpotUI = (props: PlaceSpotParams) => {
11
14
  const {
12
- isOpenPlaceSpot,
13
15
  cart,
16
+ orderTypes,
14
17
  placesState,
15
18
  handleChangePlace,
16
- getPlacesList,
17
- setOpenPlaceModal
19
+ spotNumber,
20
+ spotState,
21
+ isCheckout,
22
+ vehicle,
23
+ isInputMode,
24
+ setSpotNumber,
25
+ setVehicle,
26
+ handleChangeSpot,
27
+ setPlaceSpotNumber
18
28
  } = props
19
29
 
30
+ const theme = useTheme()
20
31
  const [, t] = useLanguage()
32
+ const [orderState] = useOrder()
33
+ const [, { showToast }] = useToast();
34
+
21
35
  const [placeGroupSelected, setPlaceGroupSelected] = useState<any>(null)
36
+ const vehicleInputAllowed = [4, 5]
37
+
38
+ const currentOrderType = isCheckout ? orderState?.options?.type : cart?.delivery_type
39
+ const isEatin = currentOrderType === 3
40
+ const isDriveThru = currentOrderType === 5
41
+ const placeholderText = isEatin
42
+ ? t('EATIN_SPOT_NUMBER', 'Table number')
43
+ : isDriveThru
44
+ ? t('DRIVE_THRU_SPOT_NUMBER', 'Drive thru lane')
45
+ : t('CURBSIDE_SPOT_NUMBER', 'Spot number')
46
+
47
+ const styles = StyleSheet.create({
48
+ selectOption: {
49
+ backgroundColor: theme.colors.backgroundGray100,
50
+ borderRadius: 7.6,
51
+ paddingVertical: 10,
52
+ paddingHorizontal: 14,
53
+ flexDirection: 'row-reverse',
54
+ alignItems: 'center',
55
+ justifyContent: 'space-between',
56
+ height: 50,
57
+ width: '100%'
58
+ },
59
+ optionWrapper: {
60
+ marginBottom: 20
61
+ }
62
+ })
63
+
64
+ const vehicleTypeList: any = [
65
+ { key: 'car', text: t('VEHICLE_TYPE_CAR', 'Car') },
66
+ { key: 'truck', text: t('VEHICLE_TYPE_TRUCK', 'Truck') },
67
+ { key: 'suv', text: t('VEHICLE_TYPE_SUV', 'SUV') },
68
+ { key: 'van', text: t('VEHICLE_TYPE_VAN', 'Van') },
69
+ { key: 'motorcycle', text: t('VEHICLE_TYPE_MOTORCYCLE', 'Motorcycle') }
70
+ ]
71
+
72
+ const vehicleInputList = [
73
+ { key: 'model', text: t('VEHICLE_MODEL', 'Model') },
74
+ { key: 'car_registration', text: t('VEHICLE_CAR_REGISTRATION', 'Car registration') },
75
+ { key: 'color', text: t('VEHICLE_COLOR', 'Color') }
76
+ ]
22
77
 
23
78
  const getPlacesGroups = () => {
24
79
  const groups = placesState.placeGroups?.filter((group: any) => group?.enabled && placesState?.places?.find((place: any) => place?.enabled && place?.place_group_id === group?.id))
@@ -39,10 +94,37 @@ const PlaceSpotUI = (props: PlaceSpotParams) => {
39
94
  }
40
95
 
41
96
  const handlerChangePlace = (place: any) => {
42
- setOpenPlaceModal(false)
43
97
  handleChangePlace(place)
44
98
  }
45
99
 
100
+ const onChangeSpot = () => {
101
+ if (orderState.loading) return
102
+ if (!Number.isInteger(Number(spotNumber))) {
103
+ showToast(ToastType.Error, t('VALIDATION_ERROR_INTEGER', 'The _attribute_ must be an integer.').replace('_attribute_', placeholderText))
104
+ return
105
+ }
106
+ if (Number(spotNumber) < 0) {
107
+ showToast(ToastType.Error, t('VALIDATION_MUST_BIGGER_ZERO', '_attribute_ must be bigger than zero').replace('_attribute_', placeholderText))
108
+ return
109
+ }
110
+ const isVehicle = Object.values(vehicle).every(e => e)
111
+ const bodyToSend: any = {}
112
+ spotNumber && (bodyToSend.spot_number = spotNumber)
113
+ isVehicle && (bodyToSend.vehicle = vehicle)
114
+
115
+ if (Object.keys(bodyToSend).length) {
116
+ handleChangeSpot({ bodyToSend, isCheckout: !!isCheckout })
117
+ }
118
+ }
119
+
120
+ const manageErrorsToShow = (array = []) => {
121
+ let stringError = ''
122
+ const list = Array.isArray(array) ? array : Object.values(array)
123
+ list.map((item: any, i: number) => {
124
+ stringError += (i + 1) === array.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
125
+ })
126
+ return stringError;
127
+ }
46
128
 
47
129
  useEffect(() => {
48
130
  if (!placesState?.loading) {
@@ -52,51 +134,162 @@ const PlaceSpotUI = (props: PlaceSpotParams) => {
52
134
  }, [placesState])
53
135
 
54
136
  useEffect(() => {
55
- getPlacesList()
56
- }, [isOpenPlaceSpot])
137
+ if (spotState?.error?.length > 0) {
138
+ const errorText = manageErrorsToShow(spotState?.error)
139
+ showToast(ToastType.Error, errorText)
140
+ }
141
+ }, [spotState?.error])
142
+
143
+ const onChangePlaceSpot = (value: string) => {
144
+ setSpotNumber(value)
145
+ setPlaceSpotNumber(value)
146
+ }
57
147
 
58
148
  return (
59
149
  <PlaceSpotContainer>
60
- {(placesState.error || placesState?.placeGroups?.length === 0) && !placesState?.loading && (
61
- <NotFoundSource
62
- content={t('NO_PLACES_THIS_BUSINESS', 'There are not places for this business')}
63
- />
64
- )}
65
- {placesState?.loading && (
66
- <Placeholder>
67
- <PlaceGroupContainer>
68
- <PlaceholderLine width={100} height={25} />
69
- <PlaceholderLine height={30} />
70
- </PlaceGroupContainer>
71
- <View>
72
- <PlaceholderLine width={120} height={25} />
73
- <PlaceholderLine height={30} />
150
+ {isInputMode ? (
151
+ <PlaceGroupContainer>
152
+ <OText color={theme.colors.textNormal} size={16} weight='500' mBottom={15}>{orderTypes[currentOrderType]}</OText>
153
+ {vehicleInputAllowed.includes(currentOrderType) && (
154
+ <>
155
+ <View style={styles.optionWrapper}>
156
+ <OText color={theme.colors.textNormal} size={12} mBottom={5}>{t('VEHICLE_TYPE', 'Vehicle type')}</OText>
157
+ <SelectDropdown
158
+ defaultButtonText={t('SELECT_AN_OPTION', 'Select an option')}
159
+ data={vehicleTypeList}
160
+ defaultValue={vehicle?.type ? vehicleTypeList.find((obj: any) => obj.key === vehicle.type) : null}
161
+ onSelect={(selectedItem, index) => {
162
+ setVehicle({ ...vehicle, type: selectedItem.key ?? '' })
163
+ }}
164
+ buttonTextAfterSelection={(selectedItem, index) => {
165
+ return selectedItem.text
166
+ }}
167
+ rowTextForSelection={(item, index) => {
168
+ return item.text
169
+ }}
170
+ buttonStyle={styles.selectOption}
171
+ buttonTextStyle={{
172
+ color: theme.colors.disabled,
173
+ fontSize: 14,
174
+ textAlign: 'left',
175
+ marginHorizontal: 0
176
+ }}
177
+ dropdownStyle={{
178
+ borderRadius: 8,
179
+ borderColor: theme.colors.lightGray
180
+ }}
181
+ rowStyle={{
182
+ borderBottomColor: theme.colors.backgroundGray100,
183
+ backgroundColor: theme.colors.backgroundGray100,
184
+ height: 40,
185
+ flexDirection: 'column',
186
+ alignItems: 'flex-start',
187
+ paddingTop: 8,
188
+ paddingHorizontal: 14
189
+ }}
190
+ rowTextStyle={{
191
+ color: theme.colors.disabled,
192
+ fontSize: 14,
193
+ marginHorizontal: 0
194
+ }}
195
+ renderDropdownIcon={() => {
196
+ return (
197
+ <IconAntDesign
198
+ name='down'
199
+ color={theme.colors.textThird}
200
+ size={16}
201
+ />
202
+ )
203
+ }}
204
+ />
205
+ </View>
206
+ {vehicleInputList.map((input: any) => (
207
+ <View key={input.key}>
208
+ <OText color={theme.colors.textNormal} size={12} mBottom={5}>{input.text}</OText>
209
+ <OInput
210
+ placeholder={input.text}
211
+ value={vehicle[input.key] ?? ''}
212
+ onChange={(value: string) => setVehicle({ ...vehicle, [input.key]: value })}
213
+ style={{
214
+ borderColor: theme.colors.border,
215
+ borderRadius: 7.6,
216
+ marginBottom: 20
217
+ }}
218
+ inputStyle={{ fontSize: 12, color: theme.colors.textNormal }}
219
+ />
220
+ </View>
221
+ ))}
222
+ </>
223
+ )}
224
+ <OText color={theme.colors.textNormal} size={12} mBottom={5}>{placeholderText}</OText>
225
+ <OInput
226
+ value={spotNumber?.toString() ?? ''}
227
+ placeholder={placeholderText}
228
+ type='number-pad'
229
+ onChange={(value: string) => onChangePlaceSpot(value)}
230
+ style={{
231
+ borderColor: theme.colors.border,
232
+ borderRadius: 7.6
233
+ }}
234
+ inputStyle={{ fontSize: 12, color: theme.colors.textNormal }}
235
+ />
236
+ <View style={{ alignItems: 'flex-start' }}>
237
+ <OButton
238
+ onClick={() => onChangeSpot()}
239
+ bgColor={theme.colors.primary}
240
+ borderColor={theme.colors.primary}
241
+ textStyle={{ color: 'white', fontSize: 12 }}
242
+ imgRightSrc={null}
243
+ text={t('UPDATE_SPOT_NUMBER', 'Update')}
244
+ isDisabled={(!spotNumber && !Object.values(vehicle).every(e => e))}
245
+ style={{ borderRadius: 7.6, height: 44, shadowOpacity: 0, marginTop: 20 }}
246
+ />
74
247
  </View>
75
- </Placeholder>
76
- )}
77
- {!(placesState.error || placesState?.placeGroups?.length === 0) && !placesState?.loading && (
248
+ </PlaceGroupContainer>
249
+ ) : (
78
250
  <>
79
- <PlaceGroupContainer>
80
- <OText size={16} mBottom={10}>{t('PLACE_GROUP', 'Place group')}</OText>
81
- <ODropDown
82
- placeholder={t('PLACE_GROUP', 'Place group')}
83
- options={getPlacesGroups()}
84
- onSelect={(group: any) => setPlaceGroupSelected(group)}
85
- defaultValue={placeGroupSelected ?? cart?.place}
86
- isModal
251
+ {(placesState.error || placesState?.placeGroups?.length === 0) && !placesState?.loading && (
252
+ <NotFoundSource
253
+ content={t('NO_PLACES_THIS_BUSINESS', 'There are not places for this business')}
87
254
  />
88
- </PlaceGroupContainer>
89
- {placeGroupSelected && (
90
- <View>
91
- <OText size={16} mBottom={10}>{t('SELECT_YOUR_SPOT', 'Select your spot')}</OText>
92
- <ODropDown
93
- onSelect={(place: any) => handlerChangePlace(place)}
94
- placeholder={t('SELECT_YOUR_SPOT', 'Select your spot')}
95
- options={getPlaces()}
96
- defaultValue={placesState?.places?.find((place : any) => place?.id === cart?.place_id)}
97
- isModal
98
- />
99
- </View>
255
+ )}
256
+ {placesState?.loading && (
257
+ <Placeholder>
258
+ <PlaceGroupContainer>
259
+ <PlaceholderLine width={100} height={25} />
260
+ <PlaceholderLine height={30} />
261
+ </PlaceGroupContainer>
262
+ <View>
263
+ <PlaceholderLine width={120} height={25} />
264
+ <PlaceholderLine height={30} />
265
+ </View>
266
+ </Placeholder>
267
+ )}
268
+ {!(placesState.error || placesState?.placeGroups?.length === 0) && !placesState?.loading && (
269
+ <>
270
+ <PlaceGroupContainer>
271
+ <OText size={16} mBottom={10}>{t('PLACE_GROUP', 'Place group')}</OText>
272
+ <ODropDown
273
+ placeholder={t('PLACE_GROUP', 'Place group')}
274
+ options={getPlacesGroups()}
275
+ onSelect={(group: any) => setPlaceGroupSelected(group)}
276
+ defaultValue={placeGroupSelected ?? cart?.place}
277
+ isModal
278
+ />
279
+ </PlaceGroupContainer>
280
+ {placeGroupSelected && (
281
+ <View>
282
+ <OText size={16} mBottom={10}>{t('SELECT_YOUR_SPOT', 'Select your spot')}</OText>
283
+ <ODropDown
284
+ onSelect={(place: any) => handlerChangePlace(place)}
285
+ placeholder={t('SELECT_YOUR_SPOT', 'Select your spot')}
286
+ options={getPlaces()}
287
+ defaultValue={placesState?.places?.find((place: any) => place?.id === cart?.place_id)}
288
+ isModal
289
+ />
290
+ </View>
291
+ )}
292
+ </>
100
293
  )}
101
294
  </>
102
295
  )}
@@ -105,9 +298,18 @@ const PlaceSpotUI = (props: PlaceSpotParams) => {
105
298
  }
106
299
 
107
300
  export const PlaceSpot = (props: PlaceSpotParams) => {
301
+ const [, t] = useLanguage()
302
+
108
303
  const placeSpotProps = {
109
304
  ...props,
110
- UIComponent: PlaceSpotUI
305
+ UIComponent: PlaceSpotUI,
306
+ orderTypes: {
307
+ 1: t('DELIVERY', 'Delivery'),
308
+ 2: t('PICKUP', 'Pickup'),
309
+ 3: t('EAT_IN', 'Eat in'),
310
+ 4: t('CURBSIDE', 'Curbside'),
311
+ 5: t('DRIVE_THRU', 'Drive thru')
312
+ }
111
313
  }
112
314
 
113
315
  return <PlaceSpotController {...placeSpotProps} />
@@ -1,8 +1,6 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
3
  export const PlaceSpotContainer = styled.View`
4
- min-height: 300px;
5
- padding: 20px;
6
4
  `
7
5
 
8
6
  export const PlaceGroupContainer = styled.View`
@@ -19,7 +19,8 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
19
19
  handleReorder,
20
20
  reorderLoading,
21
21
  orderID,
22
- handleUpdateOrderList
22
+ handleUpdateOrderList,
23
+ loading
23
24
  } = props;
24
25
 
25
26
  const theme = useTheme();
@@ -42,7 +43,7 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
42
43
  handleUpdateOrderList={handleUpdateOrderList}
43
44
  />
44
45
  ))}
45
- {pagination.totalPages && pagination.currentPage < pagination.totalPages && (
46
+ {!loading && pagination.totalPages && pagination.currentPage < pagination.totalPages && (
46
47
  <WrappButton>
47
48
  <OButton
48
49
  onClick={loadMoreOrders}