ordering-ui-react-native 0.16.1 → 0.16.4
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/components/LoginForm/index.tsx +3 -1
- package/src/components/SignupForm/index.tsx +3 -1
- package/src/components/UserProfileForm/index.tsx +63 -6
- package/src/components/UserProfileForm/styles.tsx +8 -0
- package/src/components/shared/OModal.tsx +1 -1
- package/src/types/index.tsx +2 -0
- package/themes/business/src/components/shared/OModal.tsx +1 -1
- package/themes/original/src/components/AddressForm/index.tsx +1 -1
- package/themes/original/src/components/AddressList/index.tsx +1 -1
- package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
- package/themes/original/src/components/BusinessProductsList/index.tsx +1 -1
- package/themes/original/src/components/Cart/index.tsx +1 -1
- package/themes/original/src/components/GoogleMap/index.tsx +1 -0
- package/themes/original/src/components/LoginForm/index.tsx +3 -1
- package/themes/original/src/components/OrderDetails/index.tsx +19 -25
- package/themes/original/src/components/OrderSummary/index.tsx +1 -1
- package/themes/original/src/components/OrdersOption/index.tsx +31 -26
- package/themes/original/src/components/PreviousOrders/index.tsx +1 -1
- package/themes/original/src/components/ProductItemAccordion/index.tsx +1 -1
- package/themes/original/src/components/SignupForm/index.tsx +2 -1
- package/themes/original/src/components/shared/OModal.tsx +1 -1
- package/themes/original/src/types/index.tsx +3 -1
package/package.json
CHANGED
|
@@ -92,6 +92,8 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
92
92
|
|
|
93
93
|
const inputRef = useRef<any>({})
|
|
94
94
|
|
|
95
|
+
const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
|
|
96
|
+
|
|
95
97
|
const anySocialButtonActivated = ((configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') && configs?.facebook_id?.value) ||
|
|
96
98
|
(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) ||
|
|
97
99
|
(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null)
|
|
@@ -381,7 +383,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
381
383
|
handleSuccessFacebookLogin={handleSuccessFacebook}
|
|
382
384
|
/>
|
|
383
385
|
)}
|
|
384
|
-
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
|
|
386
|
+
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
|
|
385
387
|
<GoogleLogin
|
|
386
388
|
notificationState={notificationState}
|
|
387
389
|
webClientId={configs?.google_login_client_id?.value}
|
|
@@ -115,6 +115,8 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
115
115
|
const phoneRef = useRef<any>(null)
|
|
116
116
|
const passwordRef = useRef<any>(null)
|
|
117
117
|
|
|
118
|
+
const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
|
|
119
|
+
|
|
118
120
|
const anySocialButtonActivated = ((configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') && configs?.facebook_id?.value) ||
|
|
119
121
|
(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) ||
|
|
120
122
|
(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null)
|
|
@@ -543,7 +545,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
543
545
|
handleSuccessFacebookLogin={handleSuccessFacebook}
|
|
544
546
|
/>
|
|
545
547
|
)}
|
|
546
|
-
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
|
|
548
|
+
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
|
|
547
549
|
<GoogleLogin
|
|
548
550
|
notificationState={notificationState}
|
|
549
551
|
webClientId={configs?.google_login_client_id?.value}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
UserFormDetails as UserProfileController,
|
|
3
4
|
useSession,
|
|
4
5
|
useLanguage,
|
|
5
6
|
} from 'ordering-components/native';
|
|
@@ -13,6 +14,7 @@ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityI
|
|
|
13
14
|
import Ionicons from 'react-native-vector-icons/Ionicons'
|
|
14
15
|
|
|
15
16
|
import {
|
|
17
|
+
OAlert,
|
|
16
18
|
OIcon,
|
|
17
19
|
OText
|
|
18
20
|
} from '../shared';
|
|
@@ -20,18 +22,24 @@ import {
|
|
|
20
22
|
Container,
|
|
21
23
|
Names,
|
|
22
24
|
UserInfoContainer,
|
|
23
|
-
LanguageContainer
|
|
25
|
+
LanguageContainer,
|
|
26
|
+
RemoveAccountContainer
|
|
24
27
|
} from './styles';
|
|
25
28
|
|
|
26
|
-
export const
|
|
29
|
+
export const UserProfileFormUI = (props: ProfileParams) => {
|
|
27
30
|
const {
|
|
28
|
-
navigation
|
|
31
|
+
navigation,
|
|
32
|
+
handleRemoveAccount,
|
|
33
|
+
removeAccountState
|
|
29
34
|
} = props;
|
|
30
35
|
|
|
31
36
|
const theme = useTheme();
|
|
32
|
-
const [{ user }] = useSession();
|
|
37
|
+
const [{ user }, { logout }] = useSession();
|
|
33
38
|
const [, t] = useLanguage();
|
|
34
39
|
|
|
40
|
+
const isAdmin = user?.level === 0
|
|
41
|
+
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
42
|
+
|
|
35
43
|
const styles = StyleSheet.create({
|
|
36
44
|
linkStyle: {
|
|
37
45
|
color: theme.colors.primary,
|
|
@@ -44,6 +52,9 @@ export const UserProfileForm = (props: ProfileParams) => {
|
|
|
44
52
|
},
|
|
45
53
|
iconStyle: {
|
|
46
54
|
fontSize: 24
|
|
55
|
+
},
|
|
56
|
+
removeAccount: {
|
|
57
|
+
flexDirection: 'row'
|
|
47
58
|
}
|
|
48
59
|
});
|
|
49
60
|
|
|
@@ -78,13 +89,31 @@ export const UserProfileForm = (props: ProfileParams) => {
|
|
|
78
89
|
},
|
|
79
90
|
chevronUp: {
|
|
80
91
|
display: 'none'
|
|
81
|
-
}
|
|
92
|
+
},
|
|
82
93
|
})
|
|
83
94
|
|
|
84
95
|
const onRedirect = (route: string, params?: any) => {
|
|
85
96
|
navigation.navigate(route, params)
|
|
86
97
|
}
|
|
87
98
|
|
|
99
|
+
const onRemoveAccount = () => {
|
|
100
|
+
setConfirm({
|
|
101
|
+
open: true,
|
|
102
|
+
content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
|
|
103
|
+
title: t('ACCOUNT_ALERT', 'Account alert'),
|
|
104
|
+
handleOnAccept: () => {
|
|
105
|
+
setConfirm({ ...confirm, open: false })
|
|
106
|
+
handleRemoveAccount && handleRemoveAccount(user?.id)
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (removeAccountState?.result === 'OK') {
|
|
113
|
+
logout()
|
|
114
|
+
}
|
|
115
|
+
}, [removeAccountState])
|
|
116
|
+
|
|
88
117
|
return (
|
|
89
118
|
<Container>
|
|
90
119
|
<View>
|
|
@@ -134,7 +163,35 @@ export const UserProfileForm = (props: ProfileParams) => {
|
|
|
134
163
|
<LanguageSelector pickerStyle={_pickerStyle} />
|
|
135
164
|
</LanguageContainer>
|
|
136
165
|
<LogoutButton />
|
|
166
|
+
<RemoveAccountContainer>
|
|
167
|
+
<TouchableOpacity
|
|
168
|
+
disabled={isAdmin}
|
|
169
|
+
style={styles.removeAccount}
|
|
170
|
+
onPress={() => onRemoveAccount()}
|
|
171
|
+
activeOpacity={0.7}
|
|
172
|
+
>
|
|
173
|
+
<OIcon src={theme.images.general.user} width={20} color={theme.colors.black} style={{ marginEnd: 14 }} />
|
|
174
|
+
<OText size={14} weight={'400'} style={{ opacity: isAdmin ? 0.5 : 1, top: 1 }} color={theme.colors.red}>{t('REMOVE_ACCOUNT', 'Remove account')}</OText>
|
|
175
|
+
</TouchableOpacity>
|
|
176
|
+
</RemoveAccountContainer>
|
|
137
177
|
</View>
|
|
178
|
+
<OAlert
|
|
179
|
+
open={confirm.open}
|
|
180
|
+
title={confirm.title}
|
|
181
|
+
content={confirm.content}
|
|
182
|
+
onAccept={confirm.handleOnAccept}
|
|
183
|
+
onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
184
|
+
onClose={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
185
|
+
/>
|
|
138
186
|
</Container>
|
|
139
187
|
);
|
|
140
188
|
};
|
|
189
|
+
|
|
190
|
+
export const UserProfileForm = (props: any) => {
|
|
191
|
+
const profileProps = {
|
|
192
|
+
...props,
|
|
193
|
+
UIComponent: UserProfileFormUI,
|
|
194
|
+
useSessionUser: true
|
|
195
|
+
};
|
|
196
|
+
return <UserProfileController {...profileProps} />;
|
|
197
|
+
};
|
|
@@ -35,3 +35,11 @@ export const LanguageContainer = styled.View`
|
|
|
35
35
|
align-items: center;
|
|
36
36
|
margin-bottom: 10px;
|
|
37
37
|
`
|
|
38
|
+
|
|
39
|
+
export const RemoveAccountContainer = styled.View`
|
|
40
|
+
flex-direction: row;
|
|
41
|
+
justify-content: flex-start;
|
|
42
|
+
align-items: center;
|
|
43
|
+
margin-bottom: 10px;
|
|
44
|
+
margin-top: 15px;
|
|
45
|
+
`
|
|
@@ -78,7 +78,7 @@ const OModal = (props: Props): React.ReactElement => {
|
|
|
78
78
|
animationType="slide"
|
|
79
79
|
transparent={isTransparent}
|
|
80
80
|
visible={open}
|
|
81
|
-
onRequestClose={() => { onClose() }}
|
|
81
|
+
onRequestClose={() => { onClose && onClose() }}
|
|
82
82
|
style={{ height: '100%', flex: 1, position: 'absolute', ...style, zIndex: 9999 }}
|
|
83
83
|
>
|
|
84
84
|
{isAvoidKeyBoardView ? (
|
package/src/types/index.tsx
CHANGED
|
@@ -510,7 +510,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
510
510
|
onActionLeft={goToBack}
|
|
511
511
|
showCall={false}
|
|
512
512
|
btnStyle={{ paddingLeft: 0 }}
|
|
513
|
-
style={{
|
|
513
|
+
style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
|
|
514
514
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
515
515
|
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
516
516
|
/>
|
|
@@ -179,7 +179,7 @@ const AddressListUI = (props: AddressListParams) => {
|
|
|
179
179
|
showCall={false}
|
|
180
180
|
btnStyle={{ paddingLeft: 0 }}
|
|
181
181
|
paddingTop={0}
|
|
182
|
-
style={{
|
|
182
|
+
style={{ marginTop: Platform.OS === 'ios' ? 0 : 40 }}
|
|
183
183
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
184
184
|
titleStyle={{ marginLeft: 0, marginRight: 0 }}
|
|
185
185
|
/>
|
|
@@ -144,7 +144,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
144
144
|
|
|
145
145
|
const validateSelectedDate = (curdate: any, menu: any) => {
|
|
146
146
|
const day = moment(curdate).format('d')
|
|
147
|
-
setIsEnabled(menu?.schedule[day]?.enabled || false)
|
|
147
|
+
setIsEnabled(menu?.schedule?.[day]?.enabled || false)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
const getTimes = (curdate: any, menu: any) => {
|
|
@@ -57,12 +57,12 @@ const BusinessProductsCategoriesUI = (props: any) => {
|
|
|
57
57
|
|
|
58
58
|
if (!lazyLoadProductsRecommended) {
|
|
59
59
|
if (category?.id) {
|
|
60
|
-
scrollViewRef.current.scrollTo({
|
|
60
|
+
scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
|
|
61
61
|
y: categoriesLayout[`cat_${category?.id}`]?.y + productListLayout?.y - 70,
|
|
62
62
|
animated: true
|
|
63
63
|
})
|
|
64
64
|
} else {
|
|
65
|
-
scrollViewRef.current.scrollTo({
|
|
65
|
+
scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
|
|
66
66
|
y: productListLayout?.y - 70,
|
|
67
67
|
animated: true
|
|
68
68
|
})
|
|
@@ -315,9 +315,9 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
315
315
|
))}
|
|
316
316
|
<OModal
|
|
317
317
|
open={!!openDescription}
|
|
318
|
-
title={openDescription?.name}
|
|
319
318
|
onClose={() => setOpenDescription(null)}
|
|
320
319
|
>
|
|
320
|
+
<OText size={20} style={{paddingLeft: 70, paddingRight: 20, bottom: 25}}>{openDescription?.name}</OText>
|
|
321
321
|
<ScrollView style={{ padding: 20 }}>
|
|
322
322
|
{!!openDescription?.image && (
|
|
323
323
|
<OIcon
|
|
@@ -106,7 +106,7 @@ const CartUI = (props: any) => {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
const getIncludedTaxes = () => {
|
|
109
|
-
if (cart?.taxes === null) {
|
|
109
|
+
if (cart?.taxes === null || !cart?.taxes) {
|
|
110
110
|
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
111
111
|
} else {
|
|
112
112
|
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
@@ -99,6 +99,8 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
99
99
|
const theme = useTheme();
|
|
100
100
|
const isOtpEmail = loginTab === 'otp' && otpType === 'email'
|
|
101
101
|
const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
|
|
102
|
+
const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
|
|
103
|
+
|
|
102
104
|
const loginStyle = StyleSheet.create({
|
|
103
105
|
btnOutline: {
|
|
104
106
|
backgroundColor: '#FFF',
|
|
@@ -710,7 +712,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
710
712
|
handleSuccessFacebookLogin={handleSuccessFacebook}
|
|
711
713
|
/>
|
|
712
714
|
)}
|
|
713
|
-
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
|
|
715
|
+
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
|
|
714
716
|
<GoogleLogin
|
|
715
717
|
notificationState={notificationState}
|
|
716
718
|
webClientId={configs?.google_login_client_id?.value}
|
|
@@ -333,7 +333,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
333
333
|
};
|
|
334
334
|
|
|
335
335
|
const getIncludedTaxes = () => {
|
|
336
|
-
if (order?.taxes?.length === 0) {
|
|
336
|
+
if (order?.taxes?.length === 0 || !order?.taxes) {
|
|
337
337
|
return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
|
|
338
338
|
} else {
|
|
339
339
|
return order?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
@@ -364,27 +364,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
364
364
|
)
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
const RenderGoogleMap = () => {
|
|
368
|
-
const driverLocationString = typeof order?.driver?.location?.location === 'string' && order?.driver?.location?.location?.split(',').map((l: string) => l.replace(/[^-.0-9]/g, ''))
|
|
369
|
-
const parsedLocations = locations.map(location => typeof location?.location === 'string' ? {
|
|
370
|
-
...location,
|
|
371
|
-
lat: parseFloat(location?.location?.split(',')[0].replace(/[^-.0-9]/g, '')),
|
|
372
|
-
lng: parseFloat(location?.location?.split(',')[1].replace(/[^-.0-9]/g, ''))
|
|
373
|
-
} : location)
|
|
374
|
-
|
|
375
|
-
return (
|
|
376
|
-
<GoogleMap
|
|
377
|
-
location={typeof order?.driver?.location?.location === 'string'
|
|
378
|
-
? {
|
|
379
|
-
lat: parseFloat(driverLocationString[0]),
|
|
380
|
-
lng: parseFloat(driverLocationString[1]),
|
|
381
|
-
} : order?.driver?.location
|
|
382
|
-
}
|
|
383
|
-
locations={parsedLocations}
|
|
384
|
-
readOnly
|
|
385
|
-
/>
|
|
386
|
-
)
|
|
387
|
-
}
|
|
388
367
|
|
|
389
368
|
useEffect(() => {
|
|
390
369
|
const _businessId = 'businessId:' + businessData?.id
|
|
@@ -436,6 +415,12 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
436
415
|
'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
|
|
437
416
|
},
|
|
438
417
|
];
|
|
418
|
+
const driverLocationString = typeof order?.driver?.location?.location === 'string' && order?.driver?.location?.location?.split(',').map((l: string) => l.replace(/[^-.0-9]/g, ''))
|
|
419
|
+
const parsedLocations = locations.map(location => typeof location?.location === 'string' ? {
|
|
420
|
+
...location,
|
|
421
|
+
lat: parseFloat(location?.location?.split(',')[0].replace(/[^-.0-9]/g, '')),
|
|
422
|
+
lng: parseFloat(location?.location?.split(',')[1].replace(/[^-.0-9]/g, ''))
|
|
423
|
+
} : location)
|
|
439
424
|
|
|
440
425
|
useEffect(() => {
|
|
441
426
|
if (driverLocation) {
|
|
@@ -506,7 +491,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
506
491
|
onActionLeft={handleArrowBack}
|
|
507
492
|
showCall={false}
|
|
508
493
|
btnStyle={{ paddingLeft: 0 }}
|
|
509
|
-
style={{
|
|
494
|
+
style={{ marginTop: Platform.OS === 'ios' ? 0 : 20 }}
|
|
510
495
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
511
496
|
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
512
497
|
subTitle={<OText size={12} lineHeight={18} color={theme.colors.textNormal}>
|
|
@@ -697,7 +682,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
697
682
|
</OText>
|
|
698
683
|
</View>
|
|
699
684
|
)}
|
|
700
|
-
{order?.comment && (
|
|
685
|
+
{!!order?.comment && (
|
|
701
686
|
<View style={{ marginTop: 15 }}>
|
|
702
687
|
<OText size={16} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
|
|
703
688
|
{t('COMMENT', 'Comment')}
|
|
@@ -709,7 +694,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
709
694
|
<>
|
|
710
695
|
{order?.driver?.location && mapValidStatuses.includes(parseInt(order?.status)) && (
|
|
711
696
|
<Map>
|
|
712
|
-
<
|
|
697
|
+
<GoogleMap
|
|
698
|
+
location={typeof order?.driver?.location?.location === 'string'
|
|
699
|
+
? {
|
|
700
|
+
lat: parseFloat(driverLocationString[0]),
|
|
701
|
+
lng: parseFloat(driverLocationString[1]),
|
|
702
|
+
} : driverLocation ?? order?.driver?.location
|
|
703
|
+
}
|
|
704
|
+
locations={parsedLocations}
|
|
705
|
+
readOnly
|
|
706
|
+
/>
|
|
713
707
|
</Map>
|
|
714
708
|
)}
|
|
715
709
|
</>
|
|
@@ -71,7 +71,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const getIncludedTaxes = () => {
|
|
74
|
-
if (cart?.taxes === null) {
|
|
74
|
+
if (cart?.taxes === null || !cart?.taxes) {
|
|
75
75
|
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
76
76
|
} else {
|
|
77
77
|
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
@@ -9,7 +9,7 @@ import { PreviousOrders } from '../PreviousOrders'
|
|
|
9
9
|
|
|
10
10
|
import { OptionTitle, NoOrdersWrapper } from './styles'
|
|
11
11
|
import { OrdersOptionParams } from '../../types'
|
|
12
|
-
|
|
12
|
+
import { _setStoreData } from '../../providers/StoreUtil';
|
|
13
13
|
import {
|
|
14
14
|
Placeholder,
|
|
15
15
|
PlaceholderLine,
|
|
@@ -35,13 +35,15 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
35
35
|
setOrdersLength,
|
|
36
36
|
ordersLength,
|
|
37
37
|
refreshOrders,
|
|
38
|
-
setRefreshOrders
|
|
38
|
+
setRefreshOrders,
|
|
39
|
+
reorderState,
|
|
40
|
+
handleReorder
|
|
39
41
|
} = props
|
|
40
42
|
|
|
41
43
|
const theme = useTheme();
|
|
42
44
|
|
|
43
45
|
const [, t] = useLanguage()
|
|
44
|
-
const [
|
|
46
|
+
const [{ carts }] = useOrder()
|
|
45
47
|
const { showToast } = useToast()
|
|
46
48
|
const { loading, error, orders: values } = orderList
|
|
47
49
|
|
|
@@ -51,26 +53,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
51
53
|
|
|
52
54
|
const orders = customArray || values || []
|
|
53
55
|
|
|
54
|
-
const [reorderLoading, setReorderLoading] = useState(false)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const handleReorder = async (orderId: number) => {
|
|
58
|
-
setReorderLoading(true)
|
|
59
|
-
try {
|
|
60
|
-
const { error, result } = await reorder(orderId)
|
|
61
|
-
if (!error) {
|
|
62
|
-
onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: result.uuid })
|
|
63
|
-
setReorderLoading(false)
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
setReorderLoading(false)
|
|
67
|
-
|
|
68
|
-
} catch (err: any) {
|
|
69
|
-
showToast(ToastType.Error, t('ERROR', err.message))
|
|
70
|
-
setReorderLoading(false)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
56
|
const getOrderStatus = (s: string) => {
|
|
75
57
|
const status = parseInt(s)
|
|
76
58
|
const orderStatus = [
|
|
@@ -105,6 +87,29 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
105
87
|
return objectStatus && objectStatus
|
|
106
88
|
}
|
|
107
89
|
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const _businessId = 'businessId:' + reorderState?.result?.business_id
|
|
92
|
+
if (reorderState?.error) {
|
|
93
|
+
if (reorderState?.result?.business_id) {
|
|
94
|
+
_setStoreData('adjust-cart-products', JSON.stringify(_businessId))
|
|
95
|
+
navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
|
|
99
|
+
const cartProducts = carts?.[_businessId]?.products
|
|
100
|
+
const available = cartProducts.every((product: any) => product.valid === true)
|
|
101
|
+
const orderProducts = orders.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
|
|
102
|
+
|
|
103
|
+
if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
|
|
104
|
+
onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
|
|
105
|
+
} else {
|
|
106
|
+
_setStoreData('adjust-cart-products', JSON.stringify(_businessId))
|
|
107
|
+
cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
|
|
108
|
+
navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, [reorderState])
|
|
112
|
+
|
|
108
113
|
useFocusEffect(
|
|
109
114
|
React.useCallback(() => {
|
|
110
115
|
loadOrders(false, false, false, true)
|
|
@@ -213,7 +218,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
213
218
|
orders={orders.filter((order: any) => orderStatus.includes(order.status))}
|
|
214
219
|
pagination={pagination}
|
|
215
220
|
loadMoreOrders={loadMoreOrders}
|
|
216
|
-
reorderLoading={
|
|
221
|
+
reorderLoading={reorderState?.loading}
|
|
217
222
|
customArray={customArray}
|
|
218
223
|
getOrderStatus={getOrderStatus}
|
|
219
224
|
onNavigationRedirect={onNavigationRedirect}
|
|
@@ -222,14 +227,14 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
222
227
|
<ActiveOrders
|
|
223
228
|
orders={orders.filter((order: any) => orderStatus.includes(order.status))}
|
|
224
229
|
pagination={pagination}
|
|
225
|
-
reorderLoading={
|
|
230
|
+
reorderLoading={reorderState?.loading}
|
|
226
231
|
customArray={customArray}
|
|
227
232
|
getOrderStatus={getOrderStatus}
|
|
228
233
|
onNavigationRedirect={onNavigationRedirect}
|
|
229
234
|
/>
|
|
230
235
|
) : (
|
|
231
236
|
<PreviousOrders
|
|
232
|
-
reorderLoading={
|
|
237
|
+
reorderLoading={reorderState?.loading}
|
|
233
238
|
orders={orders.filter((order: any) => orderStatus.includes(order.status)).sort((a: any, b: any) => a?.id < b?.id)}
|
|
234
239
|
pagination={pagination}
|
|
235
240
|
loadMoreOrders={loadMoreOrders}
|
|
@@ -135,6 +135,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
135
135
|
const recaptchaRef = useRef<any>({});
|
|
136
136
|
|
|
137
137
|
const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
|
|
138
|
+
const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
|
|
138
139
|
|
|
139
140
|
const handleRefs = (ref: any, code: string) => {
|
|
140
141
|
switch (code) {
|
|
@@ -787,7 +788,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
787
788
|
handleSuccessFacebookLogin={handleSuccessFacebook}
|
|
788
789
|
/>
|
|
789
790
|
)}
|
|
790
|
-
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
|
|
791
|
+
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
|
|
791
792
|
<GoogleLogin
|
|
792
793
|
notificationState={notificationState}
|
|
793
794
|
webClientId={configs?.google_login_client_id?.value}
|
|
@@ -91,7 +91,7 @@ const OModal = (props: Props): React.ReactElement => {
|
|
|
91
91
|
animationType="slide"
|
|
92
92
|
transparent={isTransparent}
|
|
93
93
|
visible={open}
|
|
94
|
-
onRequestClose={() => onClose()}
|
|
94
|
+
onRequestClose={() => onClose && onClose()}
|
|
95
95
|
style={{ height: '100%', flex: 1, position: 'absolute', ...style, zIndex: 9999 }}
|
|
96
96
|
>
|
|
97
97
|
{isAvoidKeyBoardView ? (
|
|
@@ -311,6 +311,8 @@ export interface OrdersOptionParams {
|
|
|
311
311
|
loadOrders?: any,
|
|
312
312
|
setOrderList?: any,
|
|
313
313
|
preOrders?: boolean,
|
|
314
|
+
reorderState?: any,
|
|
315
|
+
handleReorder?: (orderId: number) => {},
|
|
314
316
|
setOrdersLength?: ({ activeOrdersLength, previousOrdersLength }: { activeOrdersLength: number, previousOrdersLength: number }) => void,
|
|
315
317
|
ordersLength: { activeOrdersLength: number, previousOrdersLength: number },
|
|
316
318
|
setSelectedOrderId?: any,
|
|
@@ -339,7 +341,7 @@ export interface PreviousOrdersParams {
|
|
|
339
341
|
orderID?: number
|
|
340
342
|
reorderLoading?: boolean,
|
|
341
343
|
loadMoreOrders?: () => {},
|
|
342
|
-
handleReorder
|
|
344
|
+
handleReorder?: (orderId: number) => {},
|
|
343
345
|
onNavigationRedirect?: (route: string, params?: any) => {}
|
|
344
346
|
}
|
|
345
347
|
export interface OrderDetailsParams {
|