From 97fa5fa636d1b66020d169d91b84248f968932cc Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Wed, 17 Aug 2022 23:15:25 -0700 Subject: [PATCH] Replace `/markets` with `/home` (#766) * Make /home not kick out logged out users * Point people at /home instead of /markets --- web/components/nav/nav-bar.tsx | 2 +- web/components/nav/sidebar.tsx | 4 ++-- web/pages/home.tsx | 15 +++++++++------ web/pages/index.tsx | 6 ------ web/pages/markets.tsx | 19 ------------------- web/public/sitemap-0.xml | 4 ++-- 6 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 web/pages/markets.tsx diff --git a/web/components/nav/nav-bar.tsx b/web/components/nav/nav-bar.tsx index a935173a..680b8946 100644 --- a/web/components/nav/nav-bar.tsx +++ b/web/components/nav/nav-bar.tsx @@ -33,7 +33,7 @@ function getNavigation() { const signedOutNavigation = [ { name: 'Home', href: '/', icon: HomeIcon }, - { name: 'Explore', href: '/markets', icon: SearchIcon }, + { name: 'Explore', href: '/home', icon: SearchIcon }, ] // From https://codepen.io/chris__sev/pen/QWGvYbL diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index dfb7805e..6c4addc4 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -99,8 +99,8 @@ function getMoreNavigation(user?: User | null) { } const signedOutNavigation = [ - { name: 'Home', href: '/home', icon: HomeIcon }, - { name: 'Explore', href: '/markets', icon: SearchIcon }, + { name: 'Home', href: '/', icon: HomeIcon }, + { name: 'Explore', href: '/home', icon: SearchIcon }, { name: 'About', href: 'https://docs.manifold.markets/$how-to', diff --git a/web/pages/home.tsx b/web/pages/home.tsx index 1fd163ea..8153baea 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -12,15 +12,18 @@ import { getContractFromSlug } from 'web/lib/firebase/contracts' import { getUserAndPrivateUser } from 'web/lib/firebase/users' import { useTracking } from 'web/hooks/use-tracking' import { track } from 'web/lib/service/analytics' -import { redirectIfLoggedOut } from 'web/lib/firebase/server-auth' +import { authenticateOnServer } from 'web/lib/firebase/server-auth' import { useSaveReferral } from 'web/hooks/use-save-referral' +import { GetServerSideProps } from 'next' -export const getServerSideProps = redirectIfLoggedOut('/', async (_, creds) => { - return { props: { auth: await getUserAndPrivateUser(creds.user.uid) } } -}) +export const getServerSideProps: GetServerSideProps = async (ctx) => { + const creds = await authenticateOnServer(ctx) + const auth = creds ? await getUserAndPrivateUser(creds.user.uid) : null + return { props: { auth } } +} -const Home = (props: { auth: { user: User } }) => { - const { user } = props.auth +const Home = (props: { auth: { user: User } | null }) => { + const user = props.auth ? props.auth.user : null const [contract, setContract] = useContractPage() const router = useRouter() diff --git a/web/pages/index.tsx b/web/pages/index.tsx index 01c24fcf..4013f57a 100644 --- a/web/pages/index.tsx +++ b/web/pages/index.tsx @@ -30,12 +30,6 @@ export default function Home(props: { hotContracts: Contract[] }) { - {/*

- View{' '} - - all markets - -

*/} diff --git a/web/pages/markets.tsx b/web/pages/markets.tsx deleted file mode 100644 index c42364d5..00000000 --- a/web/pages/markets.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { useUser } from 'web/hooks/use-user' -import { ContractSearch } from '../components/contract-search' -import { Page } from '../components/page' -import { SEO } from '../components/SEO' - -// TODO: Rename endpoint to "Explore" -export default function Markets() { - const user = useUser() - return ( - - - - - ) -} diff --git a/web/public/sitemap-0.xml b/web/public/sitemap-0.xml index 3b4618fb..d0750f46 100644 --- a/web/public/sitemap-0.xml +++ b/web/public/sitemap-0.xml @@ -1,6 +1,6 @@ https://manifold.marketshourly1.0 -https://manifold.markets/marketshourly0.2 +https://manifold.markets/homehourly0.2 https://manifold.markets/leaderboardsdaily0.2 - \ No newline at end of file +