"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 dateFormat = "EEEE d. MMMM yyyy"; const timeFormat = "'kl.' HH:mm"; return (
  • {formatExtendedDateTime(occurrence.start, true)} {" "} {formatDate(occurrence.start, timeFormat)} {" "} {occurrence.venue?.preposition + " " ?? ""} {occurrence.venue?.url && ( {occurrence.venue?.title} )} {!occurrence.venue?.url && <>{occurrence.venue?.title}}
  • ); }; export const DateList = ({ event }: { event: EventFragment }) => { const [showPast, setShowPast] = useState(false); const futureOccurrences = event.occurrences .filter((occurrence) => isTodayOrFuture(occurrence.start)) .sort((a, b) => compareDates(a.start, b.start)); const pastOccurrences = event.occurrences .filter((occurrence) => !isTodayOrFuture(occurrence.start)) .sort((a, b) => compareDates(a.start, b.start)); // TODO: events occurring once // TODO: end date/time? // TODO: past occurrences? const [showAllDates, setShowAllDates] = useState(false); function toggleDates() { setShowAllDates(!showAllDates) } return (
    Dato Tid Sted
    {futureOccurrences.length > 4 && (
    )} {/*
    setShowPast(!showPast)}> {showPast ? "Skjul" : "Vis"} tidligere
    {showPast && ( <>

    Tidligere datoer{" "} ({pastOccurrences.length})

    )} */}
    ); };