Skip to content

Commit 1545c82

Browse files
authored
Merge pull request #5929 from Expensify/jules-refactorPersonalDetailsPropType
[NO-QA] Refactor duplicated personalDetailsPropTypes
2 parents a5f2739 + 37dd760 commit 1545c82

File tree

5 files changed

+12
-67
lines changed

5 files changed

+12
-67
lines changed

src/pages/NewChatPage.js

+4-15
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,14 @@ import ScreenWrapper from '../components/ScreenWrapper';
1616
import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator';
1717
import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
1818
import compose from '../libs/compose';
19-
20-
const personalDetailsPropTypes = PropTypes.shape({
21-
/** The login of the person (either email or phone number) */
22-
login: PropTypes.string.isRequired,
23-
24-
/** The URL of the person's avatar (there should already be a default avatar if
25-
the person doesn't have their own avatar uploaded yet) */
26-
avatar: PropTypes.string.isRequired,
27-
28-
/** This is either the user's full name, or their login if full name is an empty string */
29-
displayName: PropTypes.string.isRequired,
30-
31-
...withLocalizePropTypes,
32-
});
19+
import personalDetailsPropType from './personalDetailsPropType';
3320

3421
const propTypes = {
3522
/** Beta features list */
3623
betas: PropTypes.arrayOf(PropTypes.string).isRequired,
3724

3825
/** All of the personal details for everyone */
39-
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
26+
personalDetails: personalDetailsPropType.isRequired,
4027

4128
/** All reports shared with the user */
4229
reports: PropTypes.shape({
@@ -50,6 +37,8 @@ const propTypes = {
5037
}).isRequired,
5138

5239
...windowDimensionsPropTypes,
40+
41+
...withLocalizePropTypes,
5342
};
5443

5544
class NewChatPage extends Component {

src/pages/NewGroupPage.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,14 @@ import compose from '../libs/compose';
1919
import Button from '../components/Button';
2020
import KeyboardAvoidingView from '../components/KeyboardAvoidingView';
2121
import FixedFooter from '../components/FixedFooter';
22-
23-
const personalDetailsPropTypes = PropTypes.shape({
24-
/** The login of the person (either email or phone number) */
25-
login: PropTypes.string.isRequired,
26-
27-
/** The URL of the person's avatar (there should already be a default avatar if
28-
the person doesn't have their own avatar uploaded yet) */
29-
avatar: PropTypes.string.isRequired,
30-
31-
/** This is either the user's full name, or their login if full name is an empty string */
32-
displayName: PropTypes.string.isRequired,
33-
});
22+
import personalDetailsPropType from './personalDetailsPropType';
3423

3524
const propTypes = {
3625
/** Beta features list */
3726
betas: PropTypes.arrayOf(PropTypes.string).isRequired,
3827

3928
/** All of the personal details for everyone */
40-
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
29+
personalDetails: personalDetailsPropType.isRequired,
4130

4231
/** All reports shared with the user */
4332
reports: PropTypes.shape({

src/pages/SearchPage.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,7 @@ import CONST from '../CONST';
1919
import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator';
2020
import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
2121
import compose from '../libs/compose';
22-
23-
const personalDetailsPropTypes = PropTypes.shape({
24-
/** The login of the person (either email or phone number) */
25-
login: PropTypes.string.isRequired,
26-
27-
/** The URL of the person's avatar (there should already be a default avatar if
28-
the person doesn't have their own avatar uploaded yet) */
29-
avatar: PropTypes.string.isRequired,
30-
31-
/** This is either the user's full name, or their login if full name is an empty string */
32-
displayName: PropTypes.string.isRequired,
33-
});
22+
import personalDetailsPropType from './personalDetailsPropType';
3423

3524
const propTypes = {
3625
/* Onyx Props */
@@ -39,7 +28,7 @@ const propTypes = {
3928
betas: PropTypes.arrayOf(PropTypes.string).isRequired,
4029

4130
/** All of the personal details for everyone */
42-
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
31+
personalDetails: personalDetailsPropType.isRequired,
4332

4433
/** All reports shared with the user */
4534
reports: PropTypes.shape({

src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,7 @@ import ONYXKEYS from '../../../../ONYXKEYS';
88
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize';
99
import compose from '../../../../libs/compose';
1010
import {EXCLUDED_IOU_EMAILS} from '../../../../CONST';
11-
12-
const personalDetailsPropTypes = PropTypes.shape({
13-
/** The login of the person (either email or phone number) */
14-
login: PropTypes.string.isRequired,
15-
16-
/** The URL of the person's avatar (there should already be a default avatar if the person doesn't have
17-
* their own avatar uploaded yet) */
18-
avatar: PropTypes.string.isRequired,
19-
20-
/** This is either the user's full name, or their login if full name is an empty string */
21-
displayName: PropTypes.string.isRequired,
22-
});
11+
import personalDetailsPropType from '../../../personalDetailsPropType';
2312

2413
const propTypes = {
2514
/** Beta features list */
@@ -32,7 +21,7 @@ const propTypes = {
3221
onAddParticipants: PropTypes.func.isRequired,
3322

3423
/** All of the personal details for everyone */
35-
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
24+
personalDetails: PropTypes.objectOf(personalDetailsPropType).isRequired,
3625

3726
/** All reports shared with the user */
3827
reports: PropTypes.shape({

src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,7 @@ import compose from '../../../../libs/compose';
1313
import Button from '../../../../components/Button';
1414
import Text from '../../../../components/Text';
1515
import FixedFooter from '../../../../components/FixedFooter';
16-
17-
const personalDetailsPropTypes = PropTypes.shape({
18-
// The login of the person (either email or phone number)
19-
login: PropTypes.string.isRequired,
20-
21-
// The URL of the person's avatar (there should already be a default avatar if
22-
// the person doesn't have their own avatar uploaded yet)
23-
avatar: PropTypes.string.isRequired,
24-
25-
// This is either the user's full name, or their login if full name is an empty string
26-
displayName: PropTypes.string.isRequired,
27-
});
16+
import personalDetailsPropType from '../../../personalDetailsPropType';
2817

2918
const propTypes = {
3019
/** Beta features list */
@@ -51,7 +40,7 @@ const propTypes = {
5140
})),
5241

5342
/** All of the personal details for everyone */
54-
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
43+
personalDetails: PropTypes.objectOf(personalDetailsPropType).isRequired,
5544

5645
/** All reports shared with the user */
5746
reports: PropTypes.shape({

0 commit comments

Comments
 (0)