Skip to content

Commit

Permalink
refactor: resolved lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalQamar95 committed Apr 23, 2024
1 parent 9292d9d commit 90be951
Showing 1 changed file with 102 additions and 102 deletions.
204 changes: 102 additions & 102 deletions src/profile/forms/SocialLinks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,108 @@ const platformDisplayInfo = {
},
};

const SocialLink = ({ url, name, platform }) => (
<a href={url} className="font-weight-bold">
<FontAwesomeIcon className="mr-2" icon={platformDisplayInfo[platform].icon} />
{name}
</a>
);

SocialLink.propTypes = {
url: PropTypes.string.isRequired,
platform: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
};

const EditableListItem = ({
url, platform, onClickEmptyContent, name,
}) => {
const linkDisplay = url ? (
<SocialLink name={name} url={url} platform={platform} />
) : (
<EmptyContent onClick={onClickEmptyContent}>Add {name}</EmptyContent>
);

return <li className="form-group">{linkDisplay}</li>;
};

EditableListItem.propTypes = {
url: PropTypes.string,
platform: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
onClickEmptyContent: PropTypes.func,
};
EditableListItem.defaultProps = {
url: null,
onClickEmptyContent: null,
};

const EditingListItem = ({
platform, name, value, onChange, error,
}) => (
<li className="form-group">
<label htmlFor={`social-${platform}`}>{name}</label>
<input
className={classNames('form-control', { 'is-invalid': Boolean(error) })}
type="text"
id={`social-${platform}`}
name={platform}
value={value || ''}
onChange={onChange}
aria-describedby="social-error-feedback"
/>
</li>
);

EditingListItem.propTypes = {
platform: PropTypes.string.isRequired,
value: PropTypes.string,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
error: PropTypes.string,
};

EditingListItem.defaultProps = {
value: null,
error: null,
};

const EmptyListItem = ({ onClick, name }) => (
<li className="mb-4">
<EmptyContent onClick={onClick}>
<FormattedMessage
id="profile.sociallinks.add"
defaultMessage="Add {network}"
values={{
network: name,
}}
description="{network} is the name of a social network such as Facebook or Twitter"
/>
</EmptyContent>
</li>
);

EmptyListItem.propTypes = {
name: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
};

const StaticListItem = ({ name, url, platform }) => (
<li className="mb-2">
<SocialLink name={name} url={url} platform={platform} />
</li>
);

StaticListItem.propTypes = {
name: PropTypes.string.isRequired,
url: PropTypes.string,
platform: PropTypes.string.isRequired,
};

StaticListItem.defaultProps = {
url: null,
};

class SocialLinks extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -243,105 +345,3 @@ export default connect(
editableFormSelector,
{},
)(injectIntl(SocialLinks));

const SocialLink = ({ url, name, platform }) => (
<a href={url} className="font-weight-bold">
<FontAwesomeIcon className="mr-2" icon={platformDisplayInfo[platform].icon} />
{name}
</a>
);

SocialLink.propTypes = {
url: PropTypes.string.isRequired,
platform: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
};

const EditableListItem = ({
url, platform, onClickEmptyContent, name,
}) => {
const linkDisplay = url ? (
<SocialLink name={name} url={url} platform={platform} />
) : (
<EmptyContent onClick={onClickEmptyContent}>Add {name}</EmptyContent>
);

return <li className="form-group">{linkDisplay}</li>;
};

EditableListItem.propTypes = {
url: PropTypes.string,
platform: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
onClickEmptyContent: PropTypes.func,
};
EditableListItem.defaultProps = {
url: null,
onClickEmptyContent: null,
};

const EditingListItem = ({
platform, name, value, onChange, error,
}) => (
<li className="form-group">
<label htmlFor={`social-${platform}`}>{name}</label>
<input
className={classNames('form-control', { 'is-invalid': Boolean(error) })}
type="text"
id={`social-${platform}`}
name={platform}
value={value || ''}
onChange={onChange}
aria-describedby="social-error-feedback"
/>
</li>
);

EditingListItem.propTypes = {
platform: PropTypes.string.isRequired,
value: PropTypes.string,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
error: PropTypes.string,
};

EditingListItem.defaultProps = {
value: null,
error: null,
};

const EmptyListItem = ({ onClick, name }) => (
<li className="mb-4">
<EmptyContent onClick={onClick}>
<FormattedMessage
id="profile.sociallinks.add"
defaultMessage="Add {network}"
values={{
network: name,
}}
description="{network} is the name of a social network such as Facebook or Twitter"
/>
</EmptyContent>
</li>
);

EmptyListItem.propTypes = {
name: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
};

const StaticListItem = ({ name, url, platform }) => (
<li className="mb-2">
<SocialLink name={name} url={url} platform={platform} />
</li>
);

StaticListItem.propTypes = {
name: PropTypes.string.isRequired,
url: PropTypes.string,
platform: PropTypes.string.isRequired,
};

StaticListItem.defaultProps = {
url: null,
};

0 comments on commit 90be951

Please sign in to comment.