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