f48ae0170b
* sell bet * dev mode * single-pot no-refund payoff; bet selling * Increase default fetch size 25 -> 99 * Fix about page numbering * Don't flash no markets when loading on tag page. * Change Title to use body font * Make a bunch of predictions at once (#9) * Set up a page to make bulk predictions * Integrate preview into the same card * List created predictions * Make changes per James's comments * Increase the starting balance (#11) * Remove references to paying for our Mantic Dollars * Update simulator to use new calculations * Change simulator random to be evenly random again * Sell bet UI * Migrate contracts and bets script * Add comment to script * bets => trades; exclude sold bets * change sale formula * Change current value to uncapped sell value. * Disable sell button while selling * Update some 'bet' to 'trade' Co-authored-by: Austin Chen <akrolsmir@gmail.com> Co-authored-by: jahooma <jahooma@gmail.com>
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
import Image from 'next/image'
|
|
import { firebaseLogout, User } from '../lib/firebase/users'
|
|
import { formatMoney } from '../lib/util/format'
|
|
import { Row } from './layout/row'
|
|
import { MenuButton } from './menu'
|
|
|
|
export function ProfileMenu(props: { user: User }) {
|
|
const { user } = props
|
|
|
|
return (
|
|
<>
|
|
<MenuButton
|
|
className="hidden md:block"
|
|
menuItems={getNavigationOptions(user, { mobile: false })}
|
|
buttonContent={<ProfileSummary user={user} />}
|
|
/>
|
|
|
|
<MenuButton
|
|
className="md:hidden"
|
|
menuItems={getNavigationOptions(user, { mobile: true })}
|
|
buttonContent={<ProfileSummary user={user} />}
|
|
/>
|
|
</>
|
|
)
|
|
}
|
|
|
|
function getNavigationOptions(user: User, options: { mobile: boolean }) {
|
|
const { mobile } = options
|
|
return [
|
|
{
|
|
name: 'Home',
|
|
href: '/',
|
|
},
|
|
...(mobile
|
|
? [
|
|
{ name: 'About', href: '/about' },
|
|
{
|
|
name: 'Create a market',
|
|
href: '/create',
|
|
},
|
|
]
|
|
: []),
|
|
{
|
|
name: 'Your trades',
|
|
href: '/trades',
|
|
},
|
|
{
|
|
name: 'Your markets',
|
|
href: `/${user.username}`,
|
|
},
|
|
|
|
{
|
|
name: 'Sign out',
|
|
href: '#',
|
|
onClick: () => firebaseLogout(),
|
|
},
|
|
]
|
|
}
|
|
|
|
function ProfileSummary(props: { user: User }) {
|
|
const { user } = props
|
|
return (
|
|
<Row className="avatar items-center">
|
|
<div className="rounded-full w-10 h-10 mr-4">
|
|
<Image src={user.avatarUrl} width={40} height={40} />
|
|
</div>
|
|
<div className="truncate text-left" style={{ maxWidth: 175 }}>
|
|
{user.name}
|
|
<div className="text-gray-700 text-sm">{formatMoney(user.balance)}</div>
|
|
</div>
|
|
</Row>
|
|
)
|
|
}
|