import clsx from 'clsx' import { User } from 'common/user' import { useEffect, useState } from 'react' import { prefetchUsers, useUserById } from 'web/hooks/use-user' import { Col } from './layout/col' import { Modal } from './layout/modal' import { Tabs } from './layout/tabs' import { TextButton } from './text-button' import { Row } from 'web/components/layout/row' import { Avatar } from 'web/components/avatar' import { UserLink } from 'web/components/user-page' import { useReferrals } from 'web/hooks/use-referrals' export function ReferralsButton(props: { user: User }) { const { user } = props const [isOpen, setIsOpen] = useState(false) const referralIds = useReferrals(user.id) return ( <> setIsOpen(true)}> {referralIds?.length ?? ''}{' '} Referrals ) } function ReferralsDialog(props: { user: User referralIds: string[] isOpen: boolean setIsOpen: (isOpen: boolean) => void }) { const { user, referralIds, isOpen, setIsOpen } = props useEffect(() => { prefetchUsers(referralIds) }, [referralIds]) return (
{user.name}
@{user.username}
, }, ]} />
) } function ReferralsList(props: { userIds: string[] }) { const { userIds } = props return ( {userIds.length === 0 && (
No users yet...
)} {userIds.map((userId) => ( ))} ) } function UserReferralItem(props: { userId: string; className?: string }) { const { userId, className } = props const user = useUserById(userId) return ( {user && } ) }