import Link from 'next/link' import Image from 'react-bootstrap/Image' import { abbrNum, numWithUnits } from '../lib/format' import styles from './item.module.css' import userStyles from './user-header.module.css' import React, { useEffect, useMemo, useState } from 'react' import { useQuery } from '@apollo/client' import MoreFooter from './more-footer' import { useData } from './use-data' import Hat from './hat' import { useMe } from './me' import { MEDIA_URL } from '../lib/constants' // all of this nonsense is to show the stat we are sorting by first const Stacked = ({ user }) => (user.optional.stacked !== null && {abbrNum(user.optional.stacked)} stacked) const Spent = ({ user }) => (user.optional.spent !== null && {abbrNum(user.optional.spent)} spent) const Posts = ({ user }) => ( {numWithUnits(user.nposts, { unitSingular: 'post', unitPlural: 'posts' })} ) const Comments = ({ user }) => ( {numWithUnits(user.ncomments, { unitSingular: 'comment', unitPlural: 'comments' })} ) const Referrals = ({ user }) => (user.optional.referrals !== null && {numWithUnits(user.optional.referrals, { unitSingular: 'referral', unitPlural: 'referrals' })}) const Seperator = () => ( \ ) const STAT_POS = { stacked: 0, spent: 1, posts: 2, comments: 3, referrals: 4 } const STAT_COMPONENTS = [Stacked, Spent, Posts, Comments, Referrals] function seperate (arr, seperator) { return arr.flatMap((x, i) => i < arr.length - 1 ? [x, seperator] : [x]) } function User ({ user, rank, statComps, Embellish }) { const me = useMe() return ( <> {rank ? (