From 2bbfdce3ca41c8b77aa1ca80c6ba55a2fd0c3aa0 Mon Sep 17 00:00:00 2001 From: rohitdasu Date: Sat, 28 Jan 2023 22:02:54 +0530 Subject: [PATCH] feat: displaying project created datetime in project component --- components/Projects/Project.interface.ts | 1 + components/Projects/Project.tsx | 36 ++++++++++++++++-------- components/Projects/ProjectsList.tsx | 1 + 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/components/Projects/Project.interface.ts b/components/Projects/Project.interface.ts index 19845e6a..a0046b49 100644 --- a/components/Projects/Project.interface.ts +++ b/components/Projects/Project.interface.ts @@ -6,6 +6,7 @@ export type ProjectProps = { description: string; tags: string[]; author: string | null; + createdAt: Date; }; export interface IProject extends ProjectData { diff --git a/components/Projects/Project.tsx b/components/Projects/Project.tsx index d3659cb6..f8d3d595 100644 --- a/components/Projects/Project.tsx +++ b/components/Projects/Project.tsx @@ -5,6 +5,7 @@ import { motion } from 'framer-motion'; import { useRouter } from 'next/router'; import { Button } from '@/components/Button'; import { Typography } from '@/components/Typography'; +import moment from 'moment'; export const Project = ({ id, @@ -12,6 +13,7 @@ export const Project = ({ description, tags, author, + createdAt, }: ProjectProps) => { const router = useRouter(); const handleContributeClick = () => { @@ -29,18 +31,28 @@ export const Project = ({ >
- - {title} - - - {author} - - +
+ + {title} + + + {author} + + +
+ + ยท + + + {moment(createdAt).fromNow()} + +
+
= ({ selectedTags }) => { title={project.title} tags={project.tags} author={project.author.name} + createdAt={project.createdAt} /> ))}