From 41f0dd5c7a7366375d3c5f44d3d8160b5cc8a5e6 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Sun, 6 Mar 2022 22:23:39 -0800 Subject: [PATCH] Switch header on [id] depending on auth --- client/pages/post/[id].tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/pages/post/[id].tsx b/client/pages/post/[id].tsx index e2e28048..5a99b977 100644 --- a/client/pages/post/[id].tsx +++ b/client/pages/post/[id].tsx @@ -1,8 +1,9 @@ import { Loading, Page, Text } from "@geist-ui/core"; import { useRouter } from "next/router"; -import { useEffect, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import Document from '../../components/document' import Header from "../../components/header"; +import UnauthenticatedHeader from "../../components/unauthenticated-header"; import VisibilityBadge from "../../components/visibility-badge"; import { ThemeProps } from "../_app"; @@ -42,12 +43,19 @@ const Post = ({ theme, changeTheme }: ThemeProps) => { } fetchPost() }, [router, router.query.id]) - console.log(post, isLoading, error) + const token = useCallback(() => { + if (typeof window !== "undefined") { + return localStorage.getItem("drift-token") + } else { + return "" + } + }, []) return ( -
+ {token() &&
} + {!token() && } {error && {error}}