Portfolio page! Add to sidebar when signed in, move about into more.

This commit is contained in:
James Grugett 2022-04-03 15:48:25 -05:00
parent 5dcd43f5b2
commit d7b702fe00
5 changed files with 44 additions and 18 deletions

View File

@ -17,10 +17,10 @@ export function getNavigationOptions(user?: User | null) {
}
return [
{ name: 'Your trades', href: '/trades' },
{ name: 'Add funds', href: '/add-funds' },
{ name: 'Leaderboards', href: '/leaderboards' },
{ name: 'Discord', href: 'https://discord.gg/eHQBNBqXuh' },
{ name: 'About', href: 'https://docs.manifold.markets' },
{ name: 'Sign out', href: '#', onClick: () => firebaseLogout() },
]
}

View File

@ -3,6 +3,7 @@ import {
UserGroupIcon,
SearchIcon,
BookOpenIcon,
TableIcon,
DotsHorizontalIcon,
} from '@heroicons/react/outline'
import clsx from 'clsx'
@ -17,6 +18,12 @@ import { MenuButton } from './menu'
import { getNavigationOptions, ProfileSummary } from './profile-menu'
const navigation = [
{ name: 'Home', href: '/home', icon: HomeIcon },
{ name: 'Markets', href: '/markets', icon: SearchIcon },
{ name: 'Portfolio', href: '/portfolio', icon: TableIcon },
]
const signedOutNavigation = [
{ name: 'Home', href: '/home', icon: HomeIcon },
{ name: 'Markets', href: '/markets', icon: SearchIcon },
{ name: 'About', href: 'https://docs.manifold.markets', icon: BookOpenIcon },
@ -76,6 +83,8 @@ export default function Sidebar() {
let folds = useFollowedFolds(user) || []
folds = _.sortBy(folds, 'followCount').reverse()
const navigationOptions = user === null ? signedOutNavigation : navigation
return (
<nav
aria-label="Sidebar"
@ -107,7 +116,7 @@ export default function Sidebar() {
</div>
<div className="space-y-1 py-6">
{navigation.map((item) => (
{navigationOptions.map((item) => (
<SidebarItem key={item.name} item={item} currentPage={currentPage} />
))}

24
web/pages/portfolio.tsx Normal file
View File

@ -0,0 +1,24 @@
import Router from 'next/router'
import { useEffect } from 'react'
import { BetsList } from '../components/bets-list'
import { Page } from '../components/page'
import { SEO } from '../components/SEO'
import { Title } from '../components/title'
import { useUser } from '../hooks/use-user'
export default function PortfolioPage() {
const user = useUser()
useEffect(() => {
if (user === null) Router.replace('/')
})
return (
<Page>
<SEO title="Portfolio" description="Portfolio" url="/portfolio" />
<Title className="mx-4 md:mx-0" text="Portfolio" />
{user && <BetsList user={user} />}
</Page>
)
}

View File

@ -1,24 +1,17 @@
import Router from 'next/router'
import { useEffect } from 'react'
import { BetsList } from '../components/bets-list'
import { Page } from '../components/page'
import { SEO } from '../components/SEO'
import { Title } from '../components/title'
import { useUser } from '../hooks/use-user'
// Deprecated: redirects to /portfolio.
// Eventually, this will be removed.
export default function TradesPage() {
const user = useUser()
if (user === null) {
Router.replace('/')
return <></>
}
useEffect(() => {
if (user === null) Router.replace('/')
else Router.replace('/portfolio')
})
return (
<Page>
<SEO title="Your trades" description="Your trades" url="/trades" />
<Title className="mx-4 md:mx-0" text="Your trades" />
{user && <BetsList user={user} />}
</Page>
)
return <></>
}

View File

@ -15,5 +15,5 @@
<url><loc>https://manifold.markets/markets</loc><changefreq>hourly</changefreq><priority>0.7</priority><lastmod>2022-03-24T16:51:19.526Z</lastmod></url>
<url><loc>https://manifold.markets/profile</loc><changefreq>hourly</changefreq><priority>0.7</priority><lastmod>2022-03-24T16:51:19.526Z</lastmod></url>
<url><loc>https://manifold.markets/simulator</loc><changefreq>hourly</changefreq><priority>0.7</priority><lastmod>2022-03-24T16:51:19.526Z</lastmod></url>
<url><loc>https://manifold.markets/trades</loc><changefreq>hourly</changefreq><priority>0.7</priority><lastmod>2022-03-24T16:51:19.526Z</lastmod></url>
<url><loc>https://manifold.markets/portfolio</loc><changefreq>hourly</changefreq><priority>0.7</priority><lastmod>2022-03-24T16:51:19.526Z</lastmod></url>
</urlset>