-
Notifications
You must be signed in to change notification settings - Fork 0
/
Header.tsx
47 lines (42 loc) · 1.03 KB
/
Header.tsx
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
46
47
import React from 'react';
import { Link } from 'gatsby';
import { css } from '@emotion/core';
import { rhythm } from '../utils/typography';
import { navigate } from '@reach/router';
import { logout, isLoggedIn } from '../utils/auth';
interface Props {
siteTitle: string;
}
export default function Header({ siteTitle }: Props) {
return (
<>
<Link to="/">
<h1
css={css`
display: inline-block;
font-style: normal;
`}
>
{siteTitle}
</h1>
</Link>
{isLoggedIn() && (
<a
onClick={async () => {
const { Auth } = await import('aws-amplify');
Auth.signOut()
.then(() => logout(() => navigate('/backend')))
// tslint:disable-next-line:no-console
.catch((err: string) => console.log('eror:', err));
}}
css={css`
margin-top: ${rhythm(1.5)};
float: right;
`}
>
Sign Out
</a>
)}
</>
);
}