File size: 1,091 Bytes
fcd4478
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use client';

import { ProjectBaseInfo } from '@/lib/fetch/clef';
import { format } from 'date-fns';
import Link from 'next/link';
import { useParams } from 'next/navigation';
import { cn } from '@/lib/utils';

export interface ProjectCardProps {
	projectInfo: ProjectBaseInfo;
}

const ProjectCard: React.FC<ProjectCardProps> = ({ projectInfo }) => {
	const {
		id,
		name,
		created_at,
		organization: { name: orgName },
	} = projectInfo;

	const { projectId: projectIdFromParam } = useParams();

	const formattedDate = format(created_at, 'yyyy-MM-dd');
	return (
		<Link
			className={cn(
				'p-4 m-2 bg-white l:h-[250px] rounded-xl shadow-md flex items-center border border-transparent hover:border-gray-500 transition-all cursor-pointer',
				Number(projectIdFromParam) === id && 'border-gray-500',
			)}
			href={`/project/${id}`}
		>
			<div>
				<p className="text-xs text-gray-500">{orgName}</p>
				<p className="text-sm font-medium text-black mb-1">{name}</p>
				<p className="text-xs text-gray-500">{formattedDate}</p>
			</div>
		</Link>
	);
};

export default ProjectCard;