ordering-ui-react-native 0.22.76 → 0.22.77-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 +5 -7
- 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/src/providers/AlertProvider.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -3
- 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 +13 -4
- package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
- package/themes/business/src/components/MapView/index.tsx +68 -142
- package/themes/business/src/components/NewOrderNotification/index.tsx +38 -54
- package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
- package/themes/business/src/components/OrderDetails/Delivery.tsx +111 -42
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +146 -36
- 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 +271 -176
- package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
- package/themes/business/src/components/OrdersOption/index.tsx +207 -144
- 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 +20 -8
- 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 +15 -16
- 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/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 +26 -4
- package/themes/business/src/utils/index.tsx +26 -2
- 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 +223 -219
- package/themes/original/src/components/AddressForm/index.tsx +76 -17
- package/themes/original/src/components/AppleLogin/index.tsx +3 -4
- package/themes/original/src/components/BusinessController/index.tsx +4 -2
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +1 -1
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +102 -90
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
- package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
- package/themes/original/src/components/BusinessPreorder/index.tsx +30 -17
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +72 -69
- package/themes/original/src/components/BusinessProductsList/index.tsx +4 -5
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +5 -4
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +1 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +2 -1
- package/themes/original/src/components/Cart/index.tsx +42 -12
- package/themes/original/src/components/Checkout/index.tsx +126 -98
- package/themes/original/src/components/FloatingButton/index.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +2 -1
- package/themes/original/src/components/GoogleMap/index.tsx +3 -2
- package/themes/original/src/components/Help/functions.tsx +76 -0
- package/themes/original/src/components/Help/index.tsx +74 -29
- package/themes/original/src/components/Help/styles.tsx +4 -1
- package/themes/original/src/components/HelpOptions/index.tsx +53 -0
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +36 -11
- package/themes/original/src/components/LastOrder/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/index.tsx +883 -852
- package/themes/original/src/components/MessageListing/index.tsx +1 -1
- package/themes/original/src/components/Messages/index.tsx +562 -555
- package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
- package/themes/original/src/components/MomentOption/index.tsx +141 -61
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/MomentSelector/index.tsx +5 -2
- package/themes/original/src/components/MultiCheckout/index.tsx +78 -33
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +2 -2
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -2
- package/themes/original/src/components/NavBar/index.tsx +6 -2
- package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
- package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
- package/themes/original/src/components/OrderDetails/index.tsx +44 -20
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderProgress/index.tsx +5 -4
- package/themes/original/src/components/OrderSummary/index.tsx +32 -11
- package/themes/original/src/components/OrderTypeSelector/index.tsx +120 -120
- package/themes/original/src/components/OrdersOption/index.tsx +325 -325
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -0
- package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
- package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
- package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
- package/themes/original/src/components/ServiceForm/index.tsx +2 -2
- package/themes/original/src/components/SignupForm/index.tsx +1010 -971
- package/themes/original/src/components/SingleOrderCard/index.tsx +8 -5
- package/themes/original/src/components/SingleProductCard/index.tsx +2 -1
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +7 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
- package/themes/original/src/components/TaxInformation/index.tsx +3 -2
- package/themes/original/src/components/UserDetails/index.tsx +17 -16
- package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
- package/themes/original/src/components/UserVerification/index.tsx +70 -23
- package/themes/original/src/components/VerifyPhone/index.tsx +1 -1
- package/themes/original/src/components/shared/OInput.tsx +97 -97
- package/themes/original/src/components/shared/OModal.tsx +7 -2
- package/themes/original/src/providers/AlertProvider.tsx +1 -1
- package/themes/original/src/types/index.tsx +700 -695
- package/themes/original/src/utils/index.tsx +50 -34
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
- package/themes/original/src/components/HelpGuide/index.tsx +0 -68
- package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
- package/themes/original/src/components/HelpOrder/index.tsx +0 -71
- package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
|
@@ -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
|
}
|
|
@@ -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();
|
|
@@ -46,6 +47,14 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
46
47
|
const hideProductDummyLogo = theme?.business_view?.components?.products?.components?.product?.components?.dummy?.hidden
|
|
47
48
|
const hideProductCommentHide = isFromCheckout && theme?.checkout?.components?.cart?.components?.product?.components?.comments?.hidden
|
|
48
49
|
|
|
50
|
+
const styles = StyleSheet.create({
|
|
51
|
+
productImage: {
|
|
52
|
+
borderRadius: 7.6,
|
|
53
|
+
width: 48,
|
|
54
|
+
height: 48
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
49
58
|
const pickerStyle = StyleSheet.create({
|
|
50
59
|
inputAndroid: {
|
|
51
60
|
width: 45,
|
|
@@ -91,24 +100,6 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
91
100
|
const [isServiceOpen, setIsServiceOpen] = useState(false)
|
|
92
101
|
const [productQuantityState, setProductQuantityState] = useState<any>(product.quantity.toString())
|
|
93
102
|
|
|
94
|
-
const productInfo = () => {
|
|
95
|
-
if (isCartProduct) {
|
|
96
|
-
const ingredients = JSON.parse(JSON.stringify(Object.values(product.ingredients ?? {})))
|
|
97
|
-
let options = JSON.parse(JSON.stringify(Object.values(product.options ?? {})))
|
|
98
|
-
|
|
99
|
-
options = options.map((option: any) => {
|
|
100
|
-
option.suboptions = Object.values(option.suboptions ?? {})
|
|
101
|
-
return option
|
|
102
|
-
})
|
|
103
|
-
return {
|
|
104
|
-
...productInfo,
|
|
105
|
-
ingredients,
|
|
106
|
-
options
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return product
|
|
110
|
-
}
|
|
111
|
-
|
|
112
103
|
const handleEditProduct = (curProduct: any) => {
|
|
113
104
|
if (!curProduct?.calendar_event) {
|
|
114
105
|
onEditProduct && onEditProduct(curProduct)
|
|
@@ -154,8 +145,8 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
154
145
|
isValid={product?.valid ?? true}
|
|
155
146
|
onPress={
|
|
156
147
|
(!product?.valid_menu && isCartProduct) ||
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
!(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment)
|
|
149
|
+
? null : () => setActiveState(!isActive)
|
|
159
150
|
}
|
|
160
151
|
>
|
|
161
152
|
<View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>
|
|
@@ -246,7 +237,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
246
237
|
<View style={{ display: 'flex', flexDirection: 'column', flex: 1, alignItems: 'flex-end', maxWidth: 100 }}>
|
|
247
238
|
<View style={{ flexDirection: 'row' }}>
|
|
248
239
|
<OText size={12} lineHeight={18} weight={'400'}>{parsePrice(product.total || product.price)}</OText>
|
|
249
|
-
{(productInfo
|
|
240
|
+
{(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment) && (
|
|
250
241
|
<MaterialCommunityIcon name='chevron-down' size={18} />
|
|
251
242
|
)}
|
|
252
243
|
</View>
|
|
@@ -290,20 +281,20 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
290
281
|
<View style={{ display: isActive ? 'flex' : 'none', paddingStart: isFromCheckout ? 100 : 40, marginTop: isFromCheckout ? -80 : -30 }}>
|
|
291
282
|
<Animated.View>
|
|
292
283
|
<AccordionContent>
|
|
293
|
-
{productInfo
|
|
284
|
+
{productInfo.ingredients.length > 0 && productInfo.ingredients.some((ingredient: any) => !ingredient.selected) && (
|
|
294
285
|
<ProductOptionsList>
|
|
295
286
|
<OText size={10} color={theme.colors.textSecondary}>{t('INGREDIENTS', 'Ingredients')}</OText>
|
|
296
|
-
{productInfo
|
|
287
|
+
{productInfo.ingredients.map((ingredient: any, i) => !ingredient.selected && (
|
|
297
288
|
<OText size={10} color={theme.colors.textThird} key={ingredient.id + i} style={{ marginLeft: 10 }}>{t('NO', 'No')} {ingredient.name}</OText>
|
|
298
289
|
))}
|
|
299
290
|
</ProductOptionsList>
|
|
300
291
|
)}
|
|
301
|
-
{productInfo
|
|
292
|
+
{productInfo.options.length > 0 && (
|
|
302
293
|
<ProductOptionsList>
|
|
303
|
-
{productInfo
|
|
294
|
+
{productInfo.options.map((option: any) => (
|
|
304
295
|
<ProductOption key={option.id}>
|
|
305
296
|
<OText size={10} color={theme.colors.textSecondary}>{option.name}</OText>
|
|
306
|
-
{option.suboptions.map((suboption: any) => (
|
|
297
|
+
{option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map((suboption: any) => (
|
|
307
298
|
<ProductSubOption key={suboption.id}>
|
|
308
299
|
<OText size={10} color={theme.colors.textThird}>
|
|
309
300
|
{getFormattedSubOptionName({
|
|
@@ -350,13 +341,13 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
350
341
|
)
|
|
351
342
|
}
|
|
352
343
|
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
height: 48
|
|
358
|
-
},
|
|
359
|
-
test: {
|
|
360
|
-
overflow: 'hidden',
|
|
344
|
+
export const ProductItemAccordion = (props: any) => {
|
|
345
|
+
const productItemAccordionProps = {
|
|
346
|
+
...props,
|
|
347
|
+
UIComponent: ProductItemAccordionUI
|
|
361
348
|
}
|
|
362
|
-
|
|
349
|
+
|
|
350
|
+
return (
|
|
351
|
+
<ProductItemAccordionController {...productItemAccordionProps} />
|
|
352
|
+
)
|
|
353
|
+
}
|
|
@@ -36,10 +36,16 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
36
36
|
setIsScrollAvailable,
|
|
37
37
|
image,
|
|
38
38
|
enableIntersection,
|
|
39
|
-
|
|
39
|
+
usePizzaValidation,
|
|
40
|
+
pizzaState
|
|
40
41
|
} = props
|
|
41
42
|
|
|
42
|
-
const disableIncrement =
|
|
43
|
+
const disableIncrement =
|
|
44
|
+
option?.with_half_option
|
|
45
|
+
? pizzaState?.[`option:${option?.id}`]?.value === option?.max
|
|
46
|
+
: option?.limit_suboptions_by_max
|
|
47
|
+
? (balance === option?.max || state.quantity === suboption.max)
|
|
48
|
+
: state.quantity === suboption?.max || (!state.selected && balance === option?.max)
|
|
43
49
|
const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
|
|
44
50
|
|
|
45
51
|
const theme = useTheme();
|
|
@@ -66,8 +72,9 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
66
72
|
const handleSuboptionClick = () => {
|
|
67
73
|
toggleSelect()
|
|
68
74
|
setIsDirty(true)
|
|
75
|
+
const minMaxValidation = option?.with_half_option ? usePizzaValidation : (balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1))
|
|
69
76
|
|
|
70
|
-
if (
|
|
77
|
+
if (!state.selected && minMaxValidation) {
|
|
71
78
|
setShowMessage(true)
|
|
72
79
|
}
|
|
73
80
|
}
|
|
@@ -87,13 +94,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
87
94
|
if (!(balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1))) {
|
|
88
95
|
setShowMessage(false)
|
|
89
96
|
}
|
|
90
|
-
}, [balance])
|
|
91
|
-
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if (!suboption?.preselected || !option?.respect_to) return
|
|
94
|
-
const newState = { ...state, selected: suboption?.preselected, quantity: state.selected ? 0 : 1 }
|
|
95
|
-
onChange(newState, suboption, option)
|
|
96
|
-
}, [suboption, option])
|
|
97
|
+
}, [balance, pizzaState?.[`option:${option?.id}`]?.value])
|
|
97
98
|
|
|
98
99
|
return (
|
|
99
100
|
<InView onChange={(inView: boolean) => handleChangeInterSection(inView)} triggerOnce={true}>
|
|
@@ -129,7 +130,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
129
130
|
{suboption?.name}
|
|
130
131
|
</OText>
|
|
131
132
|
</IconControl>
|
|
132
|
-
{option?.allow_suboption_quantity && state?.selected && (
|
|
133
|
+
{!(option?.max === 1 && option?.min === 1) && option?.allow_suboption_quantity && state?.selected && (
|
|
133
134
|
<QuantityControl>
|
|
134
135
|
<>
|
|
135
136
|
<Checkbox disabled={disabled || state.quantity === 0} onPress={decrement}>
|
|
@@ -142,11 +143,11 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
142
143
|
<OText size={12}>
|
|
143
144
|
{state.quantity}
|
|
144
145
|
</OText>
|
|
145
|
-
<Checkbox disabled={disabled || disableIncrement} onPress={increment}>
|
|
146
|
+
<Checkbox disabled={disabled || disableIncrement || usePizzaValidation} onPress={increment}>
|
|
146
147
|
<IconAntDesign
|
|
147
148
|
name='pluscircleo'
|
|
148
149
|
size={iconsSize}
|
|
149
|
-
color={disableIncrement || disabled ? theme.colors.disabled : theme.colors.primary}
|
|
150
|
+
color={disableIncrement || disabled || usePizzaValidation ? theme.colors.disabled : theme.colors.primary}
|
|
150
151
|
/>
|
|
151
152
|
</Checkbox>
|
|
152
153
|
</>
|
|
@@ -164,7 +165,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
164
165
|
style={styles.inverse}
|
|
165
166
|
/>
|
|
166
167
|
</Circle>
|
|
167
|
-
<Circle disabled={disabled} onPress={() => changePosition('whole')}>
|
|
168
|
+
<Circle disabled={disabled || (pizzaState?.[`option:${option?.id}`]?.value === option?.max)} onPress={() => changePosition('whole')}>
|
|
168
169
|
<OIcon
|
|
169
170
|
src={theme.images.general.half_f}
|
|
170
171
|
color={state.selected && state.position === 'whole' ? theme.colors.primary : '#cbcbcb'}
|
|
@@ -143,7 +143,7 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
143
143
|
const valid = busyTimes.some(item => {
|
|
144
144
|
return (moment.utc(item?.start).local().valueOf() <= moment(selectedMoment).valueOf() &&
|
|
145
145
|
moment(selectedMoment).valueOf() < moment.utc(item?.end).local().valueOf()) ||
|
|
146
|
-
(moment.utc(item?.start).local().valueOf() < moment(selectedMoment).
|
|
146
|
+
(moment.utc(item?.start).local().valueOf() < moment(selectedMoment).valueOf() &&
|
|
147
147
|
moment(selectedMoment).add(duration, 'minutes').valueOf() < moment.utc(item?.end).local().valueOf())
|
|
148
148
|
})
|
|
149
149
|
return valid
|
|
@@ -259,7 +259,7 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
useEffect(() => {
|
|
262
|
-
if (selectDate === null || currentProfessional
|
|
262
|
+
if (selectDate === null || !currentProfessional?.schedule) return
|
|
263
263
|
const _times = getTimes(selectDate, currentProfessional)
|
|
264
264
|
setTimeList(_times)
|
|
265
265
|
}, [selectDate, currentProfessional])
|