import { CalendarDays, Globe, Tag } from "lucide-react"; import { Conference } from "@/types/conference"; import { format, isValid } from "date-fns"; import ConferenceDialog from "./ConferenceDialog"; import { useState } from "react"; import { getDeadlineInLocalTime } from '@/utils/dateUtils'; import { getAllDeadlines } from '@/utils/deadlineUtils'; type FindConferenceCardProps = Conference; const FindConferenceCard = ({ title, full_name, year, id, date, deadline, timezone, tags = [], link, note, abstract_deadline, city, country, venue, ...conferenceProps }: FindConferenceCardProps) => { const [dialogOpen, setDialogOpen] = useState(false); const conference = { title, full_name, year, id, date, deadline, timezone, tags, link, note, abstract_deadline, city, country, venue, ...conferenceProps }; const allDeadlines = getAllDeadlines(conference); // Find the paper submission deadline const paperDeadlineTypes = new Set(["paper", "submission", "paper_submission"]); const paperDeadline = allDeadlines.find((d) => paperDeadlineTypes.has(d.type)); const paperDeadlineDate = paperDeadline ? getDeadlineInLocalTime(paperDeadline.date, paperDeadline.timezone || timezone) : null; const formatLocalDeadline = (deadlineDate: Date | null) => { if (!deadlineDate || !isValid(deadlineDate)) return "TBD"; return format(deadlineDate, "MMM d, yyyy HH:mm"); }; // Create location string const location = [city, country].filter(Boolean).join(", "); const handleCardClick = (e: React.MouseEvent) => { if (!(e.target as HTMLElement).closest('a') && !(e.target as HTMLElement).closest('.tag-button')) { setDialogOpen(true); } }; return ( <>
{/* Header */}

{title} {year}

{full_name && (

{full_name}

)}
{link && ( e.stopPropagation()} > )}
{/* Paper Submission Deadline - Highlighted */}
Paper Submission Deadline
{formatLocalDeadline(paperDeadlineDate)}
{/* Conference Date */} {date && (
{date}
)} {/* Location */} {location && (
{location}
)} {/* Tags */} {tags.length > 0 && (
{tags.map((tag) => ( {tag.split("-").map(word => word.charAt(0).toUpperCase() + word.slice(1) ).join(" ")} ))}
)}
); }; export default FindConferenceCard;