manifold/web/pages/[username]/index.tsx
Marshall Polaris acc9c84e2e
More absolute imports (#156)
* Configure functions module to allow absolute imports

* Convert common imports in functions to be absolute

* Convert common imports in web to be absolute

* Convert lib imports in web to be absolute

* Convert hooks imports in web to be absolute

* Convert components imports in web to be absolute
2022-05-09 09:04:36 -04:00

33 lines
851 B
TypeScript

import { useRouter } from 'next/router'
import React, { useEffect, useState } from 'react'
import { getUserByUsername, User } from 'web/lib/firebase/users'
import { UserPage } from 'web/components/user-page'
import { useUser } from 'web/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 />
)
}