Files
porridger/front/src/pages/UserPage.tsx

56 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Container } from 'react-bootstrap'
import { useUser } from '../hooks/api'
import { userCategories } from '../assets/userCategories'
import { BackHeader, CategoryPreview, Poetry, Points, SignOut, StarRating } from '../components'
import { gotError, gotResponse } from '../hooks/useFetch'
import styles from '../styles/UserPage.module.css'
function UserPage() {
const user = useUser()
return (
<Container className={styles.sixteenXnine}>
<BackHeader text={
gotResponse(user) ? (
gotError(user) ? (
user.error
) : (
`${user.data.nickname}, с нами с ${user.data.regDate}`
)
) : (
'Загрузка...'
)
}>
<SignOut />
</BackHeader>
<div className='mb-4'>
<Points points={
gotResponse(user) ? (
gotError(user) ? -1 : user.data?.points
) : (
'Загрузка...'
)
} />
<h5 className={styles.userRating}>
Ваша оценка:
<StarRating userId={user.data?.id || 1} />
</h5>
</div>
{userCategories.map(cat => (
<CategoryPreview key={cat} category={cat} />
))}
<div className='mb-3'>
<Poetry />
</div>
</Container>
)
}
export default UserPage