ordering-ui-react-native 0.22.43 → 0.22.44-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 +6 -8
- package/src/DeliveryApp.tsx +1 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +40 -39
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/context/OfflineActions/index.tsx +236 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/BusinessController/index.tsx +8 -3
- package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
- package/themes/business/src/components/Chat/index.tsx +15 -3
- package/themes/business/src/components/DriverMap/index.tsx +44 -33
- package/themes/business/src/components/FloatingButton/index.tsx +3 -2
- package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
- package/themes/business/src/components/LoginForm/index.tsx +123 -98
- package/themes/business/src/components/LogoutButton/index.tsx +14 -5
- package/themes/business/src/components/MapView/index.tsx +42 -22
- package/themes/business/src/components/NewOrderNotification/index.tsx +38 -19
- package/themes/business/src/components/OrderDetails/Business.tsx +34 -16
- package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +155 -45
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
- package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
- package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
- package/themes/business/src/components/OrderSummary/index.tsx +6 -4
- package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
- package/themes/business/src/components/OrdersOption/index.tsx +332 -231
- package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +29 -18
- package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
- package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
- package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
- package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
- package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
- package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
- package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
- package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
- package/themes/business/src/components/StoresList/index.tsx +2 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
- package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
- package/themes/business/src/components/shared/OTextarea.tsx +8 -9
- package/themes/business/src/config/currency.tsx +1010 -0
- package/themes/business/src/hooks/useLocation.tsx +16 -12
- package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
- package/themes/business/src/types/index.tsx +22 -7
- package/themes/business/src/utils/index.tsx +28 -3
- 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/Checkout/index.tsx +9 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
- 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/PaymentOptions/index.tsx +121 -57
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +9 -1
- package/themes/original/src/components/AddressForm/index.tsx +25 -17
- package/themes/original/src/components/AddressList/index.tsx +8 -7
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +14 -6
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +8 -6
- package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
- package/themes/original/src/components/BusinessPreorder/index.tsx +46 -28
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
- package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
- package/themes/original/src/components/Cart/index.tsx +49 -15
- package/themes/original/src/components/CartContent/index.tsx +2 -4
- package/themes/original/src/components/Checkout/index.tsx +127 -79
- package/themes/original/src/components/CitiesControl/index.tsx +0 -3
- package/themes/original/src/components/CouponControl/index.tsx +1 -3
- package/themes/original/src/components/DriverTips/index.tsx +1 -3
- package/themes/original/src/components/Favorite/index.tsx +1 -5
- package/themes/original/src/components/FavoriteList/index.tsx +0 -1
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
- package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
- package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
- package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
- package/themes/original/src/components/GoogleMap/index.tsx +39 -18
- package/themes/original/src/components/Help/index.tsx +2 -0
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +35 -19
- package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
- package/themes/original/src/components/LoginForm/index.tsx +13 -10
- package/themes/original/src/components/MessageListing/index.tsx +2 -1
- package/themes/original/src/components/Messages/index.tsx +20 -13
- package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
- package/themes/original/src/components/MomentOption/index.tsx +80 -52
- package/themes/original/src/components/MomentSelector/index.tsx +5 -2
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -4
- package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
- package/themes/original/src/components/MyOrders/index.tsx +2 -2
- package/themes/original/src/components/NavBar/index.tsx +7 -4
- package/themes/original/src/components/NetworkError/index.tsx +0 -5
- package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +16 -11
- package/themes/original/src/components/OrderDetails/index.tsx +44 -21
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderProgress/index.tsx +4 -3
- package/themes/original/src/components/OrderSummary/index.tsx +32 -11
- package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
- package/themes/original/src/components/OrdersOption/index.tsx +3 -6
- package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +462 -461
- package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
- package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
- package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
- package/themes/original/src/components/ProductForm/ActionButton.tsx +7 -12
- package/themes/original/src/components/ProductForm/index.tsx +107 -102
- package/themes/original/src/components/ProductItemAccordion/index.tsx +30 -38
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
- package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
- package/themes/original/src/components/Promotions/index.tsx +2 -2
- package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
- package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
- package/themes/original/src/components/ServiceForm/index.tsx +52 -54
- package/themes/original/src/components/Sessions/index.tsx +3 -3
- package/themes/original/src/components/SignupForm/index.tsx +44 -32
- package/themes/original/src/components/SingleOrderCard/index.tsx +6 -4
- package/themes/original/src/components/SingleProductCard/index.tsx +5 -5
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +16 -3
- package/themes/original/src/components/StripeElementsForm/index.tsx +8 -4
- package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -1
- package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
- package/themes/original/src/components/TaxInformation/index.tsx +3 -2
- package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +8 -5
- package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
- package/themes/original/src/components/UserDetails/index.tsx +17 -16
- package/themes/original/src/components/UserFormDetails/index.tsx +115 -75
- package/themes/original/src/components/UserProfile/index.tsx +9 -1
- package/themes/original/src/components/UserVerification/index.tsx +18 -5
- package/themes/original/src/components/Wallets/index.tsx +6 -3
- package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
- package/themes/original/src/components/shared/OAlert.tsx +2 -1
- package/themes/original/src/components/shared/OButton.tsx +5 -4
- package/themes/original/src/components/shared/OInput.tsx +4 -8
- package/themes/original/src/components/shared/OModal.tsx +7 -2
- package/themes/original/src/types/index.tsx +12 -4
- package/themes/original/src/utils/index.tsx +29 -0
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import PhoneInput from "react-native-phone-number-input";
|
|
3
|
-
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { Pressable, StyleSheet, View } from 'react-native';
|
|
4
4
|
import { useLanguage, useConfig } from 'ordering-components/native';
|
|
5
5
|
import { useTheme } from 'styled-components/native';
|
|
6
6
|
import { Wrapper } from './styles'
|
|
7
7
|
|
|
8
8
|
import { PhoneInputParams } from '../../types';
|
|
9
9
|
import { OIcon, OText } from '../shared';
|
|
10
|
+
import { OModal } from '../../../../../src/components/shared'
|
|
10
11
|
import { findExitingCode, transformCountryCode } from '../../utils'
|
|
11
12
|
|
|
12
13
|
export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
@@ -25,7 +26,8 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
25
26
|
isDisabled,
|
|
26
27
|
isStartValidation,
|
|
27
28
|
changeCountry,
|
|
28
|
-
updateStateWithSubmit
|
|
29
|
+
updateStateWithSubmit,
|
|
30
|
+
defaultCodeFallback
|
|
29
31
|
} = props
|
|
30
32
|
|
|
31
33
|
const theme = useTheme();
|
|
@@ -34,6 +36,13 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
34
36
|
const [{ configs }] = useConfig()
|
|
35
37
|
const phoneInput = useRef<PhoneInput>(null);
|
|
36
38
|
const [userphoneNumber, setUserphoneNumber] = useState('');
|
|
39
|
+
const [countryPhoneSuboptions, setCountryPhoneSuboptions] = useState({
|
|
40
|
+
open: false,
|
|
41
|
+
options: []
|
|
42
|
+
})
|
|
43
|
+
const isDisableNumberValidation = parseInt(configs?.validation_phone_number_lib?.value ?? 1, 10)
|
|
44
|
+
const countriesWithSubOptions = ['PR']
|
|
45
|
+
const codesStartsWithZero: any = ['44']
|
|
37
46
|
|
|
38
47
|
const style = StyleSheet.create({
|
|
39
48
|
input: {
|
|
@@ -62,13 +71,22 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
62
71
|
useEffect(() => {
|
|
63
72
|
if ((defaultValue && userphoneNumber) || !defaultValue) {
|
|
64
73
|
if (userphoneNumber) {
|
|
65
|
-
const
|
|
74
|
+
const validationsForUK = ['01', '02', '07', '0800', '0808', '0845', '0870', '0871']
|
|
75
|
+
|
|
76
|
+
let isPossibly = false
|
|
77
|
+
let numberWithoutCountryCode = ''
|
|
66
78
|
const callingCode = phoneInput.current?.getCallingCode();
|
|
79
|
+
const cellphone = userphoneNumber.slice(0, 0) + userphoneNumber.slice(1, userphoneNumber.length)
|
|
80
|
+
if (codesStartsWithZero.includes(callingCode)) {
|
|
81
|
+
numberWithoutCountryCode = cellphone.replace(callingCode || '', '')
|
|
82
|
+
const result = validationsForUK.some(areaCode => numberWithoutCountryCode?.startsWith(areaCode))
|
|
83
|
+
isPossibly = result && numberWithoutCountryCode?.length >= 10 && numberWithoutCountryCode?.length < 12
|
|
84
|
+
}
|
|
85
|
+
const checkValid = phoneInput.current?.isValidNumber(userphoneNumber);
|
|
67
86
|
const formattedNumber = phoneInput.current?.getNumberAfterPossiblyEliminatingZero();
|
|
68
87
|
const regex = /^[0-9]*$/
|
|
69
|
-
const cellphone = userphoneNumber.slice(0, 0) + userphoneNumber.slice(1, userphoneNumber.length)
|
|
70
88
|
const validNumber = regex.test(cellphone)
|
|
71
|
-
if ((!checkValid && formattedNumber?.number) || !validNumber) {
|
|
89
|
+
if (((!checkValid && formattedNumber?.number && !isPossibly) || !validNumber) && !!isDisableNumberValidation) {
|
|
72
90
|
handleData && handleData({
|
|
73
91
|
...data,
|
|
74
92
|
error: t('INVALID_ERROR_PHONE_NUMBER', 'The Phone Number field is invalid')
|
|
@@ -80,8 +98,11 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
80
98
|
error: '',
|
|
81
99
|
phone: {
|
|
82
100
|
country_phone_code: callingCode,
|
|
83
|
-
cellphone: formattedNumber?.number
|
|
101
|
+
cellphone: !isDisableNumberValidation ? cellphone.slice(callingCode?.length) : formattedNumber?.number
|
|
84
102
|
}
|
|
103
|
+
}, {
|
|
104
|
+
countryCallingCode: callingCode,
|
|
105
|
+
number: numberWithoutCountryCode,
|
|
85
106
|
})
|
|
86
107
|
} else {
|
|
87
108
|
handleData && handleData({
|
|
@@ -109,6 +130,37 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
109
130
|
}
|
|
110
131
|
}, [defaultValue])
|
|
111
132
|
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (defaultCodeFallback && countriesWithSubOptions.includes(defaultCode) && phoneInput.current) {
|
|
135
|
+
phoneInput.current?.setState({
|
|
136
|
+
...phoneInput.current.state,
|
|
137
|
+
code: `${defaultCodeFallback}`
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
}, [phoneInput.current])
|
|
141
|
+
|
|
142
|
+
const _changeCountry = (c) => {
|
|
143
|
+
changeCountry?.(c)
|
|
144
|
+
if (c.callingCode?.length > 1) {
|
|
145
|
+
setCountryPhoneSuboptions({
|
|
146
|
+
open: true,
|
|
147
|
+
options: c.callingCode
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const handleSelectCallingCode = (option: any) => {
|
|
153
|
+
setCountryPhoneSuboptions({
|
|
154
|
+
open: false,
|
|
155
|
+
options: []
|
|
156
|
+
})
|
|
157
|
+
handleChangeNumber(`+${option}`)
|
|
158
|
+
phoneInput.current?.setState({
|
|
159
|
+
...phoneInput.current.state,
|
|
160
|
+
code: `${option}`
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
112
164
|
return (
|
|
113
165
|
<Wrapper onPress={() => forwardRef?.current?.focus?.()}>
|
|
114
166
|
{(isStartValidation && userphoneNumber === '') && (
|
|
@@ -130,7 +182,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
130
182
|
: findExitingCode(configs?.default_country_code?.value?.toUpperCase())}
|
|
131
183
|
onChangeFormattedText={(text: string) => handleChangeNumber(text)}
|
|
132
184
|
withDarkTheme
|
|
133
|
-
onChangeCountry={(country) =>
|
|
185
|
+
onChangeCountry={(country: any) => _changeCountry?.(country)}
|
|
134
186
|
countryPickerProps={{ withAlphaFilter: true }}
|
|
135
187
|
textContainerStyle={{ ...style.input, ...inputStyle ? inputStyle : {} }}
|
|
136
188
|
textInputStyle={textStyle}
|
|
@@ -151,6 +203,39 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
151
203
|
{data.error}
|
|
152
204
|
</OText>
|
|
153
205
|
)}
|
|
206
|
+
<OModal
|
|
207
|
+
open={countryPhoneSuboptions.open}
|
|
208
|
+
onClose={() => setCountryPhoneSuboptions({
|
|
209
|
+
open: false,
|
|
210
|
+
options: []
|
|
211
|
+
})}
|
|
212
|
+
title={t('SELECT_THE_PHONE_CODE', 'Select the phone code')}
|
|
213
|
+
entireModal
|
|
214
|
+
>
|
|
215
|
+
<View
|
|
216
|
+
style={{
|
|
217
|
+
alignItems: 'center'
|
|
218
|
+
}}
|
|
219
|
+
>
|
|
220
|
+
{countryPhoneSuboptions.options.map((option: any) => (
|
|
221
|
+
<Pressable
|
|
222
|
+
style={{
|
|
223
|
+
margin: 10,
|
|
224
|
+
padding: 10,
|
|
225
|
+
borderBottomColor: '#ccc',
|
|
226
|
+
borderBottomWidth: 1,
|
|
227
|
+
width: '100%'
|
|
228
|
+
}}
|
|
229
|
+
key={option}
|
|
230
|
+
onPress={() => handleSelectCallingCode(option)}
|
|
231
|
+
>
|
|
232
|
+
<OText>
|
|
233
|
+
{`+${option}`}
|
|
234
|
+
</OText>
|
|
235
|
+
</Pressable>
|
|
236
|
+
))}
|
|
237
|
+
</View>
|
|
238
|
+
</OModal>
|
|
154
239
|
</Wrapper>
|
|
155
240
|
)
|
|
156
241
|
}
|
|
@@ -236,9 +236,7 @@ const PlaceSpotUI = (props: PlaceSpotParams) => {
|
|
|
236
236
|
<View style={{ alignItems: 'flex-start' }}>
|
|
237
237
|
<OButton
|
|
238
238
|
onClick={() => onChangeSpot()}
|
|
239
|
-
|
|
240
|
-
borderColor={theme.colors.primary}
|
|
241
|
-
textStyle={{ color: 'white', fontSize: 12 }}
|
|
239
|
+
textStyle={{ fontSize: 12 }}
|
|
242
240
|
imgRightSrc={null}
|
|
243
241
|
text={t('UPDATE_SPOT_NUMBER', 'Update')}
|
|
244
242
|
isDisabled={(!spotNumber && !Object.values(vehicle).every(e => e))}
|
|
@@ -27,7 +27,7 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
|
|
|
27
27
|
|
|
28
28
|
const [, t] = useLanguage();
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const pastOrders = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<View style={{ marginBottom: 30 }}>
|
|
@@ -49,7 +49,6 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
|
|
|
49
49
|
onClick={loadMoreOrders}
|
|
50
50
|
text={t('LOAD_MORE_ORDERS', 'Load more orders')}
|
|
51
51
|
imgRightSrc={null}
|
|
52
|
-
textStyle={{ color: theme.colors.white }}
|
|
53
52
|
style={{ borderRadius: 7.6, shadowOpacity: 0, marginTop: 20 }}
|
|
54
53
|
/>
|
|
55
54
|
</WrappButton>
|
|
@@ -43,9 +43,9 @@ export const ActionButton = (props: any) => {
|
|
|
43
43
|
style={{
|
|
44
44
|
width: isHaveWeight ? '100%' : ((isSoldOut || maxProductQuantity <= 0) ? '60%' : '40%'),
|
|
45
45
|
}}>
|
|
46
|
-
{(
|
|
46
|
+
{(productCart &&
|
|
47
47
|
auth &&
|
|
48
|
-
(orderState.options?.address_id || isAllowUnaddressOrderType)
|
|
48
|
+
((orderState.options?.address_id || isAllowUnaddressOrderType) || (isSoldOut || maxProductQuantity <= 0))) && (
|
|
49
49
|
<OButton
|
|
50
50
|
onClick={() => handleSaveProduct()}
|
|
51
51
|
imgRightSrc=""
|
|
@@ -57,15 +57,11 @@ export const ActionButton = (props: any) => {
|
|
|
57
57
|
? t('UPDATE', 'Update')
|
|
58
58
|
: t('ADD', 'Add')
|
|
59
59
|
}`}
|
|
60
|
-
isDisabled={
|
|
60
|
+
isDisabled={buttonColor}
|
|
61
61
|
textStyle={{
|
|
62
|
-
color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
|
|
63
62
|
fontSize: orderState.loading || editMode ? 10 : 14
|
|
64
63
|
}}
|
|
65
|
-
bgColor={buttonColor ? theme.colors.lightGray : theme.colors.primary}
|
|
66
|
-
borderColor={!buttonColor ? theme.colors.white : theme.colors.primary}
|
|
67
64
|
style={{
|
|
68
|
-
opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
|
|
69
65
|
borderRadius: 7.6,
|
|
70
66
|
height: 44,
|
|
71
67
|
shadowOpacity: 0,
|
|
@@ -84,7 +80,7 @@ export const ActionButton = (props: any) => {
|
|
|
84
80
|
textStyle={{ fontSize: 10 }}
|
|
85
81
|
/>
|
|
86
82
|
) : (
|
|
87
|
-
<OButton onClick={navigation.navigate('AddressList')} />
|
|
83
|
+
<OButton onClick={() => navigation.navigate('AddressList')} />
|
|
88
84
|
))}
|
|
89
85
|
{!auth && (
|
|
90
86
|
<OButton
|
|
@@ -96,13 +92,12 @@ export const ActionButton = (props: any) => {
|
|
|
96
92
|
: t('LOGIN_SIGNUP', 'Login / Sign Up')
|
|
97
93
|
}
|
|
98
94
|
imgRightSrc=""
|
|
99
|
-
textStyle={{
|
|
95
|
+
textStyle={{ fontSize: 13, textAlign: 'center' }}
|
|
100
96
|
style={{
|
|
101
97
|
height: 42,
|
|
102
|
-
borderColor: theme.colors.primary,
|
|
103
|
-
backgroundColor: theme.colors.white,
|
|
104
98
|
paddingLeft: 0,
|
|
105
|
-
paddingRight: 0
|
|
99
|
+
paddingRight: 0,
|
|
100
|
+
borderRadius: 7.6
|
|
106
101
|
}}
|
|
107
102
|
/>
|
|
108
103
|
)}
|
|
@@ -88,6 +88,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
88
88
|
const [events] = useEvent()
|
|
89
89
|
const commentRef = useRef()
|
|
90
90
|
const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
|
|
91
|
+
const hideProductDummyLogo = theme?.business_view?.components?.products?.components?.product?.components?.dummy?.hidden
|
|
91
92
|
|
|
92
93
|
const styles = StyleSheet.create({
|
|
93
94
|
mainContainer: {
|
|
@@ -487,114 +488,118 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
487
488
|
</View>
|
|
488
489
|
) : (
|
|
489
490
|
<>
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
nextButton={
|
|
508
|
-
<View style={styles.swiperButton}>
|
|
509
|
-
<IconAntDesign
|
|
510
|
-
name="caretright"
|
|
511
|
-
color={theme.colors.white}
|
|
512
|
-
size={13}
|
|
513
|
-
// style={styles.starIcon}
|
|
514
|
-
/>
|
|
515
|
-
</View>
|
|
516
|
-
}
|
|
517
|
-
>
|
|
518
|
-
{gallery && gallery?.length > 0 && gallery.map((img : any, i: number) => (
|
|
519
|
-
<View
|
|
520
|
-
style={styles.slide1}
|
|
521
|
-
key={i}
|
|
522
|
-
>
|
|
523
|
-
{(String(img).includes('http') || typeof img === 'number') ? (
|
|
524
|
-
<FastImage
|
|
525
|
-
style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1, aspectRatio: 16 / 9 }}
|
|
526
|
-
source={typeof img !== 'number' ? {
|
|
527
|
-
uri: optimizeImage(img, 'h_1024,c_limit'),
|
|
528
|
-
priority: FastImage.priority.normal,
|
|
529
|
-
} : img}
|
|
530
|
-
/>
|
|
531
|
-
) : (
|
|
532
|
-
<>
|
|
533
|
-
<YoutubePlayer
|
|
534
|
-
height={'100%'}
|
|
535
|
-
width={'100%'}
|
|
536
|
-
play={playing}
|
|
537
|
-
videoId={img}
|
|
538
|
-
onChangeState={onStateChange}
|
|
491
|
+
{(product?.images || !hideProductDummyLogo) && (
|
|
492
|
+
<>
|
|
493
|
+
<Swiper
|
|
494
|
+
loop={false}
|
|
495
|
+
ref={swiperRef}
|
|
496
|
+
showsButtons={true}
|
|
497
|
+
style={styles.mainSwiper}
|
|
498
|
+
showsPagination={false}
|
|
499
|
+
onIndexChanged={(index : any) => handleChangeMainIndex(index)}
|
|
500
|
+
prevButton={
|
|
501
|
+
<View style={styles.swiperButton}>
|
|
502
|
+
<IconAntDesign
|
|
503
|
+
name="caretleft"
|
|
504
|
+
color={theme.colors.white}
|
|
505
|
+
size={13}
|
|
506
|
+
// style={styles.starIcon}
|
|
539
507
|
/>
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
paddingHorizontal: 20,
|
|
550
|
-
paddingVertical: 15
|
|
551
|
-
}}
|
|
552
|
-
>
|
|
553
|
-
{gallery?.length > 1 && gallery.map((img: any, index: number) => (
|
|
554
|
-
<TouchableOpacity
|
|
555
|
-
key={index}
|
|
556
|
-
onPress={() => handleClickThumb(index)}
|
|
557
|
-
>
|
|
558
|
-
<View
|
|
559
|
-
style={{
|
|
560
|
-
height: 56,
|
|
561
|
-
borderRadius: 8,
|
|
562
|
-
margin: 8,
|
|
563
|
-
opacity: index === thumbsSwiper ? 1 : 0.8
|
|
564
|
-
}}
|
|
565
|
-
>
|
|
566
|
-
{String(img).includes('http') ? (
|
|
567
|
-
<OIcon
|
|
568
|
-
url={img}
|
|
569
|
-
style={{
|
|
570
|
-
borderColor: theme.colors.lightGray,
|
|
571
|
-
borderRadius: 8,
|
|
572
|
-
minHeight: '100%',
|
|
573
|
-
opacity: isSoldOut ? 0.5 : 1
|
|
574
|
-
}}
|
|
575
|
-
width={56}
|
|
576
|
-
height={56}
|
|
577
|
-
cover
|
|
508
|
+
</View>
|
|
509
|
+
}
|
|
510
|
+
nextButton={
|
|
511
|
+
<View style={styles.swiperButton}>
|
|
512
|
+
<IconAntDesign
|
|
513
|
+
name="caretright"
|
|
514
|
+
color={theme.colors.white}
|
|
515
|
+
size={13}
|
|
516
|
+
// style={styles.starIcon}
|
|
578
517
|
/>
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
518
|
+
</View>
|
|
519
|
+
}
|
|
520
|
+
>
|
|
521
|
+
{gallery && gallery?.length > 0 && gallery.map((img : any, i: number) => (
|
|
522
|
+
<View
|
|
523
|
+
style={styles.slide1}
|
|
524
|
+
key={i}
|
|
525
|
+
>
|
|
526
|
+
{(String(img).includes('http') || typeof img === 'number') ? (
|
|
527
|
+
<FastImage
|
|
528
|
+
style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1, aspectRatio: 16 / 9 }}
|
|
529
|
+
source={typeof img !== 'number' ? {
|
|
530
|
+
uri: optimizeImage(img, 'h_1024,c_limit'),
|
|
531
|
+
priority: FastImage.priority.normal,
|
|
532
|
+
} : img}
|
|
533
|
+
/>
|
|
534
|
+
) : (
|
|
535
|
+
<>
|
|
536
|
+
<YoutubePlayer
|
|
537
|
+
height={'100%'}
|
|
538
|
+
width={'100%'}
|
|
539
|
+
play={playing}
|
|
540
|
+
videoId={img}
|
|
541
|
+
onChangeState={onStateChange}
|
|
542
|
+
/>
|
|
543
|
+
<Button title={playing ? "pause" : "play"} onPress={togglePlaying} />
|
|
544
|
+
</>
|
|
545
|
+
)}
|
|
546
|
+
</View>
|
|
547
|
+
))}
|
|
548
|
+
</Swiper>
|
|
549
|
+
<ScrollView
|
|
550
|
+
horizontal
|
|
551
|
+
contentContainerStyle={{
|
|
552
|
+
paddingHorizontal: 20,
|
|
553
|
+
paddingVertical: 15
|
|
554
|
+
}}
|
|
555
|
+
>
|
|
556
|
+
{gallery?.length > 1 && gallery.map((img: any, index: number) => (
|
|
557
|
+
<TouchableOpacity
|
|
558
|
+
key={index}
|
|
559
|
+
onPress={() => handleClickThumb(index)}
|
|
560
|
+
>
|
|
561
|
+
<View
|
|
582
562
|
style={{
|
|
583
|
-
|
|
563
|
+
height: 56,
|
|
584
564
|
borderRadius: 8,
|
|
585
|
-
|
|
586
|
-
opacity:
|
|
565
|
+
margin: 8,
|
|
566
|
+
opacity: index === thumbsSwiper ? 1 : 0.8
|
|
587
567
|
}}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
568
|
+
>
|
|
569
|
+
{String(img).includes('http') ? (
|
|
570
|
+
<OIcon
|
|
571
|
+
url={img}
|
|
572
|
+
style={{
|
|
573
|
+
borderColor: theme.colors.lightGray,
|
|
574
|
+
borderRadius: 8,
|
|
575
|
+
minHeight: '100%',
|
|
576
|
+
opacity: isSoldOut ? 0.5 : 1
|
|
577
|
+
}}
|
|
578
|
+
width={56}
|
|
579
|
+
height={56}
|
|
580
|
+
cover
|
|
581
|
+
/>
|
|
582
|
+
) : (
|
|
583
|
+
<OIcon
|
|
584
|
+
url={'https://img.youtube.com/vi/' + img + '/0.jpg'}
|
|
585
|
+
style={{
|
|
586
|
+
borderColor: theme.colors.lightGray,
|
|
587
|
+
borderRadius: 8,
|
|
588
|
+
minHeight: '100%',
|
|
589
|
+
opacity: isSoldOut ? 0.5 : 1
|
|
590
|
+
}}
|
|
591
|
+
width={56}
|
|
592
|
+
height={56}
|
|
593
|
+
cover
|
|
594
|
+
/>
|
|
595
|
+
)}
|
|
596
|
+
</View>
|
|
597
|
+
</TouchableOpacity>
|
|
595
598
|
|
|
596
|
-
|
|
597
|
-
|
|
599
|
+
))}
|
|
600
|
+
</ScrollView>
|
|
601
|
+
</>
|
|
602
|
+
)}
|
|
598
603
|
</>
|
|
599
604
|
)}
|
|
600
605
|
</WrapHeader>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import { View, Animated, StyleSheet, TouchableOpacity } from 'react-native'
|
|
3
|
-
import { useUtils, useLanguage, useOrder } from 'ordering-components/native'
|
|
3
|
+
import { useUtils, useLanguage, useOrder, ProductItemAccordion as ProductItemAccordionController } from 'ordering-components/native'
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
6
6
|
import RNPickerSelect from 'react-native-picker-select'
|
|
@@ -24,7 +24,7 @@ import { OIcon, OText, OAlert, OModal } from '../shared'
|
|
|
24
24
|
|
|
25
25
|
import { ProductItemAccordionParams } from '../../types'
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const ProductItemAccordionUI = (props: ProductItemAccordionParams) => {
|
|
28
28
|
|
|
29
29
|
const {
|
|
30
30
|
isDisabledEdit,
|
|
@@ -36,6 +36,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
36
36
|
onDeleteProduct,
|
|
37
37
|
onEditProduct,
|
|
38
38
|
isFromCheckout,
|
|
39
|
+
productInfo
|
|
39
40
|
} = props
|
|
40
41
|
|
|
41
42
|
const theme = useTheme();
|
|
@@ -43,8 +44,17 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
43
44
|
? theme?.checkout?.components?.cart?.components?.product?.components?.image?.hidden
|
|
44
45
|
: theme?.confirmation?.components?.cart?.components?.products?.components?.photo?.hidden
|
|
45
46
|
|
|
47
|
+
const hideProductDummyLogo = theme?.business_view?.components?.products?.components?.product?.components?.dummy?.hidden
|
|
46
48
|
const hideProductCommentHide = isFromCheckout && theme?.checkout?.components?.cart?.components?.product?.components?.comments?.hidden
|
|
47
49
|
|
|
50
|
+
const styles = StyleSheet.create({
|
|
51
|
+
productImage: {
|
|
52
|
+
borderRadius: 7.6,
|
|
53
|
+
width: 48,
|
|
54
|
+
height: 48
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
48
58
|
const pickerStyle = StyleSheet.create({
|
|
49
59
|
inputAndroid: {
|
|
50
60
|
width: 45,
|
|
@@ -90,24 +100,6 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
90
100
|
const [isServiceOpen, setIsServiceOpen] = useState(false)
|
|
91
101
|
const [productQuantityState, setProductQuantityState] = useState<any>(product.quantity.toString())
|
|
92
102
|
|
|
93
|
-
const productInfo = () => {
|
|
94
|
-
if (isCartProduct) {
|
|
95
|
-
const ingredients = JSON.parse(JSON.stringify(Object.values(product.ingredients ?? {})))
|
|
96
|
-
let options = JSON.parse(JSON.stringify(Object.values(product.options ?? {})))
|
|
97
|
-
|
|
98
|
-
options = options.map((option: any) => {
|
|
99
|
-
option.suboptions = Object.values(option.suboptions ?? {})
|
|
100
|
-
return option
|
|
101
|
-
})
|
|
102
|
-
return {
|
|
103
|
-
...productInfo,
|
|
104
|
-
ingredients,
|
|
105
|
-
options
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return product
|
|
109
|
-
}
|
|
110
|
-
|
|
111
103
|
const handleEditProduct = (curProduct: any) => {
|
|
112
104
|
if (!curProduct?.calendar_event) {
|
|
113
105
|
onEditProduct && onEditProduct(curProduct)
|
|
@@ -153,13 +145,13 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
153
145
|
isValid={product?.valid ?? true}
|
|
154
146
|
onPress={
|
|
155
147
|
(!product?.valid_menu && isCartProduct) ||
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
!(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment)
|
|
149
|
+
? null : () => setActiveState(!isActive)
|
|
158
150
|
}
|
|
159
151
|
>
|
|
160
152
|
<View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>
|
|
161
153
|
<ContentInfo>
|
|
162
|
-
{(product?.images || theme?.images?.dummies?.product) && !hideProductImage && (
|
|
154
|
+
{(product?.images || (!hideProductDummyLogo && theme?.images?.dummies?.product)) && !hideProductImage && (
|
|
163
155
|
<ProductImage>
|
|
164
156
|
{isFromCheckout ? (
|
|
165
157
|
product?.images ? (
|
|
@@ -245,7 +237,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
245
237
|
<View style={{ display: 'flex', flexDirection: 'column', flex: 1, alignItems: 'flex-end', maxWidth: 100 }}>
|
|
246
238
|
<View style={{ flexDirection: 'row' }}>
|
|
247
239
|
<OText size={12} lineHeight={18} weight={'400'}>{parsePrice(product.total || product.price)}</OText>
|
|
248
|
-
{(productInfo
|
|
240
|
+
{(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment) && (
|
|
249
241
|
<MaterialCommunityIcon name='chevron-down' size={18} />
|
|
250
242
|
)}
|
|
251
243
|
</View>
|
|
@@ -289,20 +281,20 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
289
281
|
<View style={{ display: isActive ? 'flex' : 'none', paddingStart: isFromCheckout ? 100 : 40, marginTop: isFromCheckout ? -80 : -30 }}>
|
|
290
282
|
<Animated.View>
|
|
291
283
|
<AccordionContent>
|
|
292
|
-
{productInfo
|
|
284
|
+
{productInfo.ingredients.length > 0 && productInfo.ingredients.some((ingredient: any) => !ingredient.selected) && (
|
|
293
285
|
<ProductOptionsList>
|
|
294
286
|
<OText size={10} color={theme.colors.textSecondary}>{t('INGREDIENTS', 'Ingredients')}</OText>
|
|
295
|
-
{productInfo
|
|
287
|
+
{productInfo.ingredients.map((ingredient: any, i) => !ingredient.selected && (
|
|
296
288
|
<OText size={10} color={theme.colors.textThird} key={ingredient.id + i} style={{ marginLeft: 10 }}>{t('NO', 'No')} {ingredient.name}</OText>
|
|
297
289
|
))}
|
|
298
290
|
</ProductOptionsList>
|
|
299
291
|
)}
|
|
300
|
-
{productInfo
|
|
292
|
+
{productInfo.options.length > 0 && (
|
|
301
293
|
<ProductOptionsList>
|
|
302
|
-
{productInfo
|
|
294
|
+
{productInfo.options.map((option: any) => (
|
|
303
295
|
<ProductOption key={option.id}>
|
|
304
296
|
<OText size={10} color={theme.colors.textSecondary}>{option.name}</OText>
|
|
305
|
-
{option.suboptions.map((suboption: any) => (
|
|
297
|
+
{option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map((suboption: any) => (
|
|
306
298
|
<ProductSubOption key={suboption.id}>
|
|
307
299
|
<OText size={10} color={theme.colors.textThird}>
|
|
308
300
|
{getFormattedSubOptionName({
|
|
@@ -349,13 +341,13 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
349
341
|
)
|
|
350
342
|
}
|
|
351
343
|
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
height: 48
|
|
357
|
-
},
|
|
358
|
-
test: {
|
|
359
|
-
overflow: 'hidden',
|
|
344
|
+
export const ProductItemAccordion = (props: any) => {
|
|
345
|
+
const productItemAccordionProps = {
|
|
346
|
+
...props,
|
|
347
|
+
UIComponent: ProductItemAccordionUI
|
|
360
348
|
}
|
|
361
|
-
|
|
349
|
+
|
|
350
|
+
return (
|
|
351
|
+
<ProductItemAccordionController {...productItemAccordionProps} />
|
|
352
|
+
)
|
|
353
|
+
}
|