"use client"; import { useState } from "react"; import { formatDate, formatExtendedDateTime, isTodayOrFuture, compareDates, } from "@/lib/date"; import { EventFragment, EventOccurrence } from "@/lib/event"; import styles from "./dateList.module.scss"; import Link from "next/link"; const DateListItem = ({ occurrence }: { occurrence: EventOccurrence }) => { const timeFormat = "'kl.' HH:mm"; const wholeCastle = occurrence.venue?.slug === "hele-huset"; return (
  • {formatExtendedDateTime(occurrence.start, true)} {" "} {formatDate(occurrence.start, timeFormat)} {" "} {wholeCastle && på Chateau Neuf} {!wholeCastle && ( {occurrence.venue?.preposition + " " ?? ""} {occurrence.venue?.url && ( {occurrence.venue?.title} )} {!occurrence.venue?.url && <>{occurrence.venue?.title}} )}
  • ); }; export const DateList = ({ event }: { event: EventFragment }) => { const [showAllDates, setShowAllDates] = useState(false); function toggleDates() { setShowAllDates(!showAllDates); } const oneOff = event.occurrences.length === 1; const showToggle = event.occurrences.length > 4; const futureOccurrences = event.occurrences .filter((occurrence) => isTodayOrFuture(occurrence.start)) .sort((a, b) => compareDates(a.start, b.start)); let visibleOccurrences = []; if (oneOff || showAllDates || event.occurrences.length <= 4) { visibleOccurrences = event.occurrences; } else { visibleOccurrences = futureOccurrences.slice(0, 4); } // TODO: end date/time? return (
    Dato Tid Sted
    {showToggle && (
    )}
    ); };