use authenticated status
This commit is contained in:
parent
3021032464
commit
dda1e5f122
|
@ -60,6 +60,7 @@
|
||||||
"react-use": "^17.2.3",
|
"react-use": "^17.2.3",
|
||||||
"skynet-js": "^3.0.2",
|
"skynet-js": "^3.0.2",
|
||||||
"stream-browserify": "^3.0.0",
|
"stream-browserify": "^3.0.0",
|
||||||
|
"swr": "^0.5.5",
|
||||||
"tailwindcss": "^2.1.1"
|
"tailwindcss": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import * as React from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import Link from "../Link";
|
import Link from "../Link";
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
|
import useAuthenticatedStatus from "../../services/useAuthenticatedStatus";
|
||||||
import LogoWhiteText from "../Icons/LogoWhiteText.svg";
|
import LogoWhiteText from "../Icons/LogoWhiteText.svg";
|
||||||
import LogoBlackText from "../Icons/LogoBlackText.svg";
|
import LogoBlackText from "../Icons/LogoBlackText.svg";
|
||||||
import MenuMobile from "../Icons/MenuMobile.svg";
|
import MenuMobile from "../Icons/MenuMobile.svg";
|
||||||
|
@ -27,6 +28,7 @@ const Navigation = ({ mode, uri }) => {
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
const windowSize = useWindowSize();
|
const windowSize = useWindowSize();
|
||||||
const isWindowTop = useWindowTop();
|
const isWindowTop = useWindowTop();
|
||||||
|
const { authenticated } = useAuthenticatedStatus();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
@ -85,12 +87,24 @@ const Navigation = ({ mode, uri }) => {
|
||||||
{title}
|
{title}
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
<Link href="https://account.siasky.net" className="button-link-primary">
|
|
||||||
Log in
|
{!authenticated && (
|
||||||
</Link>
|
<Link href="https://account.siasky.net" className="button-link-primary">
|
||||||
<Link href="https://account.siasky.net/auth/registration" className="button-primary">
|
Log in
|
||||||
Sign up
|
</Link>
|
||||||
</Link>
|
)}
|
||||||
|
|
||||||
|
{!authenticated && (
|
||||||
|
<Link href="https://account.siasky.net/auth/registration" className="button-primary">
|
||||||
|
Sign up
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{authenticated && (
|
||||||
|
<Link href="https://account.siasky.net" className="button-primary">
|
||||||
|
Dashboard
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -128,13 +142,23 @@ const Navigation = ({ mode, uri }) => {
|
||||||
</div>
|
</div>
|
||||||
<div className="pt-12 pb-8 border-t border-palette-500">
|
<div className="pt-12 pb-8 border-t border-palette-500">
|
||||||
<div className="flex items-center justify-center px-4 space-x-6">
|
<div className="flex items-center justify-center px-4 space-x-6">
|
||||||
<Link href="https://account.siasky.net" className="button-secondary-light">
|
{!authenticated && (
|
||||||
Log in
|
<Link href="https://account.siasky.net" className="button-secondary-light">
|
||||||
</Link>
|
Log in
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
|
||||||
<Link href="https://account.siasky.net/auth/registration" className="button-primary">
|
{!authenticated && (
|
||||||
Sign up
|
<Link href="https://account.siasky.net/auth/registration" className="button-primary">
|
||||||
</Link>
|
Sign up
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{authenticated && (
|
||||||
|
<Link href="https://account.siasky.net" className="button-primary">
|
||||||
|
Dashboard
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import useSWR from "swr";
|
||||||
|
|
||||||
|
export default function useAuthenticatedStatus() {
|
||||||
|
return useSWR("/__internal/do/not/use", (url) => (await fetch(url)).json());
|
||||||
|
}
|
Reference in New Issue