CoastalCommitsPastes/client/components/post-list/index.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-03-09 20:11:37 -05:00
import { Text } from "@geist-ui/core"
2022-03-06 20:20:01 -05:00
import Link from '../Link'
2022-03-06 19:46:59 -05:00
import styles from './post-list.module.css'
2022-03-09 20:11:37 -05:00
import ListItemSkeleton from "./list-item-skeleton"
import ListItem from "./list-item"
2022-03-06 19:46:59 -05:00
type Props = {
posts: any
error: any
}
const PostList = ({ posts, error }: Props) => {
return (
<div className={styles.container}>
{error && <Text type='error'>Failed to load.</Text>}
2022-03-09 20:11:37 -05:00
{!posts && <ul>
<li>
<ListItemSkeleton />
</li>
<li>
<ListItemSkeleton />
</li>
</ul>}
2022-03-06 19:46:59 -05:00
{posts?.length === 0 && <Text>You have no posts. Create one <Link href="/new">here</Link>.</Text>}
{
posts?.length > 0 && <div>
<ul>
{posts.map((post: any) => {
2022-03-09 20:11:37 -05:00
return <ListItem post={post} key={post.id} />
2022-03-06 19:46:59 -05:00
})}
</ul>
</div>
}
</div >
2022-03-06 19:46:59 -05:00
)
}
2022-03-09 20:11:37 -05:00
export default PostList