ordering-ui-react-native 0.14.51 → 0.14.54
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/themes/original/src/components/BusinessPreorder/index.tsx +53 -40
- package/themes/original/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/original/src/components/Checkout/index.tsx +3 -1
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +2 -2
- package/themes/original/src/components/ProductForm/index.tsx +3 -1
- package/themes/original/src/components/UserProfile/index.tsx +10 -4
- package/themes/original/src/components/Wallets/index.tsx +9 -1
package/package.json
CHANGED
|
@@ -34,7 +34,9 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
34
34
|
timeSelected,
|
|
35
35
|
handleBusinessClick,
|
|
36
36
|
handleChangeDate,
|
|
37
|
-
handleChangeTime
|
|
37
|
+
handleChangeTime,
|
|
38
|
+
handleAsap,
|
|
39
|
+
isAsap
|
|
38
40
|
} = props
|
|
39
41
|
|
|
40
42
|
const theme = useTheme()
|
|
@@ -43,10 +45,11 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
43
45
|
const [{ configs }] = useConfig()
|
|
44
46
|
const [orderState] = useOrder()
|
|
45
47
|
const [selectedPreorderType, setSelectedPreorderType] = useState(0)
|
|
46
|
-
const [menu, setMenu] = useState({})
|
|
48
|
+
const [menu, setMenu] = useState<any>({})
|
|
47
49
|
const [timeList, setTimeList] = useState<any>([])
|
|
48
50
|
const [selectDate, setSelectedDate] = useState<any>(null)
|
|
49
51
|
const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
|
|
52
|
+
const [isEnabled, setIsEnabled] = useState(false)
|
|
50
53
|
|
|
51
54
|
const styles = StyleSheet.create({
|
|
52
55
|
container: {
|
|
@@ -137,7 +140,13 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
137
140
|
{ key: 'business_menu', name: t('BUSINESS_MENU', 'Business menu') }
|
|
138
141
|
]
|
|
139
142
|
|
|
143
|
+
const validateSelectedDate = (curdate: any, menu: any) => {
|
|
144
|
+
const day = moment(curdate).format('d')
|
|
145
|
+
setIsEnabled(menu?.schedule[day]?.enabled || false)
|
|
146
|
+
}
|
|
147
|
+
|
|
140
148
|
const getTimes = (curdate: any, menu: any) => {
|
|
149
|
+
validateSelectedDate(curdate, menu)
|
|
141
150
|
const date = new Date()
|
|
142
151
|
var dateSeleted = new Date(curdate)
|
|
143
152
|
var times = []
|
|
@@ -240,26 +249,11 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
240
249
|
}
|
|
241
250
|
|
|
242
251
|
useEffect(() => {
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const _timeLists = hoursList.map((hour: any) => {
|
|
249
|
-
return {
|
|
250
|
-
value: hour.startTime,
|
|
251
|
-
text: configs?.format_time?.value === '12' ? (
|
|
252
|
-
hour.startTime.includes('12')
|
|
253
|
-
? `${hour.startTime}PM`
|
|
254
|
-
: parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
255
|
-
) : (
|
|
256
|
-
parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
|
|
257
|
-
)
|
|
258
|
-
}
|
|
259
|
-
})
|
|
260
|
-
setTimeList(_timeLists)
|
|
261
|
-
}
|
|
262
|
-
}, [selectDate, hoursList, menu])
|
|
252
|
+
if (selectDate === null) return
|
|
253
|
+
const selectedMenu = Object.keys(menu).length > 0 ? (menu?.use_business_schedule ? business : menu) : business
|
|
254
|
+
const _times = getTimes(selectDate, selectedMenu)
|
|
255
|
+
setTimeList(_times)
|
|
256
|
+
}, [selectDate, menu])
|
|
263
257
|
|
|
264
258
|
useEffect(() => {
|
|
265
259
|
if (selectedPreorderType === 0 && Object.keys(menu).length > 0) setMenu({})
|
|
@@ -273,6 +267,10 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
273
267
|
}
|
|
274
268
|
}, [dateSelected])
|
|
275
269
|
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
handleAsap && handleAsap()
|
|
272
|
+
}, [])
|
|
273
|
+
|
|
276
274
|
return (
|
|
277
275
|
<>
|
|
278
276
|
<PreOrderContainer contentContainerStyle={{ paddingVertical: 32, paddingHorizontal: 40 }}>
|
|
@@ -413,24 +411,38 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
413
411
|
)}
|
|
414
412
|
</View>
|
|
415
413
|
<TimeListWrapper nestedScrollEnabled={true}>
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
<
|
|
420
|
-
<
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
414
|
+
{(isEnabled && timeList?.length > 0) ? (
|
|
415
|
+
<TimeContentWrapper>
|
|
416
|
+
{timeList.map((time: any, i: number) => (
|
|
417
|
+
<TouchableOpacity key={i} onPress={() => handleChangeTime(time.value)}>
|
|
418
|
+
<TimeItem active={timeSelected === time.value}>
|
|
419
|
+
<OText
|
|
420
|
+
size={14}
|
|
421
|
+
color={timeSelected === time.value ? theme.colors.primary : theme.colors.textNormal}
|
|
422
|
+
style={{
|
|
423
|
+
lineHeight: 24
|
|
424
|
+
}}
|
|
425
|
+
>{time.text}</OText>
|
|
426
|
+
</TimeItem>
|
|
427
|
+
</TouchableOpacity>
|
|
428
|
+
))}
|
|
429
|
+
{timeList.length % 3 === 2 && (
|
|
430
|
+
<TimeItem style={{ backgroundColor: 'transparent' }} />
|
|
431
|
+
)}
|
|
432
|
+
</TimeContentWrapper>
|
|
433
|
+
) : (
|
|
434
|
+
<OText
|
|
435
|
+
size={16}
|
|
436
|
+
style={{
|
|
437
|
+
fontWeight: '600',
|
|
438
|
+
lineHeight: 24,
|
|
439
|
+
marginBottom: 12,
|
|
440
|
+
textAlign: 'center'
|
|
441
|
+
}}
|
|
442
|
+
>
|
|
443
|
+
{t('ERROR_ADD_PRODUCT_BUSINESS_CLOSED', 'The business is closed at the moment')}
|
|
444
|
+
</OText>
|
|
445
|
+
)}
|
|
434
446
|
</TimeListWrapper>
|
|
435
447
|
</OrderTimeWrapper>
|
|
436
448
|
<OButton
|
|
@@ -438,6 +450,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
438
450
|
textStyle={{ color: 'white' }}
|
|
439
451
|
style={{ borderRadius: 7.6, marginBottom: 20, marginTop: 30 }}
|
|
440
452
|
onClick={() => handleClickBusiness()}
|
|
453
|
+
isDisabled={isAsap || !(dateSelected && timeSelected)}
|
|
441
454
|
/>
|
|
442
455
|
</PreOrderContainer>
|
|
443
456
|
<Spinner visible={orderState.loading} />
|
|
@@ -240,7 +240,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
240
240
|
{isFarAway && (
|
|
241
241
|
<FarAwayMessage style={styles.farAwayMsg}>
|
|
242
242
|
<Ionicons name='md-warning-outline' style={styles.iconStyle} />
|
|
243
|
-
<OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', '
|
|
243
|
+
<OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
|
|
244
244
|
</FarAwayMessage>
|
|
245
245
|
)}
|
|
246
246
|
<OrderControlContainer>
|
|
@@ -127,6 +127,8 @@ const CheckoutUI = (props: any) => {
|
|
|
127
127
|
const [openChangeStore, setOpenChangeStore] = useState(false)
|
|
128
128
|
const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
|
|
129
129
|
|
|
130
|
+
const isWalletEnabled = configs?.wallet_enabled?.value === '1'
|
|
131
|
+
|
|
130
132
|
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
131
133
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
132
134
|
: configs?.driver_tip_options?.value || []
|
|
@@ -506,7 +508,7 @@ const CheckoutUI = (props: any) => {
|
|
|
506
508
|
</ChSection>
|
|
507
509
|
)}
|
|
508
510
|
|
|
509
|
-
{!cartState.loading && cart && (
|
|
511
|
+
{!cartState.loading && cart && isWalletEnabled && (
|
|
510
512
|
<WalletPaymentOptionContainer>
|
|
511
513
|
<PaymentOptionWallet
|
|
512
514
|
cart={cart}
|
|
@@ -55,7 +55,7 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const handleOnChange = (position: any, wallet: any) => {
|
|
58
|
-
const updatedCheckedState = checkedState.map((item, index) =>
|
|
58
|
+
const updatedCheckedState = checkedState.map((item: any, index: any) =>
|
|
59
59
|
index === position ? !item : item
|
|
60
60
|
);
|
|
61
61
|
|
|
@@ -85,7 +85,7 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
85
85
|
walletsState.result?.length > 0 &&
|
|
86
86
|
(
|
|
87
87
|
<>
|
|
88
|
-
{walletsState.result?.map((wallet: any, idx: any) => wallet.valid && (
|
|
88
|
+
{walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && (
|
|
89
89
|
<Container
|
|
90
90
|
key={wallet.id}
|
|
91
91
|
isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
|
|
@@ -212,7 +212,9 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
const handleRedirectLogin = () => {
|
|
215
|
-
navigation.navigate('Login'
|
|
215
|
+
navigation.navigate('Login', {
|
|
216
|
+
store_slug: props.businessSlug
|
|
217
|
+
});
|
|
216
218
|
};
|
|
217
219
|
|
|
218
220
|
const handleSwitchQtyUnit = (val: string) => {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
useLanguage,
|
|
6
6
|
ToastType,
|
|
7
7
|
useToast,
|
|
8
|
+
useConfig
|
|
8
9
|
} from 'ordering-components/native';
|
|
9
10
|
import { useTheme } from 'styled-components/native';
|
|
10
11
|
import { useForm } from 'react-hook-form';
|
|
@@ -91,12 +92,15 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
91
92
|
|
|
92
93
|
const [{ user }] = useSession();
|
|
93
94
|
const [, t] = useLanguage();
|
|
95
|
+
const [{ configs }] = useConfig();
|
|
94
96
|
const [, { showToast }] = useToast();
|
|
95
97
|
const { errors } = useForm();
|
|
96
98
|
|
|
97
99
|
const { height } = useWindowDimensions();
|
|
98
100
|
const { top, bottom } = useSafeAreaInsets();
|
|
99
101
|
|
|
102
|
+
const isWalletEnabled = configs?.wallet_enabled?.value === '1'
|
|
103
|
+
|
|
100
104
|
const onRedirect = (route: string, params?: any) => {
|
|
101
105
|
navigation.navigate(route, params)
|
|
102
106
|
}
|
|
@@ -161,10 +165,12 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
161
165
|
<MessageCircle name='message1' style={styles.messageIconStyle} color={theme.colors.textNormal} />
|
|
162
166
|
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('MESSAGES', 'Messages')}</OText>
|
|
163
167
|
</ListItem>
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
{!isWalletEnabled && (
|
|
169
|
+
<ListItem onPress={() => onRedirect('Wallets', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
|
|
170
|
+
<Ionicons name='wallet-outline' style={styles.messageIconStyle} color={theme.colors.textNormal} />
|
|
171
|
+
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('WALLETS', 'Wallets')}</OText>
|
|
172
|
+
</ListItem>
|
|
173
|
+
)}
|
|
168
174
|
<ListItem onPress={() => navigation.navigate('Help', {})} activeOpacity={0.7}>
|
|
169
175
|
<OIcon src={theme.images.general.ic_help} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
|
|
170
176
|
<OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('HELP', 'Help')}</OText>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
2
|
import { Pressable, View } from 'react-native';
|
|
3
3
|
import { useTheme } from 'styled-components/native'
|
|
4
4
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
@@ -60,6 +60,14 @@ const WalletsUI = (props: any) => {
|
|
|
60
60
|
navigation?.canGoBack() && navigation.goBack()
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (configs?.wallet_enabled?.value === '0') {
|
|
65
|
+
navigation.navigate('BottomTab', {
|
|
66
|
+
screen: 'Profile'
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
}, [configs])
|
|
70
|
+
|
|
63
71
|
return (
|
|
64
72
|
<Container>
|
|
65
73
|
<NavBar
|