Switch header on [id] depending on auth
This commit is contained in:
parent
773920bb41
commit
41f0dd5c7a
1 changed files with 11 additions and 3 deletions
|
@ -1,8 +1,9 @@
|
||||||
import { Loading, Page, Text } from "@geist-ui/core";
|
import { Loading, Page, Text } from "@geist-ui/core";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import Document from '../../components/document'
|
import Document from '../../components/document'
|
||||||
import Header from "../../components/header";
|
import Header from "../../components/header";
|
||||||
|
import UnauthenticatedHeader from "../../components/unauthenticated-header";
|
||||||
import VisibilityBadge from "../../components/visibility-badge";
|
import VisibilityBadge from "../../components/visibility-badge";
|
||||||
import { ThemeProps } from "../_app";
|
import { ThemeProps } from "../_app";
|
||||||
|
|
||||||
|
@ -42,12 +43,19 @@ const Post = ({ theme, changeTheme }: ThemeProps) => {
|
||||||
}
|
}
|
||||||
fetchPost()
|
fetchPost()
|
||||||
}, [router, router.query.id])
|
}, [router, router.query.id])
|
||||||
console.log(post, isLoading, error)
|
|
||||||
|
|
||||||
|
const token = useCallback(() => {
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
return localStorage.getItem("drift-token")
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<Page.Header>
|
<Page.Header>
|
||||||
<Header theme={theme} changeTheme={changeTheme} />
|
{token() && <Header theme={theme} changeTheme={changeTheme} />}
|
||||||
|
{!token() && <UnauthenticatedHeader theme={theme} changeTheme={changeTheme} />}
|
||||||
</Page.Header>
|
</Page.Header>
|
||||||
<Page.Content width={"var(--main-content-width)"} margin="auto">
|
<Page.Content width={"var(--main-content-width)"} margin="auto">
|
||||||
{error && <Text type="error">{error}</Text>}
|
{error && <Text type="error">{error}</Text>}
|
||||||
|
|
Loading…
Reference in a new issue