-
Notifications
You must be signed in to change notification settings - Fork 19
/
Logout.js
45 lines (37 loc) · 1011 Bytes
/
Logout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Inferno from 'inferno'
import Component from 'inferno-component'
import { connect } from 'inferno-mobx'
import Loading from '../components/common/Loading'
@connect(['store'])
class Logout extends Component {
// When route is loaded (isomorphic)
static onEnter({ state }) {
state.common.title = 'Logout'
}
state = {
loading: false
}
handleLogout = () => {
const { store } = this.props
const { router } = this.context
this.setState({
loading: true
})
new Promise(resolve => setTimeout(resolve, 500))
.then(() => store.account.logout())
.then(() => router.push('/'))
}
render(_, { loading }) {
return <main>
<div className="account">
<h3>Do you want to log out ?</h3>
<p>This will disconnect you and you will have to login again next time.</p>
{loading
? <Loading/>
: <button onClick={this.handleLogout}>Logout</button>
}
</div>
</main>
}
}
export default Logout