import { Modal } from 'web/components/layout/modal'
import { Col } from 'web/components/layout/col'
import { PAST_BETS, User } from 'common/user'
import clsx from 'clsx'
import {
Badge,
calculateBadgeRarity,
MarketCreatorBadge,
ProvenCorrectBadge,
rarities,
StreakerBadge,
} from 'common/badge'
import { groupBy } from 'lodash'
import { Row } from 'web/components/layout/row'
import { SiteLink } from 'web/components/site-link'
import { contractPathWithoutContract } from 'web/lib/firebase/contracts'
import { Tooltip } from 'web/components/tooltip'
import {
bronzeClassName,
goldClassName,
silverClassName,
} from 'web/components/badge-display'
import { formatMoney } from 'common/util/format'
export function BadgesModal(props: {
isOpen: boolean
setOpen: (open: boolean) => void
user: User
}) {
const { isOpen, setOpen, user } = props
const { provenCorrect, marketCreator, streaker } = user.achievements ?? {}
const badges = [
...(provenCorrect?.badges ?? []),
...(streaker?.badges ?? []),
...(marketCreator?.badges ?? []),
]
// group badges by their rarities
const badgesByRarity = groupBy(badges, (badge) => calculateBadgeRarity(badge))
return (
🏅
{user.name + "'s"} badges
Bronze
{badgesByRarity['bronze'] ? (
badgesByRarity['bronze'].map((badge, i) => (
))
) : (
None yet
)}
Silver
{badgesByRarity['silver'] ? (
badgesByRarity['silver'].map((badge, i) => (
))
) : (
None yet
)}
Gold
{badgesByRarity['gold'] ? (
badgesByRarity['gold'].map((badge, i) => (
))
) : (
None yet
)}
)
}
function BadgeToItem(props: { badge: Badge; rarity: rarities }) {
const { badge, rarity } = props
if (badge.type === 'PROVEN_CORRECT')
return (
)
else if (badge.type === 'STREAKER')
return
else if (badge.type === 'MARKET_CREATOR')
return (
)
else return null
}
function ProvenCorrectBadgeItem(props: {
badge: ProvenCorrectBadge
rarity: rarities
}) {
const { badge, rarity } = props
const { betAmount, contractSlug, contractCreatorUsername } = badge.data
return (
Proven Correct
)
}
function StreakerBadgeItem(props: { badge: StreakerBadge; rarity: rarities }) {
const { badge, rarity } = props
const { totalBettingStreak } = badge.data
return (
1 ? 's' : ''
} in a row`}
>
Prediction Streak
)
}
function MarketCreatorBadgeItem(props: {
badge: MarketCreatorBadge
rarity: rarities
}) {
const { badge, rarity } = props
const { totalContractsCreated } = badge.data
return (
1 ? 's' : ''
}`}
>
Market Creator
)
}
function Medal(props: { rarity: rarities }) {
const { rarity } = props
return (
{rarity === 'gold' ? '🥇' : rarity === 'silver' ? '🥈' : '🥉'}
)
}