⚡️ feat: make the whole card clickable
This commit is contained in:
parent
0ffdbd3304
commit
6396b066c8
@ -1,4 +1,8 @@
|
|||||||
import React, { ComponentPropsWithoutRef, MouseEvent } from 'react';
|
import React, {
|
||||||
|
ComponentPropsWithoutRef,
|
||||||
|
MouseEvent,
|
||||||
|
useCallback,
|
||||||
|
} from 'react';
|
||||||
import { ProjectCardTheme, projectCardTheme } from './ProjectCard.theme';
|
import { ProjectCardTheme, projectCardTheme } from './ProjectCard.theme';
|
||||||
import { Project } from 'gql-client';
|
import { Project } from 'gql-client';
|
||||||
import { Button } from 'components/shared/Button';
|
import { Button } from 'components/shared/Button';
|
||||||
@ -11,7 +15,7 @@ import {
|
|||||||
WarningDiamondIcon,
|
WarningDiamondIcon,
|
||||||
} from 'components/shared/CustomIcon';
|
} from 'components/shared/CustomIcon';
|
||||||
import { relativeTimeMs } from 'utils/time';
|
import { relativeTimeMs } from 'utils/time';
|
||||||
import { Link } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Avatar } from 'components/shared/Avatar';
|
import { Avatar } from 'components/shared/Avatar';
|
||||||
import { getInitials } from 'utils/geInitials';
|
import { getInitials } from 'utils/geInitials';
|
||||||
import {
|
import {
|
||||||
@ -38,14 +42,24 @@ export const ProjectCard = ({
|
|||||||
// TODO: Update this to use the actual status from the API
|
// TODO: Update this to use the actual status from the API
|
||||||
const hasError = status === 'failure';
|
const hasError = status === 'failure';
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handleOptionsClick = (
|
const handleOptionsClick = (
|
||||||
e: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>,
|
e: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>,
|
||||||
) => {
|
) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClick = useCallback(() => {
|
||||||
|
navigate(`projects/${project.id}`);
|
||||||
|
}, [project.id, navigate]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div {...props} className={theme.wrapper({ className })}>
|
<div
|
||||||
|
{...props}
|
||||||
|
className={theme.wrapper({ className })}
|
||||||
|
onClick={handleClick}
|
||||||
|
>
|
||||||
{/* Upper content */}
|
{/* Upper content */}
|
||||||
<div className={theme.upperContent()}>
|
<div className={theme.upperContent()}>
|
||||||
{/* Icon container */}
|
{/* Icon container */}
|
||||||
@ -54,14 +68,13 @@ export const ProjectCard = ({
|
|||||||
imageSrc={project.icon}
|
imageSrc={project.icon}
|
||||||
initials={getInitials(project.name)}
|
initials={getInitials(project.name)}
|
||||||
/>
|
/>
|
||||||
{/* </div> */}
|
|
||||||
{/* Title and website */}
|
{/* Title and website */}
|
||||||
<Link to={`projects/${project.id}`} className={theme.content()}>
|
<div className={theme.content()}>
|
||||||
<p className={theme.title()}>{project.name}</p>
|
<p className={theme.title()}>{project.name}</p>
|
||||||
<p className={theme.description()}>
|
<p className={theme.description()}>
|
||||||
{project.deployments[0]?.domain?.name ?? 'No domain'}
|
{project.deployments[0]?.domain?.name ?? 'No domain'}
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</div>
|
||||||
{/* Icons */}
|
{/* Icons */}
|
||||||
<div className={theme.icons()}>
|
<div className={theme.icons()}>
|
||||||
{hasError && <WarningDiamondIcon className="text-elements-danger" />}
|
{hasError && <WarningDiamondIcon className="text-elements-danger" />}
|
||||||
|
Loading…
Reference in New Issue
Block a user