Skip to content

Commit 9e3742e

Browse files
committed
feat(apps/web/components/thoughts): show edited label
1 parent d18f25d commit 9e3742e

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

apps/web/app/thoughts/page.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ export default async function ThoughtsPage() {
1515
</Card>
1616

1717
<section className="flex flex-col gap-2">
18-
{thoughts.map(({ id, content, author }) => (
18+
{thoughts.map(thought => (
1919
<ThoughtCard
20-
key={id}
21-
id={id}
22-
content={content}
23-
author={author}
20+
key={thought.id}
2421
currentUserId={currentUser.id}
22+
{...thought}
2523
/>
2624
))}
2725
</section>

apps/web/components/thoughts/thought-card.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { Thought } from '~/server/types/thoughts'
77

88
namespace ThoughtCard {
99
export type Props = Readonly<
10-
Pick<Thought, 'content' | 'author' | 'id'> & {
10+
Thought & {
1111
currentUserId: string
1212
}
1313
>
@@ -17,6 +17,8 @@ function ThoughtCard({
1717
id,
1818
content,
1919
author,
20+
updatedAt,
21+
createdAt,
2022
currentUserId,
2123
}: ThoughtCard.Props) {
2224
return (
@@ -39,14 +41,16 @@ function ThoughtCard({
3941
<User className="place-self-center" />
4042

4143
<CardHeader className="flex flex-row items-center justify-between">
42-
<div className="flex flex-row items-center gap-2">
43-
<div>
44-
<p className="font-semibold leading-5">{author.name}</p>
45-
<p className="text-muted-foreground text-xs">
46-
{new Date(author.createdAt).toLocaleDateString()}
47-
</p>
48-
</div>
44+
<div>
45+
<p className="font-semibold leading-5">{author.name}</p>
46+
<p className="text-muted-foreground text-xs">
47+
{new Date(author.createdAt).toLocaleDateString()}
48+
</p>
4949
</div>
50+
51+
{createdAt !== updatedAt && (
52+
<p className="pr-2 text-xs text-neutral-400">(edited)</p>
53+
)}
5054
</CardHeader>
5155

5256
<div />

0 commit comments

Comments
 (0)