fathom/assets/js/components/LogoutButton.js

26 lines
459 B
JavaScript
Raw Normal View History

2016-11-23 18:40:35 +00:00
'use strict';
import { h, render, Component } from 'preact';
import Client from '../lib/client.js';
import { bind } from 'decko';
2016-11-23 18:40:35 +00:00
class LogoutButton extends Component {
@bind
2016-11-23 18:40:35 +00:00
handleSubmit(e) {
e.preventDefault();
Client.request('session', {
2016-11-23 18:40:35 +00:00
method: "DELETE",
}).then((r) => { this.props.onSuccess() })
2016-11-23 18:40:35 +00:00
}
render() {
return (
<a href="#" onClick={this.handleSubmit}>Sign out</a>
)
}
}
export default LogoutButton