dm1sh 60779ea489
Updated poetry to use latest api
Added poem id, changed url, fixed formatting, enabled actual fetching
2023-08-08 19:26:37 +03:00

41 lines
1.3 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 { usePoetry } from '../hooks/api'
import { gotError, gotResponse } from '../hooks/useFetch'
import styles from '../styles/Poetry.module.css'
function Poetry() {
const poetry = usePoetry()
return (
<div className={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
className={styles.text}
dangerouslySetInnerHTML={{
__html:
poetry.data.text.trim().replace(/(\n){3,}/g, '\n\n'),
}}
/>
<p><em>{poetry.data.author}</em></p>
</>
)
) : (
<h5>Загрузка...</h5>
)
}
</div>
)
}
export default Poetry