2016-03-17 11:31:11 +05:30
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
2017-05-26 00:41:57 +05:30
|
|
|
import { Link } from 'react-router-dom';
|
2016-04-17 15:05:04 +05:30
|
|
|
|
2016-03-17 11:31:11 +05:30
|
|
|
import styles from './profile.scss';
|
|
|
|
|
|
|
|
export default class ProfileField extends Component {
|
|
|
|
static displayName = 'ProfileField';
|
|
|
|
static propTypes = {
|
2016-03-20 14:00:58 +05:30
|
|
|
label: React.PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
|
2016-04-17 15:05:04 +05:30
|
|
|
link: PropTypes.string,
|
2016-05-20 01:11:43 +05:30
|
|
|
onChange: PropTypes.func,
|
2016-03-17 11:31:11 +05:30
|
|
|
value: React.PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
|
2016-05-20 01:11:43 +05:30
|
|
|
warningMessage: React.PropTypes.oneOfType([PropTypes.string, PropTypes.element])
|
2016-03-17 11:31:11 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2016-05-20 01:11:43 +05:30
|
|
|
const {label, value, warningMessage, link, onChange} = this.props;
|
|
|
|
|
|
|
|
let Action = null;
|
|
|
|
|
|
|
|
if (link) {
|
|
|
|
Action = (props) => <Link to={link} {...props} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (onChange) {
|
|
|
|
Action = (props) => <a onClick={onChange} {...props} href="#" />;
|
|
|
|
}
|
2016-03-17 11:31:11 +05:30
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.paramItem}>
|
|
|
|
<div className={styles.paramRow}>
|
|
|
|
<div className={styles.paramName}>{label}:</div>
|
|
|
|
<div className={styles.paramValue}>{value}</div>
|
|
|
|
|
2016-05-20 01:11:43 +05:30
|
|
|
{Action ? (
|
|
|
|
<Action to={link} className={styles.paramAction}>
|
|
|
|
<span className={styles.paramEditIcon} />
|
|
|
|
</Action>
|
|
|
|
) : null}
|
2016-03-17 11:31:11 +05:30
|
|
|
</div>
|
|
|
|
|
|
|
|
{warningMessage ? (
|
|
|
|
<div className={styles.paramMessage}>
|
|
|
|
{warningMessage}
|
|
|
|
</div>
|
|
|
|
) : ''}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|