File size: 1,015 Bytes
41a71fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import { DeletePost, EditPost } from '@/features/Post';
import { PostCard, useFetchPosts } from '@/entities/Post';
import { classNames } from '@/shared/lib/classNames/classNames';
import cls from './PostList.module.scss';
interface PostListProps {
className?: string;
}
export const PostList = (props: PostListProps) => {
const { className } = props;
const { data, isPending, isError } = useFetchPosts();
if (isPending) {
return <div>...Идет загрузка</div>;
}
if (isError) {
return <div>Произошла непредвиденная ошибка</div>;
}
return (
<div className={classNames(cls.PostList, {}, [className])}>
{data?.map((post) => (
<PostCard
key={post.id}
post={post}
editButton={<EditPost postId={post.id} />}
deleteButton={<DeletePost postId={post.id} />}
/>
))}
</div>
);
};
|