ordering-ui-react-native 0.23.55 → 0.23.56
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
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { View, StyleSheet, ScrollView, ActivityIndicator, Pressable } from 'react-native';
|
|
3
|
+
import { _retrieveStoreData, _clearStoreData } from '../../providers/StoreUtil';
|
|
3
4
|
import { useForm } from 'react-hook-form';
|
|
4
5
|
import { launchImageLibrary } from 'react-native-image-picker';
|
|
5
6
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
UserData,
|
|
21
22
|
EditButton,
|
|
22
23
|
EnabledStatusDriver,
|
|
24
|
+
RemoveAccount
|
|
23
25
|
} from './styles';
|
|
24
26
|
import { LogoutButton } from '../LogoutButton';
|
|
25
27
|
import { LanguageSelector } from '../LanguageSelector';
|
|
@@ -36,6 +38,8 @@ import {
|
|
|
36
38
|
OInput,
|
|
37
39
|
OModal,
|
|
38
40
|
} from '../../components/shared';
|
|
41
|
+
import { OAlert } from '../../../../../src/components/shared'
|
|
42
|
+
|
|
39
43
|
import { sortInputFields, getTraduction } from '../../utils';
|
|
40
44
|
import { ProfileParams } from '../../types';
|
|
41
45
|
import { NotFoundSource } from '../NotFoundSource';
|
|
@@ -49,6 +53,7 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
49
53
|
toggleIsEdit,
|
|
50
54
|
cleanFormState,
|
|
51
55
|
handleToggleAvalaibleStatusDriver,
|
|
56
|
+
handleRemoveAccount,
|
|
52
57
|
isAlsea,
|
|
53
58
|
isShowDriverStatus,
|
|
54
59
|
navigation
|
|
@@ -62,6 +67,7 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
62
67
|
const [{ loading }, { loadOriginalValidationFields }] = useValidationFields()
|
|
63
68
|
const { errors } = useForm();
|
|
64
69
|
const theme = useTheme();
|
|
70
|
+
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
65
71
|
|
|
66
72
|
const [phoneInputData, setPhoneInputData] = useState<any>({
|
|
67
73
|
error: '',
|
|
@@ -76,13 +82,7 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
76
82
|
const [phoneToShow, setPhoneToShow] = useState('');
|
|
77
83
|
const [openModal, setOpenModal] = useState(false)
|
|
78
84
|
const allowDriverUpdateData = user?.level !== 4 || configs?.allow_driver_update_data?.value === "1"
|
|
79
|
-
|
|
80
|
-
if (phoneInputData.phone.cellphone) {
|
|
81
|
-
const codeNumberPhone = phoneInputData.phone.country_phone_code
|
|
82
|
-
const numberPhone = phoneInputData.phone.cellphone
|
|
83
|
-
setPhoneToShow(`(${codeNumberPhone}) ${numberPhone}`);
|
|
84
|
-
}
|
|
85
|
-
}, [phoneInputData.phone.cellphone]);
|
|
85
|
+
const isAdmin = user?.level === 0
|
|
86
86
|
|
|
87
87
|
const setUserCellPhone = (isEdit = false) => {
|
|
88
88
|
if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
|
|
@@ -148,6 +148,28 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
148
148
|
});
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
+
const onRemoveAccount = async () => {
|
|
152
|
+
setConfirm({
|
|
153
|
+
open: true,
|
|
154
|
+
content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
|
|
155
|
+
title: t('ACCOUNT_ALERT', 'Account alert'),
|
|
156
|
+
handleOnAccept: () => {
|
|
157
|
+
setConfirm({ ...confirm, open: false })
|
|
158
|
+
handleRemoveAccount && handleRemoveAccount(user?.id)
|
|
159
|
+
_clearStoreData({ excludedKeys: ['isTutorial', 'language'] });
|
|
160
|
+
props?.setRootState && props?.setRootState({ isAuth: false, token: null })
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
if (phoneInputData.phone.cellphone) {
|
|
167
|
+
const codeNumberPhone = phoneInputData.phone.country_phone_code
|
|
168
|
+
const numberPhone = phoneInputData.phone.cellphone
|
|
169
|
+
setPhoneToShow(`(${codeNumberPhone}) ${numberPhone}`);
|
|
170
|
+
}
|
|
171
|
+
}, [phoneInputData.phone.cellphone]);
|
|
172
|
+
|
|
151
173
|
useEffect(() => {
|
|
152
174
|
const isLoadingDriver = userState?.loadingDriver ?? true;
|
|
153
175
|
|
|
@@ -544,6 +566,10 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
544
566
|
|
|
545
567
|
<LogoutButton setRootState={props.setRootState} />
|
|
546
568
|
</Actions>
|
|
569
|
+
<RemoveAccount disabled={isAdmin} onPress={() => onRemoveAccount()} activeOpacity={0.7}>
|
|
570
|
+
<AntDesignIcon size={16} name='close' color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
|
|
571
|
+
<OText size={14} lineHeight={24} weight={'400'} style={{ opacity: isAdmin ? 0.5 : 1 }} color={theme.colors.danger500}>{t('REMOVE_ACCOUNT', 'Remove account')}</OText>
|
|
572
|
+
</RemoveAccount>
|
|
547
573
|
<OModal
|
|
548
574
|
open={openModal}
|
|
549
575
|
onClose={() => setOpenModal(false)}
|
|
@@ -554,6 +580,14 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
554
580
|
<DriverSchedule schedule={user?.schedule} />
|
|
555
581
|
)}
|
|
556
582
|
</OModal>
|
|
583
|
+
<OAlert
|
|
584
|
+
open={confirm.open}
|
|
585
|
+
title={confirm.title}
|
|
586
|
+
content={confirm.content}
|
|
587
|
+
onAccept={confirm.handleOnAccept}
|
|
588
|
+
onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
589
|
+
onClose={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
590
|
+
/>
|
|
557
591
|
</ScrollView>
|
|
558
592
|
)}
|
|
559
593
|
</>
|
|
@@ -34,3 +34,10 @@ export const Actions = styled.View`
|
|
|
34
34
|
justify-content: space-between;
|
|
35
35
|
align-items: flex-start;
|
|
36
36
|
`;
|
|
37
|
+
|
|
38
|
+
export const RemoveAccount = styled.TouchableOpacity`
|
|
39
|
+
flex-direction: row;
|
|
40
|
+
justify-content: flex-start;
|
|
41
|
+
align-items: center;
|
|
42
|
+
margin-bottom: 24px;
|
|
43
|
+
`
|
|
@@ -43,6 +43,7 @@ export interface ProfileParams {
|
|
|
43
43
|
navigation?: any;
|
|
44
44
|
isEdit?: boolean;
|
|
45
45
|
formState?: any;
|
|
46
|
+
setRootState?: any;
|
|
46
47
|
userState?: any;
|
|
47
48
|
toggleIsEdit?: any;
|
|
48
49
|
cleanFormState?: any;
|
|
@@ -51,6 +52,7 @@ export interface ProfileParams {
|
|
|
51
52
|
handleChangeInput?: any;
|
|
52
53
|
handleButtonUpdateClick?: any;
|
|
53
54
|
handleToggleAvalaibleStatusDriver?: any;
|
|
55
|
+
handleRemoveAccount?: any;
|
|
54
56
|
onNavigationRedirect?: any;
|
|
55
57
|
handlechangeImage?: any;
|
|
56
58
|
validationFields?: any;
|
|
@@ -40,6 +40,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
40
40
|
open: false,
|
|
41
41
|
options: []
|
|
42
42
|
})
|
|
43
|
+
const isDisableNumberValidation = parseInt(configs?.validation_phone_number_lib?.value ?? 1, 10)
|
|
43
44
|
const countriesWithSubOptions = ['PR']
|
|
44
45
|
const style = StyleSheet.create({
|
|
45
46
|
input: {
|
|
@@ -74,7 +75,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
74
75
|
const regex = /^[0-9]*$/
|
|
75
76
|
const cellphone = userphoneNumber.slice(0, 0) + userphoneNumber.slice(1, userphoneNumber.length)
|
|
76
77
|
const validNumber = regex.test(cellphone)
|
|
77
|
-
if ((!checkValid && formattedNumber?.number) || !validNumber) {
|
|
78
|
+
if (((!checkValid && formattedNumber?.number) || !validNumber) && !!isDisableNumberValidation) {
|
|
78
79
|
handleData && handleData({
|
|
79
80
|
...data,
|
|
80
81
|
error: t('INVALID_ERROR_PHONE_NUMBER', 'The Phone Number field is invalid')
|
|
@@ -86,7 +87,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
86
87
|
error: '',
|
|
87
88
|
phone: {
|
|
88
89
|
country_phone_code: callingCode,
|
|
89
|
-
cellphone: formattedNumber?.number
|
|
90
|
+
cellphone: !isDisableNumberValidation ? userphoneNumber : formattedNumber?.number
|
|
90
91
|
}
|
|
91
92
|
})
|
|
92
93
|
} else {
|
|
@@ -134,7 +135,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
const handleSelectCallingCode = (option
|
|
138
|
+
const handleSelectCallingCode = (option: any) => {
|
|
138
139
|
setCountryPhoneSuboptions({
|
|
139
140
|
open: false,
|
|
140
141
|
options: []
|
|
@@ -167,7 +168,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
167
168
|
: findExitingCode(configs?.default_country_code?.value?.toUpperCase())}
|
|
168
169
|
onChangeFormattedText={(text: string) => handleChangeNumber(text)}
|
|
169
170
|
withDarkTheme
|
|
170
|
-
onChangeCountry={(country
|
|
171
|
+
onChangeCountry={(country: any) => _changeCountry?.(country)}
|
|
171
172
|
countryPickerProps={{ withAlphaFilter: true }}
|
|
172
173
|
textContainerStyle={{ ...style.input, ...inputStyle ? inputStyle : {} }}
|
|
173
174
|
textInputStyle={textStyle}
|
|
@@ -202,7 +203,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
202
203
|
alignItems: 'center'
|
|
203
204
|
}}
|
|
204
205
|
>
|
|
205
|
-
{countryPhoneSuboptions.options.map((option
|
|
206
|
+
{countryPhoneSuboptions.options.map((option: any) => (
|
|
206
207
|
<Pressable
|
|
207
208
|
style={{
|
|
208
209
|
margin: 10,
|