Skip to content

Commit

Permalink
#9 fix : display in days if over 24 hours
Browse files Browse the repository at this point in the history
luckylooky2 committed Mar 19, 2023
1 parent 1cba859 commit ed9da89
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions front/src/components/party/PartyCard.tsx
Original file line number Diff line number Diff line change
@@ -28,10 +28,11 @@ const PartyCard = ({ party }: PartyProps): JSX.Element => {
const navigate = useNavigate();

const timer = (createdDate: Date): string => {
const diffHours = differenceInHours(new Date(), createdDate);
const diffMinutes = differenceInMinutes(new Date(), createdDate);
const diffHours: number = differenceInHours(new Date(), createdDate);
const diffMinutes: number = differenceInMinutes(new Date(), createdDate);
if (diffHours === 0) return diffMinutes + " minutes ago";
else return diffHours + " hours ago";
else if (diffHours < 24) return diffHours + " hours ago";
else return Math.floor(diffHours / 24) + " days ago";
};

return (
@@ -44,7 +45,7 @@ const PartyCard = ({ party }: PartyProps): JSX.Element => {
: { width: 320, marginTop: 1, bgcolor: "#ffffff" }
}
>
<Box sx={{ display: "flex" }}>
<Box sx={{ display: "flex", flexDirection: "row" }}>
<Typography level="h1" fontSize="md" sx={{ mb: 0.5 }}>
{party.title}
</Typography>

0 comments on commit ed9da89

Please sign in to comment.