Added poetry display on userPage

This commit is contained in:
2023-07-31 15:03:56 +03:00
parent e7327945e3
commit 6724a97352
7 changed files with 208 additions and 1 deletions

View File

@ -0,0 +1,39 @@
import { CSSProperties } from 'react'
import { usePoetry } from '../hooks/api'
import { gotError, gotResponse } from '../hooks/useFetch'
const styles = {
container: {
paddingBottom: 8,
} as CSSProperties,
}
function Poetry() {
const poetry = usePoetry()
return (
<div style={styles.container}>
<h4 className='fw-bold'>Поэзия</h4> {
gotResponse(poetry) ? (
gotError(poetry) ? (
<div className='text-danger'>
<h5>Ошибка получения стиха</h5>
<p>{poetry.error}</p>
</div>
) : (
<>
<h5>{poetry.data.title}</h5>
<p dangerouslySetInnerHTML={{ __html: poetry.data.text }} />
<p><em>{poetry.data.author}</em></p>
</>
)
) : (
<h5>Загрузка...</h5>
)
}
</div>
)
}
export default Poetry

View File

@ -12,3 +12,4 @@ export { default as CategoryPreview } from './CategoryPreview'
export { default as StoriesPreview } from './StoriesPreview'
export { default as Points } from './Points'
export { default as SignOut } from './SignOut'
export { default as Poetry } from './Poetry'