2021-12-13 18:20:31 +00:00
|
|
|
import { firebaseLogin, firebaseLogout, User } from '../lib/firebase/users'
|
2021-12-09 01:57:59 +00:00
|
|
|
import { Header } from '../components/header'
|
2021-12-09 23:37:26 +00:00
|
|
|
import { useUser } from '../hooks/use-user'
|
2021-12-10 17:54:16 +00:00
|
|
|
import { ContractsList } from '../components/contracts-list'
|
2021-12-11 03:35:21 +00:00
|
|
|
import { Title } from '../components/title'
|
2021-12-14 01:29:02 +00:00
|
|
|
import { Row } from '../components/layout/row'
|
2021-12-14 17:35:11 +00:00
|
|
|
import { formatMoney } from '../lib/util/format'
|
2021-12-15 07:41:50 +00:00
|
|
|
import { BetsList } from '../components/bets-list'
|
|
|
|
import { Spacer } from '../components/layout/spacer'
|
2021-12-09 01:57:59 +00:00
|
|
|
|
2021-12-13 18:20:31 +00:00
|
|
|
function UserCard(props: { user: User }) {
|
|
|
|
const { user } = props
|
|
|
|
return (
|
2021-12-14 01:29:02 +00:00
|
|
|
<Row className="card glass lg:card-side shadow-xl hover:shadow-xl text-neutral-content bg-green-600 hover:bg-green-600 transition-all max-w-sm mx-auto my-12">
|
|
|
|
<div className="p-4">
|
2021-12-13 18:20:31 +00:00
|
|
|
{user?.avatarUrl && (
|
2021-12-14 07:30:09 +00:00
|
|
|
<img
|
|
|
|
src={user.avatarUrl}
|
|
|
|
className="rounded-lg shadow-lg"
|
|
|
|
width={96}
|
|
|
|
height={96}
|
|
|
|
/>
|
2021-12-13 18:20:31 +00:00
|
|
|
)}
|
2021-12-14 01:29:02 +00:00
|
|
|
</div>
|
2021-12-13 18:20:31 +00:00
|
|
|
<div className="max-w-md card-body">
|
|
|
|
<h2 className="card-title font-major-mono">{user?.name}</h2>
|
|
|
|
<p>{user?.email}</p>
|
2021-12-14 17:35:11 +00:00
|
|
|
<p>{formatMoney(user?.balance)}</p>
|
2021-12-13 18:20:31 +00:00
|
|
|
<div className="card-actions">
|
|
|
|
<button
|
|
|
|
className="btn glass rounded-full hover:bg-green-500"
|
|
|
|
onClick={firebaseLogout}
|
|
|
|
>
|
|
|
|
Sign Out
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-12-14 01:29:02 +00:00
|
|
|
</Row>
|
2021-12-13 18:20:31 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function SignInCard() {
|
|
|
|
return (
|
|
|
|
<div className="card glass lg:card-side shadow-xl hover:shadow-xl text-neutral-content bg-green-600 hover:bg-green-600 transition-all max-w-sm mx-auto my-12">
|
2021-12-14 01:29:02 +00:00
|
|
|
<div className="p-4">
|
2021-12-13 18:20:31 +00:00
|
|
|
<img
|
|
|
|
src="/logo-icon-white-bg.png"
|
|
|
|
className="rounded-lg shadow-lg w-20 h-20"
|
|
|
|
/>
|
2021-12-14 01:29:02 +00:00
|
|
|
</div>
|
2021-12-13 18:20:31 +00:00
|
|
|
<div className="max-w-md card-body">
|
|
|
|
<h2 className="card-title font-major-mono">Welcome!</h2>
|
|
|
|
<p>Sign in to get started</p>
|
|
|
|
<div className="card-actions">
|
|
|
|
<button
|
|
|
|
className="btn glass rounded-full hover:bg-green-500"
|
|
|
|
onClick={firebaseLogin}
|
|
|
|
>
|
|
|
|
Sign in with Google
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-12-09 01:57:59 +00:00
|
|
|
export default function Account() {
|
2021-12-09 23:37:26 +00:00
|
|
|
const user = useUser()
|
2021-12-09 01:57:59 +00:00
|
|
|
|
|
|
|
return (
|
2021-12-10 18:07:38 +00:00
|
|
|
<div>
|
2021-12-09 01:57:59 +00:00
|
|
|
<Header />
|
2021-12-14 01:29:02 +00:00
|
|
|
<div className="max-w-4xl pt-8 pb-0 sm:pb-8 mx-auto">
|
2021-12-13 18:20:31 +00:00
|
|
|
{user ? (
|
|
|
|
<div>
|
|
|
|
<UserCard user={user} />
|
2021-12-15 07:41:50 +00:00
|
|
|
|
2021-12-14 01:29:02 +00:00
|
|
|
<Title className="px-2" text="Your markets" />
|
2021-12-14 07:05:33 +00:00
|
|
|
<ContractsList />
|
2021-12-15 07:41:50 +00:00
|
|
|
|
|
|
|
<Spacer h={4} />
|
|
|
|
|
|
|
|
<Title className="px-2" text="Your bets" />
|
|
|
|
<BetsList user={user} />
|
2021-12-09 01:57:59 +00:00
|
|
|
</div>
|
2021-12-13 18:20:31 +00:00
|
|
|
) : (
|
|
|
|
<SignInCard />
|
|
|
|
)}
|
2021-12-09 01:57:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|