import { m } from '@/i18n/messages' import { useLocale, getLocale } from '@/i18n/config' import { asI18n } from '@pikku/react' import { Box, Button, Card, Flex, Image, Stack, Text, Title } from '@pikku/mantine/core' import { ImageOff } from 'lucide-react' type EventCardProps = { eventName: string startDate: Date | null endDate: Date | null clientName?: string | null coverImageUrl?: string | null eventOutline?: string | null description?: string | null organiserWebsite?: string | null } function formatDateRange(start: Date | null, end: Date | null, lng: string): string { const locale = lng.startsWith('de') ? 'de-DE' : 'en-GB' const fmt = new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' }) // An enquiry may have no dates yet; show whatever we have, or a placeholder. if (!start && !end) return '—' if (!start || !end) return fmt.format((start ?? end) as Date) return start.toISOString().slice(0, 10) === end.toISOString().slice(0, 10) ? fmt.format(start) : fmt.formatRange(start, end) } export function EventCard({ eventName, startDate, endDate, clientName, coverImageUrl, eventOutline, description, organiserWebsite, }: EventCardProps) { useLocale() return ( {coverImageUrl ? ( {eventName} ) : ( )} {asI18n(`${eventName}`)} {asI18n(`${formatDateRange(startDate, endDate, getLocale())}`)} {clientName && ( {asI18n(`${clientName}`)} )} {(eventOutline || description) && ( {asI18n(`${eventOutline || description}`)} )} {organiserWebsite && ( )} ) }