forked from polka_billy/porridger
Improved loading handling
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { StoriesPreview } from '.'
|
||||
import { UserCategoriesNames, UserCategory, composeUserCategoriesFilters } from '../assets/userCategories'
|
||||
import { useAnnouncements } from '../hooks/api'
|
||||
import { gotError } from '../hooks/useFetch'
|
||||
import { gotError, gotResponse } from '../hooks/useFetch'
|
||||
|
||||
type CategoryPreviewProps = {
|
||||
category: UserCategory,
|
||||
@ -15,8 +15,12 @@ function CategoryPreview({ category }: CategoryPreviewProps) {
|
||||
<h4 className='fw-bold'>{UserCategoriesNames[category]}</h4>
|
||||
{gotError(announcements) ? (
|
||||
<p className='text-danger'>{announcements.error}</p>
|
||||
) : (announcements.loading ? 'Загрузка...' :
|
||||
<StoriesPreview announcements={announcements.data} category={category} />
|
||||
) : (
|
||||
gotResponse(announcements) ? (
|
||||
<StoriesPreview announcements={announcements.data} category={category} />
|
||||
) : (
|
||||
'Загрузка...'
|
||||
)
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ import { CSSProperties } from 'react'
|
||||
import handStarsIcon from '../assets/handStars.svg'
|
||||
|
||||
type PointsProps = {
|
||||
points: number,
|
||||
points: number | string,
|
||||
}
|
||||
|
||||
const styles = {
|
||||
|
Reference in New Issue
Block a user