Files
conve-x/src/components/Post.tsx
T

40 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-09-11 00:40:14 -05:00
import { Text } from '@codemirror/state';
import Image from 'next/image';
import { Doc, Id } from '../../convex/_generated/dataModel';
2023-09-11 00:40:14 -05:00
import PostContent from './PostContent';
2023-09-11 13:49:13 -05:00
import { PostWithUserDto } from '@/app/types';
2023-09-11 00:40:14 -05:00
2023-09-11 13:49:13 -05:00
export default function Post({ post }: { post: PostWithUserDto }) {
const username = post.user.clerkUsername ?? post.user._id;
2023-09-11 00:40:14 -05:00
const createdPostDate = new Date(post._creationTime);
const postYear = createdPostDate.getFullYear();
const postMonth = createdPostDate.toLocaleString(undefined, {
month: 'short',
});
const dayOfMonth = createdPostDate.getDate();
return (
<div className='flex w-full h-full gap-4 p-8 bg-white dark:bg-secondary-gray border border-gray-600'>
<div>
<Image
alt='user profile image'
src={post.user.clerkImageUrl}
2023-09-11 00:40:14 -05:00
width={40}
height={40}
className='rounded-full object-cover border-4 border-primary-accent'
/>
</div>
<div className='flex flex-col gap-2'>
<div className='flex items-center gap-2'>
<div>{username}</div>
<div className='text-xs'>{`${postMonth} ${dayOfMonth}, ${postYear}`}</div>
</div>
<div>
<PostContent content={Text.of(post.content).toString()} />
</div>
<div></div>
</div>
</div>
);
}