2017-08-22 21:49:50 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2019-12-07 13:28:52 +02:00
|
|
|
import React from 'react';
|
2017-05-25 22:11:57 +03:00
|
|
|
import { Link } from 'react-router-dom';
|
2016-04-17 12:35:04 +03:00
|
|
|
|
2016-03-17 08:01:11 +02:00
|
|
|
import styles from './profile.scss';
|
|
|
|
|
2019-12-07 13:28:52 +02:00
|
|
|
export default class ProfileField extends React.Component {
|
2019-11-27 11:03:32 +02:00
|
|
|
static propTypes = {
|
|
|
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
|
|
|
|
.isRequired,
|
|
|
|
link: PropTypes.string,
|
|
|
|
onChange: PropTypes.func,
|
|
|
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
|
|
|
|
.isRequired,
|
|
|
|
warningMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { label, value, warningMessage, link, onChange } = this.props;
|
|
|
|
|
|
|
|
let Action = null;
|
|
|
|
|
|
|
|
if (link) {
|
|
|
|
Action = props => <Link to={link} {...props} />;
|
2016-03-17 08:01:11 +02:00
|
|
|
}
|
2019-11-27 11:03:32 +02:00
|
|
|
|
|
|
|
if (onChange) {
|
|
|
|
Action = props => <a onClick={onChange} {...props} href="#" />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.paramItem}>
|
|
|
|
<div className={styles.paramRow}>
|
|
|
|
<div className={styles.paramName}>{label}</div>
|
|
|
|
<div className={styles.paramValue}>{value}</div>
|
|
|
|
|
|
|
|
{Action ? (
|
|
|
|
<Action to={link} className={styles.paramAction}>
|
|
|
|
<span className={styles.paramEditIcon} />
|
|
|
|
</Action>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{warningMessage ? (
|
|
|
|
<div className={styles.paramMessage}>{warningMessage}</div>
|
|
|
|
) : (
|
|
|
|
''
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-03-17 08:01:11 +02:00
|
|
|
}
|