This repository has been archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
header.tsx
65 lines (63 loc) · 1.55 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from "react"
import { SessionContext } from "gatsby-theme-auth0-ts"
import { Link } from "@reach/router"
import { useStaticQuery, graphql } from "gatsby"
export const Header = () => {
const session = React.useContext(SessionContext)
const {
user,
auth: { authorize, logout },
} = session
const data = useStaticQuery(graphql`
query {
site {
siteMetadata {
title
}
}
}
`)
return (
<header>
<Link to="/" style={{ textDecoration: "none", color: "black" }}>
<h1>{data.site.siteMetadata.title}</h1>
</Link>
<nav>
{user.isLoggedIn ? (
<>
<Link style={{ color: "black" }} to="/account">
Account
</Link>{" "}
<Link style={{ color: "black" }} to="/account/settings">
Settings
</Link>{" "}
<Link style={{ color: "black" }} to="/account/billing">
Billing
</Link>{" "}
<button
style={{
color: "black",
border: "1px solid black",
borderRadius: "3px",
}}
onClick={() => logout()}
>
Log Out
</button>
</>
) : (
<button
style={{
color: "black",
border: "1px solid black",
borderRadius: "3px",
}}
onClick={() => authorize()}
>
Log In
</button>
)}
</nav>
</header>
)
}