Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NO-QA] Refactor duplicated personalDetailsPropTypes #5929

Merged
merged 3 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/pages/NewChatPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,14 @@ import ScreenWrapper from '../components/ScreenWrapper';
import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator';
import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
import compose from '../libs/compose';

const personalDetailsPropTypes = PropTypes.shape({
/** The login of the person (either email or phone number) */
login: PropTypes.string.isRequired,

/** The URL of the person's avatar (there should already be a default avatar if
the person doesn't have their own avatar uploaded yet) */
avatar: PropTypes.string.isRequired,

/** This is either the user's full name, or their login if full name is an empty string */
displayName: PropTypes.string.isRequired,

...withLocalizePropTypes,
});
import personalDetailsPropType from './personalDetailsPropType';

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

/** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
personalDetails: personalDetailsPropType.isRequired,

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

...windowDimensionsPropTypes,

...withLocalizePropTypes,
};

class NewChatPage extends Component {
Expand Down
15 changes: 2 additions & 13 deletions src/pages/NewGroupPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,14 @@ import compose from '../libs/compose';
import Button from '../components/Button';
import KeyboardAvoidingView from '../components/KeyboardAvoidingView';
import FixedFooter from '../components/FixedFooter';

const personalDetailsPropTypes = PropTypes.shape({
/** The login of the person (either email or phone number) */
login: PropTypes.string.isRequired,

/** The URL of the person's avatar (there should already be a default avatar if
the person doesn't have their own avatar uploaded yet) */
avatar: PropTypes.string.isRequired,

/** This is either the user's full name, or their login if full name is an empty string */
displayName: PropTypes.string.isRequired,
});
import personalDetailsPropType from './personalDetailsPropType';

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

/** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
personalDetails: personalDetailsPropType.isRequired,

/** All reports shared with the user */
reports: PropTypes.shape({
Expand Down
15 changes: 2 additions & 13 deletions src/pages/SearchPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,7 @@ import CONST from '../CONST';
import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator';
import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
import compose from '../libs/compose';

const personalDetailsPropTypes = PropTypes.shape({
/** The login of the person (either email or phone number) */
login: PropTypes.string.isRequired,

/** The URL of the person's avatar (there should already be a default avatar if
the person doesn't have their own avatar uploaded yet) */
avatar: PropTypes.string.isRequired,

/** This is either the user's full name, or their login if full name is an empty string */
displayName: PropTypes.string.isRequired,
});
import personalDetailsPropType from './personalDetailsPropType';

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

/** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
personalDetails: personalDetailsPropType.isRequired,

/** All reports shared with the user */
reports: PropTypes.shape({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ import ONYXKEYS from '../../../../ONYXKEYS';
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize';
import compose from '../../../../libs/compose';
import {EXCLUDED_IOU_EMAILS} from '../../../../CONST';

const personalDetailsPropTypes = PropTypes.shape({
/** The login of the person (either email or phone number) */
login: PropTypes.string.isRequired,

/** The URL of the person's avatar (there should already be a default avatar if the person doesn't have
* their own avatar uploaded yet) */
avatar: PropTypes.string.isRequired,

/** This is either the user's full name, or their login if full name is an empty string */
displayName: PropTypes.string.isRequired,
});
import personalDetailsPropType from '../../../personalDetailsPropType';

const propTypes = {
/** Beta features list */
Expand All @@ -32,7 +21,7 @@ const propTypes = {
onAddParticipants: PropTypes.func.isRequired,

/** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
personalDetails: PropTypes.objectOf(personalDetailsPropType).isRequired,

/** All reports shared with the user */
reports: PropTypes.shape({
Expand Down
15 changes: 2 additions & 13 deletions src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@ import compose from '../../../../libs/compose';
import Button from '../../../../components/Button';
import Text from '../../../../components/Text';
import FixedFooter from '../../../../components/FixedFooter';

const personalDetailsPropTypes = PropTypes.shape({
// The login of the person (either email or phone number)
login: PropTypes.string.isRequired,

// The URL of the person's avatar (there should already be a default avatar if
// the person doesn't have their own avatar uploaded yet)
avatar: PropTypes.string.isRequired,

// This is either the user's full name, or their login if full name is an empty string
displayName: PropTypes.string.isRequired,
});
import personalDetailsPropType from '../../../personalDetailsPropType';

const propTypes = {
/** Beta features list */
Expand All @@ -51,7 +40,7 @@ const propTypes = {
})),

/** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
personalDetails: PropTypes.objectOf(personalDetailsPropType).isRequired,

/** All reports shared with the user */
reports: PropTypes.shape({
Expand Down