import { CalendarDays, Globe, Tag, Clock, AlarmClock } from "lucide-react"; import { Conference } from "@/types/conference"; import { formatDistanceToNow, parseISO, isValid } from "date-fns"; import ConferenceDialog from "./ConferenceDialog"; import { useState } from "react"; const ConferenceCard = ({ title, full_name, date, place, deadline, timezone, tags = [], link, note, abstract_deadline, ...conferenceProps }: Conference) => { const [dialogOpen, setDialogOpen] = useState(false); const deadlineDate = deadline && deadline !== 'TBD' ? parseISO(deadline) : null; const daysLeft = deadlineDate && isValid(deadlineDate) ? formatDistanceToNow(deadlineDate, { addSuffix: true }) : 'TBD'; // Determine countdown color based on days remaining const getCountdownColor = () => { if (!deadlineDate || !isValid(deadlineDate)) return "text-neutral-600"; const daysRemaining = Math.ceil((deadlineDate.getTime() - new Date().getTime()) / (1000 * 60 * 60 * 24)); if (daysRemaining <= 7) return "text-red-600"; if (daysRemaining <= 30) return "text-orange-600"; return "text-green-600"; }; const handleCardClick = (e: React.MouseEvent) => { // Only open dialog if the click wasn't on a link or interactive element if (!(e.target as HTMLElement).closest('a')) { setDialogOpen(true); } }; return ( <>

{title}

{link && ( e.stopPropagation()} > )}
{date}
{place}
{deadline === 'TBD' ? 'TBD' : deadline}
{daysLeft}
{Array.isArray(tags) && tags.length > 0 && (
{tags.map((tag) => ( {tag} ))}
)}
); }; export default ConferenceCard;