-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
PersonalDetailsInitialPage.js
118 lines (109 loc) · 4.6 KB
/
PersonalDetailsInitialPage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React from 'react';
import {ScrollView, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import {withNetwork} from '@components/OnyxProvider';
import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import usePrivatePersonalDetails from '@hooks/usePrivatePersonalDetails';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import useThemeStyles from '@styles/useThemeStyles';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
const propTypes = {
/* Onyx Props */
/** User's private personal details */
privatePersonalDetails: PropTypes.shape({
legalFirstName: PropTypes.string,
legalLastName: PropTypes.string,
dob: PropTypes.string,
/** User's home address */
address: PropTypes.shape({
street: PropTypes.string,
city: PropTypes.string,
state: PropTypes.string,
zip: PropTypes.string,
country: PropTypes.string,
}),
}),
...withLocalizePropTypes,
};
const defaultProps = {
privatePersonalDetails: {
legalFirstName: '',
legalLastName: '',
dob: '',
address: {
street: '',
street2: '',
city: '',
state: '',
zip: '',
country: '',
},
},
};
function PersonalDetailsInitialPage(props) {
const styles = useThemeStyles();
usePrivatePersonalDetails();
const privateDetails = props.privatePersonalDetails || {};
const legalName = `${privateDetails.legalFirstName || ''} ${privateDetails.legalLastName || ''}`.trim();
const isLoadingPersonalDetails = lodashGet(props.privatePersonalDetails, 'isLoading', true);
return (
<ScreenWrapper testID={PersonalDetailsInitialPage.displayName}>
<HeaderWithBackButton
title={props.translate('privatePersonalDetails.personalDetails')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)}
/>
{isLoadingPersonalDetails ? (
<FullscreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
) : (
<ScrollView>
<View style={styles.flex1}>
<View style={[styles.ph5, styles.mb5]}>
<Text>{props.translate('privatePersonalDetails.privateDataMessage')}</Text>
</View>
<MenuItemWithTopDescription
title={legalName}
description={props.translate('privatePersonalDetails.legalName')}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.SETTINGS_PERSONAL_DETAILS_LEGAL_NAME)}
/>
<MenuItemWithTopDescription
title={privateDetails.dob || ''}
description={props.translate('common.dob')}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.SETTINGS_PERSONAL_DETAILS_DATE_OF_BIRTH)}
titleStyle={[styles.flex1]}
/>
<MenuItemWithTopDescription
title={PersonalDetailsUtils.getFormattedAddress(props.privatePersonalDetails)}
description={props.translate('privatePersonalDetails.address')}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS)}
/>
</View>
</ScrollView>
)}
</ScreenWrapper>
);
}
PersonalDetailsInitialPage.propTypes = propTypes;
PersonalDetailsInitialPage.defaultProps = defaultProps;
PersonalDetailsInitialPage.displayName = 'PersonalDetailsInitialPage';
export default compose(
withLocalize,
withOnyx({
privatePersonalDetails: {
key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS,
},
}),
withNetwork(),
)(PersonalDetailsInitialPage);