import { useEffect, useState } from 'preact/hooks' const endpoint = 'https://kultar.sout.no/events/' const fetch_options = {} function Tickets({ ticket_link }) { console.log(ticket_link) return Biletter } function Time({ date }) { const hasTime = date.getHours() === 0 const time_option = hasTime ? undefined : 'numeric' const options = { month: 'long', weekday: 'long', day: 'numeric', hour: time_option, minute: time_option, } return

{new Intl.DateTimeFormat('no', options).format(date)}

} function Location({ location }) { const { location: area, host } = location const hasHost = host.length !== 0 const hasArea = area.length !== 0 if (hasHost && hasArea) { return (

{host}, {area}.

) } if (hasHost) { return

{host}.

} if (hasArea) { return

{area}.

} return '' } function EventCard({ event }) { const { event_id, name, location, date, ticket_link } = event return (

{name}

) } function Event({ event, index }) { const isFirstEvent = index === 0 /* if (isFirstEvent) { * return * } */ return ( <>
) } export default function Events() { const [events, setEvents] = useState(null) useEffect(async () => { const res = await fetch(endpoint, fetch_options) const result = await res.json() setEvents(result) }, []) if (events === null) { return

Laster arrangement...

} if (events.length <= 0) { return

Det er ingen fremtidige arrangement.

} return ( <> {events.map((event, index) => ( ))} ) }