From 6396b066c85de0e65dc6c1f61ea972057e3dbb56 Mon Sep 17 00:00:00 2001 From: Wahyu Kurniawan Date: Wed, 28 Feb 2024 15:06:25 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20feat:=20make=20the=20whole?= =?UTF-8?q?=20card=20clickable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/ProjectCard/ProjectCard.tsx | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/frontend/src/components/projects/ProjectCard/ProjectCard.tsx b/packages/frontend/src/components/projects/ProjectCard/ProjectCard.tsx index 85603037..83aba24e 100644 --- a/packages/frontend/src/components/projects/ProjectCard/ProjectCard.tsx +++ b/packages/frontend/src/components/projects/ProjectCard/ProjectCard.tsx @@ -1,4 +1,8 @@ -import React, { ComponentPropsWithoutRef, MouseEvent } from 'react'; +import React, { + ComponentPropsWithoutRef, + MouseEvent, + useCallback, +} from 'react'; import { ProjectCardTheme, projectCardTheme } from './ProjectCard.theme'; import { Project } from 'gql-client'; import { Button } from 'components/shared/Button'; @@ -11,7 +15,7 @@ import { WarningDiamondIcon, } from 'components/shared/CustomIcon'; import { relativeTimeMs } from 'utils/time'; -import { Link } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import { Avatar } from 'components/shared/Avatar'; import { getInitials } from 'utils/geInitials'; import { @@ -38,14 +42,24 @@ export const ProjectCard = ({ // TODO: Update this to use the actual status from the API const hasError = status === 'failure'; + const navigate = useNavigate(); + const handleOptionsClick = ( e: MouseEvent, ) => { e.stopPropagation(); }; + const handleClick = useCallback(() => { + navigate(`projects/${project.id}`); + }, [project.id, navigate]); + return ( -
+
{/* Upper content */}
{/* Icon container */} @@ -54,14 +68,13 @@ export const ProjectCard = ({ imageSrc={project.icon} initials={getInitials(project.name)} /> - {/*
*/} {/* Title and website */} - +

{project.name}

{project.deployments[0]?.domain?.name ?? 'No domain'}

- +
{/* Icons */}
{hasError && }