Skip to content

Commit

Permalink
Set updatedAt & display under createdAt
Browse files Browse the repository at this point in the history
  • Loading branch information
philosolog committed Jan 13, 2025
1 parent 3ead364 commit c49a7e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
8 changes: 7 additions & 1 deletion api/src/controllers/reviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,13 @@ const reviewsRouter = router({
}

const { id, ...updateWithoutId } = input;
await db.update(review).set(updateWithoutId).where(eq(review.id, id));
await db
.update(review)
.set({
...updateWithoutId,
updatedAt: new Date(),
})
.where(eq(review.id, id));
return true;
}),

Expand Down
26 changes: 15 additions & 11 deletions site/src/component/Review/SubReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,11 @@ const SubReview: FC<SubReviewProps> = ({ review, course, professor }) => {
</div>
</div>
<div>
<div className="subreview-author" style={{ display: 'flex', justifyContent: 'space-between' }}>
<p style={{ textAlign: 'left' }}>
<span className="mr-1">Posted by {review.userDisplay}</span>
<div className="subreview-author">
<p className=" gapped">
<span className=" mr-1">Posted by {review.userDisplay}</span>
{review.verified && verifiedBadge}
{review.authored && authorBadge}
<p>{review.content}</p>
</p>
<p style={{ textAlign: 'right' }}>
Created{' '}
Expand All @@ -209,15 +208,20 @@ const SubReview: FC<SubReviewProps> = ({ review, course, professor }) => {
month: 'long',
day: 'numeric',
})}
<br />
Updated{' '}
{new Date(review.updatedAt).toLocaleString('default', {
year: 'numeric',
month: 'long',
day: 'numeric',
})}
{review.updatedAt && (
<>
<br />
Updated{' '}
{new Date(review.updatedAt).toLocaleString('default', {
year: 'numeric',
month: 'long',
day: 'numeric',
})}
</>
)}
</p>
</div>
<p>{review.content}</p>
</div>
</div>
</div>
Expand Down

0 comments on commit c49a7e7

Please sign in to comment.