import clsx from 'clsx'
import React from 'react'
import { formatMoney } from 'common/util/format'
import { Col } from 'web/components/layout/col'
import { Row } from 'web/components/layout/row'
import { Page } from 'web/components/page'
import { SEO } from 'web/components/SEO'
import { Title } from 'web/components/title'
import { useUser } from 'web/hooks/use-user'
import { fromNow } from 'web/lib/util/time'
import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
import {
getChallengeUrl,
useAcceptedChallenges,
useUserChallenges,
} from 'web/lib/firebase/challenges'
import { Challenge } from 'common/challenge'
import { Tabs } from 'web/components/layout/tabs'
import { SiteLink } from 'web/components/site-link'
import { UserLink } from 'web/components/user-page'
import { Avatar } from 'web/components/avatar'
import Router from 'next/router'
import { contractPathWithoutContract } from 'web/lib/firebase/contracts'
import { Button } from 'web/components/button'
import { ClipboardCopyIcon, QrcodeIcon } from '@heroicons/react/outline'
import { copyToClipboard } from 'web/lib/util/copy'
import toast from 'react-hot-toast'
<<<<<<< HEAD
=======
import { Modal } from 'web/components/layout/modal'
import { QRCode } from 'web/components/qr-code'
>>>>>>> 798253f8 (Challenge Bets (#679))
dayjs.extend(customParseFormat)
const columnClass = 'sm:px-5 px-2 py-3.5 max-w-[100px] truncate'
const amountClass = columnClass + ' max-w-[75px] font-bold'
export default function ChallengesListPage() {
const user = useUser()
const userChallenges = useUserChallenges(user?.id ?? '')
const challenges = useAcceptedChallenges()
const userTab = user
? [
{
content: ,
title: 'Your Challenges',
},
]
: []
const publicTab = [
{
content: ,
title: 'Public Challenges',
},
]
return (
Find or create a question to challenge someone to a bet.
)
}
function YourChallengesTable(props: { links: Challenge[] }) {
const { links } = props
return links.length == 0 ? (
There aren't currently any challenges.
) : (
Amount |
Link
|
Accepted By |
{links.map((link) => (
))}
)
}
function YourLinkSummaryRow(props: { challenge: Challenge }) {
const { challenge } = props
const { acceptances } = challenge
<<<<<<< HEAD
=======
const [open, setOpen] = React.useState(false)
>>>>>>> 798253f8 (Challenge Bets (#679))
const className = clsx(
'whitespace-nowrap text-sm hover:cursor-pointer text-gray-500 hover:bg-sky-50 bg-white'
)
return (
<<<<<<< HEAD
{formatMoney(challenge.creatorAmount)}
|
{`...${challenge.contractSlug}/${challenge.slug}`}
|
{acceptances.length > 0 ? (
<>
>
) : (
No one -
{challenge.expiresTime &&
` (expires ${fromNow(challenge.expiresTime)})`}
)}
|
=======
<>
Have your friend scan this to accept the challenge!
{formatMoney(challenge.creatorAmount)}
|
{`...${challenge.contractSlug}/${challenge.slug}`}
|
{acceptances.length > 0 ? (
<>
>
) : (
No one -
{challenge.expiresTime &&
` (expires ${fromNow(challenge.expiresTime)})`}
)}
|
>
>>>>>>> 798253f8 (Challenge Bets (#679))
)
}
function PublicChallengesTable(props: { links: Challenge[] }) {
const { links } = props
return links.length == 0 ? (
There aren't currently any challenges.
) : (
Amount |
Creator |
Acceptor |
Market |
{links.map((link) => (
))}
)
}
function PublicLinkSummaryRow(props: { challenge: Challenge }) {
const { challenge } = props
const {
acceptances,
creatorUsername,
creatorName,
creatorAvatarUrl,
contractCreatorUsername,
contractQuestion,
contractSlug,
} = challenge
const className = clsx(
'whitespace-nowrap text-sm hover:cursor-pointer text-gray-500 hover:bg-sky-50 bg-white'
)
return (
Router.push(getChallengeUrl(challenge))}
>
{formatMoney(challenge.creatorAmount)}
|
|
{acceptances.length > 0 ? (
<>
>
) : (
No one -
{challenge.expiresTime &&
` (expires ${fromNow(challenge.expiresTime)})`}
)}
|
{contractQuestion}
|
)
}