ordering-ui-react-native 0.16.12 → 0.16.13-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.
- package/package.json +8 -4
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/ActiveOrders/index.tsx +61 -63
- package/src/components/ActiveOrders/styles.tsx +8 -14
- package/src/components/AddressForm/index.tsx +18 -2
- package/src/components/BusinessBasicInformation/index.tsx +11 -19
- package/src/components/BusinessController/index.tsx +10 -8
- package/src/components/BusinessInformation/index.tsx +22 -0
- package/src/components/BusinessProductsList/index.tsx +10 -10
- package/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +2 -1
- package/src/components/LanguageSelector/index.tsx +21 -16
- package/src/components/LoginForm/index.tsx +118 -30
- package/src/components/LoginForm/styles.tsx +6 -0
- package/src/components/Messages/index.tsx +2 -2
- package/src/components/NotificationSetting/index.tsx +85 -0
- package/src/components/OrderDetails/index.tsx +7 -21
- package/src/components/OrdersOption/index.tsx +54 -56
- package/src/components/PaymentOptions/index.tsx +335 -365
- package/src/components/PaymentOptionsWebView/index.tsx +120 -121
- package/src/components/ReviewDriver/index.tsx +1 -1
- package/src/components/ReviewOrder/index.tsx +2 -1
- package/src/components/ReviewProducts/index.tsx +11 -0
- package/src/components/SignupForm/index.tsx +143 -61
- package/src/components/SingleProductReview/index.tsx +8 -5
- package/src/components/StripeElementsForm/index.tsx +25 -16
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OBottomPopup.tsx +6 -2
- package/src/index.tsx +2 -0
- package/src/navigators/CheckoutNavigator.tsx +6 -0
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/BusinessesListing.tsx +7 -6
- package/src/pages/MultiCheckout.tsx +31 -0
- package/src/pages/MultiOrdersDetails.tsx +27 -0
- package/src/pages/OrderDetails.tsx +1 -1
- package/src/pages/ReviewDriver.tsx +2 -2
- package/src/pages/ReviewOrder.tsx +2 -2
- package/src/theme.json +0 -1
- package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
- package/src/types/index.tsx +13 -9
- package/src/utils/index.tsx +0 -1
- package/themes/business/index.tsx +4 -0
- package/themes/business/src/components/BusinessController/index.tsx +2 -2
- package/themes/business/src/components/Chat/index.tsx +42 -34
- package/themes/business/src/components/DriverMap/index.tsx +13 -10
- package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
- package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
- package/themes/business/src/components/LoginForm/index.tsx +111 -74
- package/themes/business/src/components/MapView/index.tsx +1 -1
- package/themes/business/src/components/MessagesOption/index.tsx +11 -1
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -3
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +19 -18
- package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
- package/themes/business/src/components/OrdersOption/index.tsx +65 -21
- package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
- package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
- package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
- package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
- package/themes/business/src/components/PreviousOrders/index.tsx +21 -23
- package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
- package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
- package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
- package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
- package/themes/business/src/components/shared/ODropDown.tsx +42 -8
- package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
- package/themes/business/src/components/shared/OModal.tsx +40 -37
- package/themes/business/src/types/index.tsx +14 -9
- package/themes/business/src/utils/index.tsx +10 -0
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/BusinessMenu/index.tsx +2 -1
- package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +1 -0
- package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
- package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
- package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
- package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
- package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +16 -0
- package/themes/original/src/components/AddressForm/index.tsx +136 -133
- package/themes/original/src/components/AddressList/index.tsx +1 -1
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
- package/themes/original/src/components/BusinessController/index.tsx +173 -108
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
- package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +106 -126
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +18 -13
- package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
- package/themes/original/src/components/BusinessProductsList/index.tsx +60 -77
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +290 -181
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -0
- package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +109 -40
- package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
- package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +676 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
- package/themes/original/src/components/BusinessesListing/index.tsx +100 -484
- package/themes/original/src/components/Cart/index.tsx +81 -36
- package/themes/original/src/components/Cart/styles.tsx +4 -0
- package/themes/original/src/components/CartContent/index.tsx +22 -16
- package/themes/original/src/components/Checkout/index.tsx +106 -66
- package/themes/original/src/components/Checkout/styles.tsx +0 -1
- package/themes/original/src/components/DriverTips/index.tsx +4 -4
- package/themes/original/src/components/DriverTips/styles.tsx +2 -1
- package/themes/original/src/components/Favorite/index.tsx +1 -0
- package/themes/original/src/components/Favorite/styles.tsx +1 -0
- package/themes/original/src/components/FavoriteList/index.tsx +143 -94
- package/themes/original/src/components/GPSButton/index.tsx +25 -17
- package/themes/original/src/components/GoogleMap/index.tsx +20 -12
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
- package/themes/original/src/components/HelpGuide/index.tsx +8 -3
- package/themes/original/src/components/HelpOrder/index.tsx +8 -3
- package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -2
- package/themes/original/src/components/LoginForm/index.tsx +79 -42
- package/themes/original/src/components/Messages/index.tsx +17 -17
- package/themes/original/src/components/MomentSelector/index.tsx +197 -0
- package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
- package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
- package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +262 -0
- package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
- package/themes/original/src/components/MyOrders/index.tsx +177 -27
- package/themes/original/src/components/MyOrders/styles.tsx +8 -1
- package/themes/original/src/components/NavBar/index.tsx +11 -5
- package/themes/original/src/components/NetworkError/index.tsx +5 -3
- package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
- package/themes/original/src/components/OrderDetails/index.tsx +125 -40
- package/themes/original/src/components/OrderDetails/styles.tsx +5 -2
- package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
- package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
- package/themes/original/src/components/OrderProgress/index.tsx +8 -2
- package/themes/original/src/components/OrderSummary/index.tsx +1 -34
- package/themes/original/src/components/OrderTypeSelector/index.tsx +84 -36
- package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +144 -0
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +56 -0
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
- package/themes/original/src/components/OrdersOption/index.tsx +126 -37
- package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
- package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
- package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
- package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
- package/themes/original/src/components/ProductForm/index.tsx +712 -655
- package/themes/original/src/components/ProductForm/styles.tsx +9 -7
- package/themes/original/src/components/ProductItemAccordion/index.tsx +40 -27
- package/themes/original/src/components/ProductOption/index.tsx +1 -1
- package/themes/original/src/components/ProfessionalFilter/index.tsx +129 -0
- package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
- package/themes/original/src/components/ProfessionalProfile/index.tsx +309 -0
- package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
- package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
- package/themes/original/src/components/ReviewOrder/index.tsx +18 -3
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
- package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
- package/themes/original/src/components/SearchBar/index.tsx +10 -5
- package/themes/original/src/components/ServiceForm/index.tsx +608 -0
- package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
- package/themes/original/src/components/SignupForm/index.tsx +301 -158
- package/themes/original/src/components/SingleOrderCard/index.tsx +213 -177
- package/themes/original/src/components/SingleProductCard/index.tsx +198 -110
- package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
- package/themes/original/src/components/SingleProductReview/index.tsx +30 -3
- package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
- package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
- package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
- package/themes/original/src/components/UpsellingProducts/index.tsx +14 -4
- package/themes/original/src/components/UserDetails/index.tsx +32 -18
- package/themes/original/src/components/UserFormDetails/index.tsx +107 -73
- package/themes/original/src/components/UserProfile/index.tsx +8 -1
- package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
- package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
- package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
- package/themes/original/src/components/Wallets/index.tsx +174 -162
- package/themes/original/src/components/Wallets/styles.tsx +10 -8
- package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
- package/themes/original/src/components/shared/OButton.tsx +10 -3
- package/themes/original/src/components/shared/OInput.tsx +3 -2
- package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
- package/themes/original/src/types/index.tsx +160 -47
- package/themes/original/src/utils/index.tsx +77 -0
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
PaymentOptions as PaymentOptionsController,
|
|
11
11
|
useLanguage,
|
|
12
|
-
|
|
12
|
+
ToastType,
|
|
13
13
|
useToast,
|
|
14
14
|
} from 'ordering-components/native';
|
|
15
15
|
import { useTheme } from 'styled-components/native';
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
PMCardItemContent
|
|
31
31
|
} from './styles'
|
|
32
32
|
import { getIconCard, flatArray } from '../../utils';
|
|
33
|
+
import { useApplePay } from '@stripe/stripe-react-native';
|
|
33
34
|
|
|
34
35
|
const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
|
|
35
36
|
const methodsPay = ['google_pay', 'apple_pay']
|
|
@@ -62,7 +63,8 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
62
63
|
} = props
|
|
63
64
|
|
|
64
65
|
const theme = useTheme();
|
|
65
|
-
|
|
66
|
+
const [, { showToast }] = useToast();
|
|
67
|
+
const { confirmApplePayPayment } = useApplePay()
|
|
66
68
|
|
|
67
69
|
const getPayIcon = (method: string) => {
|
|
68
70
|
switch (method) {
|
|
@@ -80,6 +82,8 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
80
82
|
return theme.images.general.stripes
|
|
81
83
|
case 'stripe_redirect':
|
|
82
84
|
return theme.images.general.stripesb
|
|
85
|
+
case 'apple_pay':
|
|
86
|
+
return theme.images.general.applePayMark
|
|
83
87
|
default:
|
|
84
88
|
return theme.images.general.creditCard
|
|
85
89
|
}
|
|
@@ -98,18 +102,18 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
98
102
|
// ]
|
|
99
103
|
|
|
100
104
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
if (cart?.balance > 0) {
|
|
106
|
+
const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
|
|
107
|
+
if (webViewPaymentGateway.includes(paymethod?.gateway)) {
|
|
108
|
+
handlePaymentMethodClickCustom(paymethod)
|
|
109
|
+
}
|
|
110
|
+
handlePaymethodClick(paymethod, isPopupMethod)
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
showToast(
|
|
110
114
|
ToastType.Error,
|
|
111
115
|
t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
|
|
112
|
-
|
|
116
|
+
;
|
|
113
117
|
}
|
|
114
118
|
|
|
115
119
|
useEffect(() => {
|
|
@@ -134,39 +138,55 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
134
138
|
|
|
135
139
|
useEffect(() => {
|
|
136
140
|
if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
|
|
137
|
-
|
|
141
|
+
handlePlaceOrder(confirmApplePayPayment)
|
|
138
142
|
}
|
|
139
143
|
}, [paymethodData, paymethodSelected])
|
|
140
144
|
|
|
141
145
|
const renderPaymethods = ({ item }: any) => {
|
|
142
146
|
return (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
key={item.id}
|
|
148
|
-
isDisabled={isDisabled}
|
|
149
|
-
isActive={paymethodSelected?.id === item.id}
|
|
150
|
-
>
|
|
151
|
-
<OIcon
|
|
152
|
-
src={getPayIcon(item.gateway)}
|
|
153
|
-
width={20}
|
|
154
|
-
height={20}
|
|
155
|
-
color={paymethodSelected?.id === item.id ? theme.colors.white : theme.colors.backgroundDark}
|
|
156
|
-
/>
|
|
157
|
-
<OText
|
|
158
|
-
size={10}
|
|
159
|
-
style={{ margin: 0, marginTop: 4 }}
|
|
160
|
-
color={paymethodSelected?.id === item.id ? theme.colors.white : '#000'}
|
|
147
|
+
<>
|
|
148
|
+
{item?.gateway === 'apple_pay' ? (
|
|
149
|
+
<TouchableOpacity
|
|
150
|
+
onPress={() => handlePaymentMethodClick(item)}
|
|
161
151
|
>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
152
|
+
<OIcon
|
|
153
|
+
src={getPayIcon(item.gateway)}
|
|
154
|
+
width={70}
|
|
155
|
+
height={70}
|
|
156
|
+
style={{ marginRight: 10 }}
|
|
157
|
+
/>
|
|
158
|
+
</TouchableOpacity>
|
|
159
|
+
) : (
|
|
160
|
+
<TouchableOpacity
|
|
161
|
+
onPress={() => handlePaymentMethodClick(item)}
|
|
162
|
+
>
|
|
163
|
+
<PMItem
|
|
164
|
+
key={item.id}
|
|
165
|
+
isDisabled={isDisabled}
|
|
166
|
+
isActive={paymethodSelected?.id === item.id}
|
|
167
|
+
>
|
|
168
|
+
<OIcon
|
|
169
|
+
src={getPayIcon(item.gateway)}
|
|
170
|
+
width={20}
|
|
171
|
+
height={20}
|
|
172
|
+
color={item?.gateway === 'apple_pay' ? '' : paymethodSelected?.id === item.id ? theme.colors.white : theme.colors.backgroundDark}
|
|
173
|
+
/>
|
|
174
|
+
<OText
|
|
175
|
+
size={10}
|
|
176
|
+
style={{ margin: 0, marginTop: 4 }}
|
|
177
|
+
color={paymethodSelected?.id === item.id ? theme.colors.white : '#000'}
|
|
178
|
+
>
|
|
179
|
+
{t(item.gateway.toUpperCase(), item.name)}
|
|
180
|
+
</OText>
|
|
181
|
+
</PMItem>
|
|
182
|
+
</TouchableOpacity>
|
|
183
|
+
)}
|
|
184
|
+
</>
|
|
185
|
+
|
|
166
186
|
)
|
|
167
187
|
}
|
|
168
188
|
|
|
169
|
-
const excludeIds: any = [32]; //exclude paypal & connect & redirect
|
|
189
|
+
const excludeIds: any = [32, 66]; //exclude paypal & connect & redirect
|
|
170
190
|
|
|
171
191
|
return (
|
|
172
192
|
<PMContainer>
|
|
@@ -214,7 +234,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
214
234
|
|
|
215
235
|
{paymethodSelected?.gateway === 'cash' && (
|
|
216
236
|
<PaymentOptionCash
|
|
217
|
-
orderTotal={cart.total}
|
|
237
|
+
orderTotal={cart.balance ?? cart.total}
|
|
218
238
|
defaultValue={paymethodSelected?.data?.cash}
|
|
219
239
|
onChangeData={handlePaymethodDataChange}
|
|
220
240
|
setErrorCash={props.setErrorCash}
|
|
@@ -22,9 +22,8 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
22
22
|
textStyle,
|
|
23
23
|
flagStyle,
|
|
24
24
|
noDropIcon,
|
|
25
|
-
|
|
26
|
-
isStartValidation
|
|
27
|
-
changeCountry
|
|
25
|
+
isDisabled,
|
|
26
|
+
isStartValidation
|
|
28
27
|
} = props
|
|
29
28
|
|
|
30
29
|
const theme = useTheme();
|
|
@@ -107,16 +106,11 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
107
106
|
)}
|
|
108
107
|
<PhoneInput
|
|
109
108
|
ref={phoneInput}
|
|
110
|
-
|
|
109
|
+
disabled={isDisabled}
|
|
111
110
|
defaultValue={userphoneNumber || defaultValue}
|
|
112
|
-
defaultCode={defaultCode ?
|
|
113
|
-
!isNaN(defaultCode)
|
|
114
|
-
? transformCountryCode(defaultCode)
|
|
115
|
-
: defaultCode
|
|
116
|
-
: configs?.default_country_code?.value}
|
|
111
|
+
defaultCode={defaultCode ? transformCountryCode(defaultCode) : configs?.default_country_code?.value}
|
|
117
112
|
onChangeFormattedText={(text: string) => handleChangeNumber(text)}
|
|
118
113
|
withDarkTheme
|
|
119
|
-
onChangeCountry={(country) => changeCountry?.(country)}
|
|
120
114
|
countryPickerProps={{ withAlphaFilter: true }}
|
|
121
115
|
textContainerStyle={{ ...style.input, ...inputStyle ? inputStyle : {} }}
|
|
122
116
|
textInputStyle={textStyle}
|
|
@@ -1,24 +1,78 @@
|
|
|
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
|
-
|
|
17
|
-
|
|
19
|
+
spotNumber,
|
|
20
|
+
spotState,
|
|
21
|
+
isCheckout,
|
|
22
|
+
vehicle,
|
|
23
|
+
isInputMode,
|
|
24
|
+
setSpotNumber,
|
|
25
|
+
setVehicle,
|
|
26
|
+
handleChangeSpot
|
|
18
27
|
} = props
|
|
19
28
|
|
|
29
|
+
const theme = useTheme()
|
|
20
30
|
const [, t] = useLanguage()
|
|
31
|
+
const [orderState] = useOrder()
|
|
32
|
+
const [, { showToast }] = useToast();
|
|
33
|
+
|
|
21
34
|
const [placeGroupSelected, setPlaceGroupSelected] = useState<any>(null)
|
|
35
|
+
const vehicleInputAllowed = [4, 5]
|
|
36
|
+
|
|
37
|
+
const currentOrderType = isCheckout ? orderState?.options?.type : cart?.delivery_type
|
|
38
|
+
const isEatin = currentOrderType === 3
|
|
39
|
+
const isDriveThru = currentOrderType === 5
|
|
40
|
+
const placeholderText = isEatin
|
|
41
|
+
? t('EATIN_SPOT_NUMBER', 'Table number')
|
|
42
|
+
: isDriveThru
|
|
43
|
+
? t('DRIVE_THRU_SPOT_NUMBER', 'Drive thru lane')
|
|
44
|
+
: t('CURBSIDE_SPOT_NUMBER', 'Spot number')
|
|
45
|
+
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
selectOption: {
|
|
48
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
49
|
+
borderRadius: 7.6,
|
|
50
|
+
paddingVertical: 10,
|
|
51
|
+
paddingHorizontal: 14,
|
|
52
|
+
flexDirection: 'row-reverse',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
justifyContent: 'space-between',
|
|
55
|
+
height: 50,
|
|
56
|
+
width: '100%'
|
|
57
|
+
},
|
|
58
|
+
optionWrapper: {
|
|
59
|
+
marginBottom: 20
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const vehicleTypeList: any = [
|
|
64
|
+
{ key: 'car', text: t('VEHICLE_TYPE_CAR', 'Car') },
|
|
65
|
+
{ key: 'truck', text: t('VEHICLE_TYPE_TRUCK', 'Truck') },
|
|
66
|
+
{ key: 'suv', text: t('VEHICLE_TYPE_SUV', 'SUV') },
|
|
67
|
+
{ key: 'van', text: t('VEHICLE_TYPE_VAN', 'Van') },
|
|
68
|
+
{ key: 'motorcycle', text: t('VEHICLE_TYPE_MOTORCYCLE', 'Motorcycle') }
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
const vehicleInputList = [
|
|
72
|
+
{ key: 'model', text: t('VEHICLE_MODEL', 'Model') },
|
|
73
|
+
{ key: 'car_registration', text: t('VEHICLE_CAR_REGISTRATION', 'Car registration') },
|
|
74
|
+
{ key: 'color', text: t('VEHICLE_COLOR', 'Color') }
|
|
75
|
+
]
|
|
22
76
|
|
|
23
77
|
const getPlacesGroups = () => {
|
|
24
78
|
const groups = placesState.placeGroups?.filter((group: any) => group?.enabled && placesState?.places?.find((place: any) => place?.enabled && place?.place_group_id === group?.id))
|
|
@@ -39,10 +93,37 @@ const PlaceSpotUI = (props: PlaceSpotParams) => {
|
|
|
39
93
|
}
|
|
40
94
|
|
|
41
95
|
const handlerChangePlace = (place: any) => {
|
|
42
|
-
setOpenPlaceModal(false)
|
|
43
96
|
handleChangePlace(place)
|
|
44
97
|
}
|
|
45
98
|
|
|
99
|
+
const onChangeSpot = () => {
|
|
100
|
+
if (orderState.loading) return
|
|
101
|
+
if (!Number.isInteger(Number(spotNumber))) {
|
|
102
|
+
showToast(ToastType.Error, t('VALIDATION_ERROR_INTEGER', 'The _attribute_ must be an integer.').replace('_attribute_', placeholderText))
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
if (Number(spotNumber) < 0) {
|
|
106
|
+
showToast(ToastType.Error, t('VALIDATION_MUST_BIGGER_ZERO', '_attribute_ must be bigger than zero').replace('_attribute_', placeholderText))
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
const isVehicle = Object.values(vehicle).every(e => e)
|
|
110
|
+
const bodyToSend: any = {}
|
|
111
|
+
spotNumber && (bodyToSend.spot_number = spotNumber)
|
|
112
|
+
isVehicle && (bodyToSend.vehicle = vehicle)
|
|
113
|
+
|
|
114
|
+
if (Object.keys(bodyToSend).length) {
|
|
115
|
+
handleChangeSpot({ bodyToSend, isCheckout: !!isCheckout })
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const manageErrorsToShow = (array = []) => {
|
|
120
|
+
let stringError = ''
|
|
121
|
+
const list = Array.isArray(array) ? array : Object.values(array)
|
|
122
|
+
list.map((item: any, i: number) => {
|
|
123
|
+
stringError += (i + 1) === array.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
|
|
124
|
+
})
|
|
125
|
+
return stringError;
|
|
126
|
+
}
|
|
46
127
|
|
|
47
128
|
useEffect(() => {
|
|
48
129
|
if (!placesState?.loading) {
|
|
@@ -52,51 +133,157 @@ const PlaceSpotUI = (props: PlaceSpotParams) => {
|
|
|
52
133
|
}, [placesState])
|
|
53
134
|
|
|
54
135
|
useEffect(() => {
|
|
55
|
-
|
|
56
|
-
|
|
136
|
+
if (spotState?.error?.length > 0) {
|
|
137
|
+
const errorText = manageErrorsToShow(spotState?.error)
|
|
138
|
+
showToast(ToastType.Error, errorText)
|
|
139
|
+
}
|
|
140
|
+
}, [spotState?.error])
|
|
57
141
|
|
|
58
142
|
return (
|
|
59
143
|
<PlaceSpotContainer>
|
|
60
|
-
{
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
144
|
+
{isInputMode ? (
|
|
145
|
+
<PlaceGroupContainer>
|
|
146
|
+
<OText color={theme.colors.textNormal} size={16} weight='500' mBottom={15}>{orderTypes[currentOrderType]}</OText>
|
|
147
|
+
{vehicleInputAllowed.includes(currentOrderType) && (
|
|
148
|
+
<>
|
|
149
|
+
<View style={styles.optionWrapper}>
|
|
150
|
+
<OText color={theme.colors.textNormal} size={12} mBottom={5}>{t('VEHICLE_TYPE', 'Vehicle type')}</OText>
|
|
151
|
+
<SelectDropdown
|
|
152
|
+
defaultButtonText={t('SELECT_AN_OPTION', 'Select an option')}
|
|
153
|
+
data={vehicleTypeList}
|
|
154
|
+
defaultValue={vehicle?.type ? vehicleTypeList.find((obj: any) => obj.key === vehicle.type) : null}
|
|
155
|
+
onSelect={(selectedItem, index) => {
|
|
156
|
+
setVehicle({ ...vehicle, type: selectedItem.key ?? '' })
|
|
157
|
+
}}
|
|
158
|
+
buttonTextAfterSelection={(selectedItem, index) => {
|
|
159
|
+
return selectedItem.text
|
|
160
|
+
}}
|
|
161
|
+
rowTextForSelection={(item, index) => {
|
|
162
|
+
return item.text
|
|
163
|
+
}}
|
|
164
|
+
buttonStyle={styles.selectOption}
|
|
165
|
+
buttonTextStyle={{
|
|
166
|
+
color: theme.colors.disabled,
|
|
167
|
+
fontSize: 14,
|
|
168
|
+
textAlign: 'left',
|
|
169
|
+
marginHorizontal: 0
|
|
170
|
+
}}
|
|
171
|
+
dropdownStyle={{
|
|
172
|
+
borderRadius: 8,
|
|
173
|
+
borderColor: theme.colors.lightGray
|
|
174
|
+
}}
|
|
175
|
+
rowStyle={{
|
|
176
|
+
borderBottomColor: theme.colors.backgroundGray100,
|
|
177
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
178
|
+
height: 40,
|
|
179
|
+
flexDirection: 'column',
|
|
180
|
+
alignItems: 'flex-start',
|
|
181
|
+
paddingTop: 8,
|
|
182
|
+
paddingHorizontal: 14
|
|
183
|
+
}}
|
|
184
|
+
rowTextStyle={{
|
|
185
|
+
color: theme.colors.disabled,
|
|
186
|
+
fontSize: 14,
|
|
187
|
+
marginHorizontal: 0
|
|
188
|
+
}}
|
|
189
|
+
renderDropdownIcon={() => {
|
|
190
|
+
return (
|
|
191
|
+
<IconAntDesign
|
|
192
|
+
name='down'
|
|
193
|
+
color={theme.colors.textThird}
|
|
194
|
+
size={16}
|
|
195
|
+
/>
|
|
196
|
+
)
|
|
197
|
+
}}
|
|
198
|
+
/>
|
|
199
|
+
</View>
|
|
200
|
+
{vehicleInputList.map((input: any) => (
|
|
201
|
+
<View key={input.key}>
|
|
202
|
+
<OText color={theme.colors.textNormal} size={12} mBottom={5}>{input.text}</OText>
|
|
203
|
+
<OInput
|
|
204
|
+
placeholder={input.text}
|
|
205
|
+
value={vehicle[input.key] ?? ''}
|
|
206
|
+
onChange={(value: string) => setVehicle({ ...vehicle, [input.key]: value })}
|
|
207
|
+
style={{
|
|
208
|
+
borderColor: theme.colors.border,
|
|
209
|
+
borderRadius: 7.6,
|
|
210
|
+
marginBottom: 20
|
|
211
|
+
}}
|
|
212
|
+
inputStyle={{ fontSize: 12, color: theme.colors.textNormal }}
|
|
213
|
+
/>
|
|
214
|
+
</View>
|
|
215
|
+
))}
|
|
216
|
+
</>
|
|
217
|
+
)}
|
|
218
|
+
<OText color={theme.colors.textNormal} size={12} mBottom={5}>{placeholderText}</OText>
|
|
219
|
+
<OInput
|
|
220
|
+
value={spotNumber?.toString() ?? ''}
|
|
221
|
+
placeholder={placeholderText}
|
|
222
|
+
type='number-pad'
|
|
223
|
+
onChange={(value: string) => setSpotNumber(value)}
|
|
224
|
+
style={{
|
|
225
|
+
borderColor: theme.colors.border,
|
|
226
|
+
borderRadius: 7.6
|
|
227
|
+
}}
|
|
228
|
+
inputStyle={{ fontSize: 12, color: theme.colors.textNormal }}
|
|
229
|
+
/>
|
|
230
|
+
<View style={{ alignItems: 'flex-start' }}>
|
|
231
|
+
<OButton
|
|
232
|
+
onClick={() => onChangeSpot()}
|
|
233
|
+
bgColor={theme.colors.primary}
|
|
234
|
+
borderColor={theme.colors.primary}
|
|
235
|
+
textStyle={{ color: 'white', fontSize: 12 }}
|
|
236
|
+
imgRightSrc={null}
|
|
237
|
+
text={t('UPDATE_SPOT_NUMBER', 'Update')}
|
|
238
|
+
isDisabled={(!spotNumber && !Object.values(vehicle).every(e => e))}
|
|
239
|
+
style={{ borderRadius: 7.6, height: 44, shadowOpacity: 0, marginTop: 20 }}
|
|
240
|
+
/>
|
|
74
241
|
</View>
|
|
75
|
-
</
|
|
76
|
-
)
|
|
77
|
-
{!(placesState.error || placesState?.placeGroups?.length === 0) && !placesState?.loading && (
|
|
242
|
+
</PlaceGroupContainer>
|
|
243
|
+
) : (
|
|
78
244
|
<>
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
placeholder={t('PLACE_GROUP', 'Place group')}
|
|
83
|
-
options={getPlacesGroups()}
|
|
84
|
-
onSelect={(group: any) => setPlaceGroupSelected(group)}
|
|
85
|
-
defaultValue={placeGroupSelected ?? cart?.place}
|
|
86
|
-
isModal
|
|
245
|
+
{(placesState.error || placesState?.placeGroups?.length === 0) && !placesState?.loading && (
|
|
246
|
+
<NotFoundSource
|
|
247
|
+
content={t('NO_PLACES_THIS_BUSINESS', 'There are not places for this business')}
|
|
87
248
|
/>
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</
|
|
249
|
+
)}
|
|
250
|
+
{placesState?.loading && (
|
|
251
|
+
<Placeholder>
|
|
252
|
+
<PlaceGroupContainer>
|
|
253
|
+
<PlaceholderLine width={100} height={25} />
|
|
254
|
+
<PlaceholderLine height={30} />
|
|
255
|
+
</PlaceGroupContainer>
|
|
256
|
+
<View>
|
|
257
|
+
<PlaceholderLine width={120} height={25} />
|
|
258
|
+
<PlaceholderLine height={30} />
|
|
259
|
+
</View>
|
|
260
|
+
</Placeholder>
|
|
261
|
+
)}
|
|
262
|
+
{!(placesState.error || placesState?.placeGroups?.length === 0) && !placesState?.loading && (
|
|
263
|
+
<>
|
|
264
|
+
<PlaceGroupContainer>
|
|
265
|
+
<OText size={16} mBottom={10}>{t('PLACE_GROUP', 'Place group')}</OText>
|
|
266
|
+
<ODropDown
|
|
267
|
+
placeholder={t('PLACE_GROUP', 'Place group')}
|
|
268
|
+
options={getPlacesGroups()}
|
|
269
|
+
onSelect={(group: any) => setPlaceGroupSelected(group)}
|
|
270
|
+
defaultValue={placeGroupSelected ?? cart?.place}
|
|
271
|
+
isModal
|
|
272
|
+
/>
|
|
273
|
+
</PlaceGroupContainer>
|
|
274
|
+
{placeGroupSelected && (
|
|
275
|
+
<View>
|
|
276
|
+
<OText size={16} mBottom={10}>{t('SELECT_YOUR_SPOT', 'Select your spot')}</OText>
|
|
277
|
+
<ODropDown
|
|
278
|
+
onSelect={(place: any) => handlerChangePlace(place)}
|
|
279
|
+
placeholder={t('SELECT_YOUR_SPOT', 'Select your spot')}
|
|
280
|
+
options={getPlaces()}
|
|
281
|
+
defaultValue={placesState?.places?.find((place : any) => place?.id === cart?.place_id)}
|
|
282
|
+
isModal
|
|
283
|
+
/>
|
|
284
|
+
</View>
|
|
285
|
+
)}
|
|
286
|
+
</>
|
|
100
287
|
)}
|
|
101
288
|
</>
|
|
102
289
|
)}
|
|
@@ -105,9 +292,18 @@ const PlaceSpotUI = (props: PlaceSpotParams) => {
|
|
|
105
292
|
}
|
|
106
293
|
|
|
107
294
|
export const PlaceSpot = (props: PlaceSpotParams) => {
|
|
295
|
+
const [, t] = useLanguage()
|
|
296
|
+
|
|
108
297
|
const placeSpotProps = {
|
|
109
298
|
...props,
|
|
110
|
-
UIComponent: PlaceSpotUI
|
|
299
|
+
UIComponent: PlaceSpotUI,
|
|
300
|
+
orderTypes: {
|
|
301
|
+
1: t('DELIVERY', 'Delivery'),
|
|
302
|
+
2: t('PICKUP', 'Pickup'),
|
|
303
|
+
3: t('EAT_IN', 'Eat in'),
|
|
304
|
+
4: t('CURBSIDE', 'Curbside'),
|
|
305
|
+
5: t('DRIVE_THRU', 'Drive thru')
|
|
306
|
+
}
|
|
111
307
|
}
|
|
112
308
|
|
|
113
309
|
return <PlaceSpotController {...placeSpotProps} />
|