ordering-ui-react-native 0.16.0 → 0.16.3
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/UserProfileForm/index.tsx +63 -6
- package/src/components/UserProfileForm/styles.tsx +8 -0
- package/src/types/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.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/BusinessProductsList/index.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +1 -1
- package/themes/original/src/components/ProductItemAccordion/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -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
|
+
`
|
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
|
/>
|
|
@@ -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
|
|
@@ -506,7 +506,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
506
506
|
onActionLeft={handleArrowBack}
|
|
507
507
|
showCall={false}
|
|
508
508
|
btnStyle={{ paddingLeft: 0 }}
|
|
509
|
-
style={{
|
|
509
|
+
style={{ marginTop: Platform.OS === 'ios' ? 0 : 20 }}
|
|
510
510
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
511
511
|
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
512
512
|
subTitle={<OText size={12} lineHeight={18} color={theme.colors.textNormal}>
|