bbf419953e
* WIP - got comments on the user page * Remove number from chosen FR answer * Distinguish wining and losing FR answers * Show no answers text * Simplify get answer items logic * Show answer number * Show answer # when resolving * Fix import path * Add user's collated comments onto profile * Allow linking to comments/markets in profile * Allow preload of users contracts in profile * Remove unused check * Small code improvements
33 lines
857 B
TypeScript
33 lines
857 B
TypeScript
import { useRouter } from 'next/router'
|
|
import React, { useEffect, useState } from 'react'
|
|
|
|
import { getUserByUsername, User } from '../../lib/firebase/users'
|
|
import { UserPage } from '../../components/user-page'
|
|
import { useUser } from '../../hooks/use-user'
|
|
import Custom404 from '../404'
|
|
|
|
export default function UserProfile() {
|
|
const router = useRouter()
|
|
const [user, setUser] = useState<User | null | 'loading'>('loading')
|
|
const { username, tab } = router.query as { username: string; tab: string }
|
|
useEffect(() => {
|
|
if (username) {
|
|
getUserByUsername(username).then(setUser)
|
|
}
|
|
}, [username])
|
|
|
|
const currentUser = useUser()
|
|
|
|
if (user === 'loading') return <></>
|
|
|
|
return user ? (
|
|
<UserPage
|
|
user={user}
|
|
currentUser={currentUser || undefined}
|
|
defaultTabTitle={tab}
|
|
/>
|
|
) : (
|
|
<Custom404 />
|
|
)
|
|
}
|