Files
y/client/src/PostList.tsx
Stepan Usatiuk b4fa821d0d basic feed
2023-12-17 12:17:45 +01:00

30 lines
840 B
TypeScript

import { TPostToArr } from "./api/dto";
import { Post } from "./Post";
export function PostList({
posts,
selfUuid,
}: {
posts: TPostToArr | null;
selfUuid: string;
}) {
const sortedPosts = posts?.sort((a, b) => b.createdAt - a.createdAt);
return (
<div className={"posts"}>
{sortedPosts &&
sortedPosts.map((p) => {
const date = new Date(p.createdAt * 1000);
return (
<Post
text={p.text}
createdDate={`${date.toUTCString()}`}
key={p.id}
id={p.id}
actions={selfUuid == p.authorUuid}
/>
);
})}
</div>
);
}