2021-04-12 13:32:25 +00:00
|
|
|
import React, { Component } from "react";
|
|
|
|
import PropTypes from "prop-types";
|
2016-10-19 20:22:18 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
import Button from "../../buttons/Button";
|
|
|
|
import userInterface from "../../../interfaces/user";
|
2016-09-19 23:43:35 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
const baseClass = "logout-form";
|
2016-10-27 16:14:30 +00:00
|
|
|
|
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();
|
2021-04-12 13:32:25 +00:00
|
|
|
};
|
2016-09-19 23:43:35 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
render() {
|
2016-09-19 23:43:35 +00:00
|
|
|
const { user } = this.props;
|
|
|
|
const { gravatarURL } = user;
|
|
|
|
const { onFormSubmit } = this;
|
|
|
|
|
|
|
|
return (
|
2016-11-03 19:40:54 +00:00
|
|
|
<form onSubmit={onFormSubmit} className={baseClass}>
|
|
|
|
<div className={`${baseClass}__container`}>
|
2021-04-12 13:32:25 +00:00
|
|
|
<img
|
|
|
|
alt="Avatar"
|
|
|
|
src={gravatarURL}
|
|
|
|
className={`${baseClass}__avatar`}
|
|
|
|
/>
|
2016-11-03 19:40:54 +00:00
|
|
|
<p className={`${baseClass}__username`}>{user.username}</p>
|
2021-04-12 13:32:25 +00:00
|
|
|
<p className={`${baseClass}__subtext`}>
|
|
|
|
Are you sure you want to log out?
|
|
|
|
</p>
|
2016-09-19 23:43:35 +00:00
|
|
|
</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}
|
|
|
|
type="submit"
|
2020-12-19 01:36:39 +00:00
|
|
|
variant="brand"
|
2016-12-28 15:24:52 +00:00
|
|
|
>
|
|
|
|
Logout
|
|
|
|
</Button>
|
2016-09-19 23:43:35 +00:00
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LogoutForm;
|