import { Globe, Tag, Clock } from "lucide-react"; import { Conference } from "@/types/conference"; import { isValid, isPast } from "date-fns"; import ConferenceDialog from "./ConferenceDialog"; import CountdownTimer from "./CountdownTimer"; import { useState } from "react"; import { getDeadlineInLocalTime } from '@/utils/dateUtils'; const ConferenceCard = ({ title, full_name, year, date, deadline, timezone, tags = [], link, note, abstract_deadline, city, country, venue, ...conferenceProps }: Conference) => { const [dialogOpen, setDialogOpen] = useState(false); const deadlineDate = getDeadlineInLocalTime(deadline, timezone); // Create location string by concatenating city and country 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); } }; const handleTagClick = (e: React.MouseEvent, tag: string) => { e.stopPropagation(); const searchParams = new URLSearchParams(window.location.search); const currentTags = searchParams.get('tags')?.split(',') || []; let newTags; if (currentTags.includes(tag)) { newTags = currentTags.filter(t => t !== tag); } else { newTags = [...currentTags, tag]; } if (newTags.length > 0) { searchParams.set('tags', newTags.join(',')); } else { searchParams.delete('tags'); } const newUrl = `${window.location.pathname}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`; window.history.pushState({}, '', newUrl); window.dispatchEvent(new CustomEvent('urlchange', { detail: { tag } })); }; return ( <>

{title} {year} {link && ( e.stopPropagation()} > )}

{full_name && (

{full_name}

)}
{date}. {location}
{note && (
Note: {note.replace(/<[^>]*>/g, '')}
)}
Deadline: {deadline === 'TBD' ? 'TBD' : deadlineDate?.toLocaleString('en-US', { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZoneName: 'short' })}
{Array.isArray(tags) && tags.length > 0 && (
{tags.map((tag) => ( ))}
)}
); }; export default ConferenceCard;