import { relativeTimeMs } from '@/utils/time'; import { Project } from 'gql-client'; import { Clock, GitBranch } from 'lucide-react'; import { ComponentPropsWithoutRef } from 'react'; /** * Props for the ProjectDeploymentInfo component * * @property {Project} project - The project data containing deployment information */ interface ProjectDeploymentInfoProps extends ComponentPropsWithoutRef<'div'> { project: Project; } /** * ProjectDeploymentInfo component * * Displays information about the latest deployment for a project, including: * - Commit message (or "No production deployment" if none exists) * - Relative time since deployment or project creation * - Branch name (if a deployment exists) * * The component handles both cases where a project has deployments and where it doesn't, * displaying appropriate information in each case. * * @example * ```tsx * * ``` */ export const ProjectDeploymentInfo = ({ project, ...props }: ProjectDeploymentInfoProps) => { const hasDeployment = project.deployments.length > 0; const latestDeployment = project.deployments[0]; return (
{/* Commit message or no deployment message */}
{hasDeployment ? latestDeployment?.commitMessage : 'No production deployment'}
{/* Timestamp and branch information */}
{hasDeployment ? relativeTimeMs(latestDeployment.createdAt) : relativeTimeMs(project.createdAt)} on
{hasDeployment && (
{latestDeployment.branch}
)}
); };