import { useCallback, useEffect, useState } from 'react'; import { getEvent } from '../api'; import { IEvent } from '../types'; import UILink from '../UI/UILink'; import UISecondaryBox from '../UI/UISecondaryBox'; import UISecondaryHeader from '../UI/UISecondaryHeader'; import useImmutable from '../useImmutable'; import EventContext from './EventContext'; import EventDetails from './EventDetails'; import EventInterestForm from './EventInterestForm'; import EventPlaceholder from './EventPlaceholder'; function GroupName({ group }: { group: IEvent['group'] }) { return {group.name}; } export default function Event({ id, initial, }: { id: number; initial?: IEvent; }) { const [event, setEvent] = useImmutable(initial ?? null); const [loading, setLoading] = useState(true); const [tentativeInvites] = useImmutable>({}); const refresh = useCallback(() => { setLoading(true); getEvent(id) .then((e) => e && setEvent(e)) .finally(() => setLoading(false)); }, [id, setEvent]); useEffect(refresh, [refresh]); if (loading) { return ; } if (!event) { return

Event Not Found

; } const { name, group } = event; return (
{name} {group && }
); }