2016-09-19 23:43:35 +00:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
2016-10-19 20:22:18 +00:00
|
|
|
|
2016-09-19 23:43:35 +00:00
|
|
|
import componentStyles from './styles';
|
2016-10-03 17:54:22 +00:00
|
|
|
import Button from '../../buttons/Button';
|
2016-10-21 23:13:41 +00:00
|
|
|
import userInterface from '../../../interfaces/user';
|
2016-09-19 23:43:35 +00:00
|
|
|
|
2016-10-27 16:14:30 +00:00
|
|
|
const baseClass = 'logout-form';
|
|
|
|
|
2016-09-19 23:43:35 +00:00
|
|
|
class LogoutForm extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
onSubmit: PropTypes.func,
|
2016-10-21 23:13:41 +00:00
|
|
|
user: userInterface,
|
2016-09-19 23:43:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
onFormSubmit = (evt) => {
|
|
|
|
evt.preventDefault();
|
|
|
|
|
|
|
|
const { onSubmit } = this.props;
|
|
|
|
|
|
|
|
return onSubmit();
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {
|
|
|
|
avatarStyles,
|
|
|
|
containerStyles,
|
|
|
|
formStyles,
|
|
|
|
subtextStyles,
|
|
|
|
usernameStyles,
|
|
|
|
} = componentStyles;
|
|
|
|
const { user } = this.props;
|
|
|
|
const { gravatarURL } = user;
|
|
|
|
const { onFormSubmit } = this;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<form onSubmit={onFormSubmit} style={formStyles}>
|
|
|
|
<div style={containerStyles}>
|
|
|
|
<img alt="Avatar" src={gravatarURL} style={avatarStyles} />
|
|
|
|
<p style={usernameStyles}>{user.username}</p>
|
|
|
|
<p style={subtextStyles}>Are you sure you want to log out?</p>
|
|
|
|
</div>
|
2016-10-03 17:54:22 +00:00
|
|
|
<Button
|
2016-10-27 16:14:30 +00:00
|
|
|
className={`${baseClass}__submit-btn`}
|
2016-09-19 23:43:35 +00:00
|
|
|
onClick={onFormSubmit}
|
|
|
|
text="Logout"
|
|
|
|
type="submit"
|
2016-10-03 17:54:22 +00:00
|
|
|
variant="gradient"
|
2016-09-19 23:43:35 +00:00
|
|
|
/>
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LogoutForm;
|