ordering-ui-react-native 0.16.94-release → 0.16.95-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 +1 -1
- package/src/utils/index.tsx +5 -0
- package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +2 -2
- package/themes/original/src/components/AddressDetails/index.tsx +19 -3
- package/themes/original/src/components/AnalyticsSegment/index.tsx +3 -3
- package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +1 -1
- package/themes/original/src/components/Checkout/index.tsx +1 -1
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +26 -4
- package/themes/original/src/components/MultiCheckout/index.tsx +22 -3
package/package.json
CHANGED
package/src/utils/index.tsx
CHANGED
|
@@ -154,6 +154,11 @@ export const transformCountryCode = (countryCode : number) => {
|
|
|
154
154
|
return code?.countryCode
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
export const verifyCountryCode = (countryCode : string) => {
|
|
158
|
+
const code = CODES.find((code : any) => code.countryCode === (countryCode || '').toUpperCase())
|
|
159
|
+
return code?.countryCode
|
|
160
|
+
}
|
|
161
|
+
|
|
157
162
|
/**
|
|
158
163
|
* Function to check if a number is decimal or not
|
|
159
164
|
* @param {*} value number to check if decimal or not
|
|
@@ -7,7 +7,7 @@ import { Wrapper } from './styles'
|
|
|
7
7
|
|
|
8
8
|
import { PhoneInputParams } from '../../../../../src/types';
|
|
9
9
|
import { OText } from '../shared';
|
|
10
|
-
import {transformCountryCode} from '../../../../../src/utils'
|
|
10
|
+
import { transformCountryCode, verifyCountryCode } from '../../../../../src/utils'
|
|
11
11
|
import {I18nManager} from 'react-native'
|
|
12
12
|
import { useTheme } from 'styled-components/native';
|
|
13
13
|
|
|
@@ -89,7 +89,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
89
89
|
containerStyle={{ width: '100%' }}
|
|
90
90
|
ref={phoneInput}
|
|
91
91
|
defaultValue={userphoneNumber || defaultValue}
|
|
92
|
-
defaultCode={defaultCode ? transformCountryCode(defaultCode) : configs?.default_country_code?.value}
|
|
92
|
+
defaultCode={defaultCode ? transformCountryCode(defaultCode) : verifyCountryCode(configs?.default_country_code?.value)}
|
|
93
93
|
onChangeFormattedText={(text : string) => handleChangeNumber(text)}
|
|
94
94
|
withDarkTheme
|
|
95
95
|
textInputStyle={{textAlign: I18nManager.isRTL ? 'right' : 'left'}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import FastImage from 'react-native-fast-image'
|
|
3
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
4
|
import {
|
|
4
5
|
AddressDetails as AddressDetailsController,
|
|
5
6
|
useOrder,
|
|
@@ -21,6 +22,14 @@ const AddressDetailsUI = (props: any) => {
|
|
|
21
22
|
const [, t] = useLanguage();
|
|
22
23
|
const { width } = useWindowDimensions();
|
|
23
24
|
|
|
25
|
+
const styles = StyleSheet.create({
|
|
26
|
+
productStyle: {
|
|
27
|
+
width: width,
|
|
28
|
+
height: 151,
|
|
29
|
+
marginVertical: 10
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
24
33
|
return (
|
|
25
34
|
<ADContainer>
|
|
26
35
|
<ADHeader>
|
|
@@ -34,10 +43,17 @@ const AddressDetailsUI = (props: any) => {
|
|
|
34
43
|
</OText>
|
|
35
44
|
)}
|
|
36
45
|
</ADHeader>
|
|
37
|
-
{!!apiKey && (
|
|
46
|
+
{!!apiKey && googleMapsUrl && (
|
|
38
47
|
<ADMap
|
|
39
48
|
style={{ marginStart: -40, marginEnd: -40, width: width, flex: 1 }}>
|
|
40
|
-
<
|
|
49
|
+
<FastImage
|
|
50
|
+
style={styles.productStyle}
|
|
51
|
+
source={{
|
|
52
|
+
uri: googleMapsUrl,
|
|
53
|
+
priority: FastImage.priority.normal,
|
|
54
|
+
}}
|
|
55
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
56
|
+
/>
|
|
41
57
|
</ADMap>
|
|
42
58
|
)}
|
|
43
59
|
<ADAddress>
|
|
@@ -18,9 +18,9 @@ export const AnalyticsSegment = (props: any) => {
|
|
|
18
18
|
|
|
19
19
|
const handleProductListViewed = (category: any) => {
|
|
20
20
|
segmentClient.track('Product List Viewed', {
|
|
21
|
-
business_id: category
|
|
22
|
-
category_id: category
|
|
23
|
-
category: category
|
|
21
|
+
business_id: category?.business_id,
|
|
22
|
+
category_id: category?.id,
|
|
23
|
+
category: category?.name,
|
|
24
24
|
products: category?.products
|
|
25
25
|
})
|
|
26
26
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
BusinessReviews as BusinessReviewController,
|
|
4
4
|
useLanguage,
|
|
5
5
|
useOrder,
|
|
6
|
+
useUtils
|
|
6
7
|
} from 'ordering-components/native';
|
|
7
8
|
import { useTheme } from 'styled-components/native';
|
|
8
9
|
import IconAntDesign from 'react-native-vector-icons/AntDesign';
|
|
@@ -30,6 +31,7 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
|
|
|
30
31
|
const theme = useTheme();
|
|
31
32
|
const [searchReview, setSearchReview] = useState('')
|
|
32
33
|
const [orderState] = useOrder();
|
|
34
|
+
const [{ parseDate }] = useUtils()
|
|
33
35
|
|
|
34
36
|
const styles = StyleSheet.create({
|
|
35
37
|
starIcon: {
|
|
@@ -94,7 +96,7 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
|
|
|
94
96
|
const ReviewItem = ({ comment, created_at, total }: any) => (
|
|
95
97
|
<View style={{ marginBottom: 30 }}>
|
|
96
98
|
<OText size={12} color={theme.colors.textSecondary}>
|
|
97
|
-
{
|
|
99
|
+
{parseDate(created_at, { outputFormat: 'MMMM D, YYYY • hh:mm A' })}
|
|
98
100
|
</OText>
|
|
99
101
|
<OText size={12} color={theme.colors.textNormal}>{comment}</OText>
|
|
100
102
|
</View>
|
|
@@ -224,7 +224,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
224
224
|
|
|
225
225
|
useEffect(() => {
|
|
226
226
|
if (!businessesList?.loading) {
|
|
227
|
-
const fb = businessesList.businesses.filter((b) => b
|
|
227
|
+
const fb = businessesList.businesses.filter((b) => b?.featured === true && b?.open);
|
|
228
228
|
const ary = [];
|
|
229
229
|
while (fb.length > 0) {
|
|
230
230
|
ary.push(fb.splice(0, 2));
|
|
@@ -588,7 +588,7 @@ const CheckoutUI = (props: any) => {
|
|
|
588
588
|
) : (
|
|
589
589
|
<AddressDetails
|
|
590
590
|
navigation={navigation}
|
|
591
|
-
location={
|
|
591
|
+
location={options?.address?.location}
|
|
592
592
|
businessLogo={businessDetails?.business?.logo}
|
|
593
593
|
isCartPending={cart?.status === 2}
|
|
594
594
|
uuid={cartUuid}
|
|
@@ -25,6 +25,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
|
25
25
|
businessIds,
|
|
26
26
|
paymethodsAndWallets,
|
|
27
27
|
walletsState,
|
|
28
|
+
walletsPaymethod,
|
|
28
29
|
paymethodSelected,
|
|
29
30
|
handleSelectPaymethod,
|
|
30
31
|
handleSelectWallet,
|
|
@@ -52,6 +53,8 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate, { isTruncable: true })}`
|
|
57
|
+
|
|
55
58
|
const getPayIcon = (method: string) => {
|
|
56
59
|
switch (method) {
|
|
57
60
|
case 'cash':
|
|
@@ -169,13 +172,16 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
|
169
172
|
</>
|
|
170
173
|
) : (
|
|
171
174
|
<>
|
|
172
|
-
{walletsState?.result?.filter((wallet: any) =>
|
|
175
|
+
{walletsState?.result?.filter((wallet: any) =>
|
|
176
|
+
paymethodsAndWallets.wallets.find((item: any) => item.type === wallet.type))
|
|
177
|
+
.map((wallet: any, idx: any) => walletName[wallet.type]?.isActive &&
|
|
178
|
+
(
|
|
173
179
|
<WalletItem
|
|
174
180
|
key={wallet.type}
|
|
175
181
|
isBottomBorder={idx === paymethodsAndWallets.wallets?.length - 1}
|
|
176
|
-
onPress={() => handleSelectWallet(
|
|
182
|
+
onPress={() => handleSelectWallet(!!!walletsPaymethod?.find((walletPay: any) => walletPay.wallet_id === wallet.id)?.id, wallet)}
|
|
177
183
|
>
|
|
178
|
-
{
|
|
184
|
+
{!!walletsPaymethod?.find((walletPay: any) => walletPay.wallet_id === wallet.id)?.id ? (
|
|
179
185
|
<MaterialCommunityIcons
|
|
180
186
|
name="checkbox-marked"
|
|
181
187
|
size={25}
|
|
@@ -189,7 +195,23 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
|
189
195
|
/>
|
|
190
196
|
)}
|
|
191
197
|
<OText size={12} style={{ flex: 1, marginLeft: 15 }}>{walletName[wallet.type]?.name}</OText>
|
|
192
|
-
|
|
198
|
+
{wallet.type === 'cash' && (
|
|
199
|
+
<OText>
|
|
200
|
+
{parsePrice(wallet?.balance, { isTruncable: true })}
|
|
201
|
+
</OText>
|
|
202
|
+
)}
|
|
203
|
+
{wallet.type === 'credit_point' && (
|
|
204
|
+
<OText>
|
|
205
|
+
<OText color={theme.colors.primary} weight='bold'>
|
|
206
|
+
{`${wallet?.balance} ${t('POINTS', 'Points')}`}
|
|
207
|
+
</OText>
|
|
208
|
+
<OText>
|
|
209
|
+
{wallet?.balance > 0
|
|
210
|
+
? creditBalance(wallet)
|
|
211
|
+
: null}
|
|
212
|
+
</OText>
|
|
213
|
+
</OText>
|
|
214
|
+
)}
|
|
193
215
|
</WalletItem>
|
|
194
216
|
))}
|
|
195
217
|
</>
|
|
@@ -63,6 +63,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
63
63
|
loyaltyPlansState,
|
|
64
64
|
totalCartsFee,
|
|
65
65
|
cartGroup,
|
|
66
|
+
walletState,
|
|
66
67
|
onNavigationRedirectReplace
|
|
67
68
|
} = props
|
|
68
69
|
|
|
@@ -86,8 +87,11 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
86
87
|
const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
|
|
87
88
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
88
89
|
const isMultiDriverTips = configs?.checkout_multi_business_enabled?.value === '1'
|
|
89
|
-
const isDisablePlaceOrderButton = !(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) || (paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data)
|
|
90
90
|
const walletCarts = (Object.values(carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && cart?.wallets) || null) || []
|
|
91
|
+
const isDisablePlaceOrderButton = cartGroup?.loading || (!(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) && cartGroup?.result?.balance > 0) ||
|
|
92
|
+
(paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data) ||
|
|
93
|
+
walletCarts.length > 0
|
|
94
|
+
|
|
91
95
|
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
92
96
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
93
97
|
: configs?.driver_tip_options?.value || []
|
|
@@ -171,6 +175,18 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
171
175
|
}
|
|
172
176
|
}, [openCarts])
|
|
173
177
|
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (walletState.error) {
|
|
180
|
+
showToast(ToastType.Error, t(walletState.error, walletState.error?.[0]?.replace(/_/g, ' ')))
|
|
181
|
+
}
|
|
182
|
+
}, [walletState.error])
|
|
183
|
+
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (!cartUuid) {
|
|
186
|
+
onNavigationRedirectReplace('BottomTab', { screen: 'Cart' })
|
|
187
|
+
}
|
|
188
|
+
}, [cartUuid])
|
|
189
|
+
|
|
174
190
|
return (
|
|
175
191
|
<>
|
|
176
192
|
<Container noPadding>
|
|
@@ -248,6 +264,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
248
264
|
<MultiCartsPaymethodsAndWallets
|
|
249
265
|
openCarts={openCarts}
|
|
250
266
|
paymethodSelected={paymethodSelected}
|
|
267
|
+
walletsPaymethod={cartGroup?.result?.wallets}
|
|
251
268
|
handleSelectPaymethod={handleSelectPaymethod}
|
|
252
269
|
handleSelectWallet={handleSelectWallet}
|
|
253
270
|
handlePaymethodDataChange={handlePaymethodDataChange}
|
|
@@ -346,12 +363,14 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
346
363
|
)}
|
|
347
364
|
{openCarts.length > 1 && (
|
|
348
365
|
<ChCartsTotal>
|
|
349
|
-
{totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
|
|
366
|
+
{!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
|
|
350
367
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
351
368
|
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
352
369
|
{t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
|
|
353
370
|
</OText>
|
|
354
|
-
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
371
|
+
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
372
|
+
{parsePrice(totalCartsFee)}
|
|
373
|
+
</OText>
|
|
355
374
|
</View>
|
|
356
375
|
)}
|
|
357
376
|
{openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
|