push
github
169 of 420 branches covered (0.0%)
Branch coverage included in aggregate %.
131 of 131 new or added lines in 15 files covered. (100.0%)
6773 of 14610 relevant lines covered (46.36%)
0.74 hits per line
1 |
/* eslint-env browser */
|
1✔ |
2 |
import { Component, html, render, useEffect } from 'uland-isomorphic' |
1✔ |
3 |
import { useUser } from '../hooks/useUser.js' |
1✔ |
4 |
import { useLSP } from '../hooks/useLSP.js' |
1✔ |
5 |
|
1✔ |
6 |
export const page = Component(() => {
|
|
7 |
const state = useLSP() |
1✔ |
8 |
const { user } = useUser() |
1✔ |
9 |
|
1✔ |
10 |
useEffect(() => { |
1✔ |
11 |
const logout = async () => { |
× |
12 |
try {
|
× |
13 |
await fetch(`${state.apiUrl}/logout`, { |
× |
14 |
method: 'post' |
× |
15 |
}) |
× |
16 |
} finally {
|
× |
17 |
state.user = null
|
× |
18 |
window.location.replace('/')
|
× |
19 |
} |
× |
20 |
} |
× |
21 |
|
× |
22 |
logout().catch(err => {
|
× |
23 |
console.error(err) |
× |
24 |
}) |
× |
25 |
}, []) |
1✔ |
26 |
|
1✔ |
27 |
return html` |
1✔ |
28 |
${!user
|
1✔ |
29 |
? html`
|
1✔ |
30 |
<div>
|
1✔ |
31 |
Logged out |
1✔ |
32 |
</div>
|
1✔ |
33 |
`
|
1✔ |
34 |
: html`
|
|
35 |
<div>
|
× |
36 |
Logging out of ${user.username} |
× |
37 |
</div>
|
× |
38 |
`
|
× |
39 |
} |
× |
40 |
`
|
1✔ |
41 |
}) |
1✔ |
42 |
|
1✔ |
43 |
if (typeof window !== 'undefined') { |
|
44 |
render(document.querySelector('.bc-main'), page)
|
× |
45 |
} |
× |