Fix invalid time value error in date formatting

This commit is contained in:
Francisco Pessano
2025-07-13 21:03:15 -03:00
committed by GitHub
parent 90e62199c5
commit 6438fcb12f
3 changed files with 7 additions and 3 deletions

View File

@@ -11,7 +11,9 @@ interface ProjectCardProps {
} }
export function ProjectCard({ project, onSeenStatusChange }: ProjectCardProps) { export function ProjectCard({ project, onSeenStatusChange }: ProjectCardProps) {
const formattedDate = formatDistanceToNow(new Date(project.created_at), { addSuffix: true }); const formattedDate = project.created_at && !isNaN(new Date(project.created_at).getTime())
? formatDistanceToNow(new Date(project.created_at), { addSuffix: true })
: 'N/A';
const [seen, setSeen] = useState(false); const [seen, setSeen] = useState(false);
useEffect(() => { useEffect(() => {

View File

@@ -205,7 +205,9 @@ export function ProjectsTable({ projects, title, showUrlColumn = true, onSeenSta
), ),
cell: ({ row }) => ( cell: ({ row }) => (
<div className="text-sm w-full"> <div className="text-sm w-full">
{formatDistanceToNow(new Date(row.original.created_at), { addSuffix: true })} {row.original.created_at && !isNaN(new Date(row.original.created_at).getTime())
? formatDistanceToNow(new Date(row.original.created_at), { addSuffix: true })
: 'N/A'}
</div> </div>
), ),
size: 140, size: 140,

View File

@@ -4,7 +4,7 @@ import path from 'path';
export interface TwitterProject { export interface TwitterProject {
id: string; id: string;
created_at: string; created_at: string | null;
project_description: string; project_description: string;
project_url: string | null; project_url: string | null;
original_tweet_url: string | null; original_tweet_url: string | null;