"use client";

import { useState } from "react";
import { formatDate, isTodayOrFuture } from "@/lib/date";
import { EventFragment, EventOrganizer } from "@/lib/event";
import styles from "./organizerList.module.scss";
import Link from "next/link";

export const OrganizerList = ({ event }: { event: EventFragment }) => {
  return (
    <ul className={styles.organizerList}>
      {event.organizers.map((organizer) => {
        const url = organizer.association?.url ?? organizer.externalUrl ?? null;
        if (typeof url === "string" && url.startsWith("http")) {
          return (
            <li key={organizer.name}>
              <Link href={url}>{organizer.name}</Link>
            </li>
          );
        }
        return <li key={organizer.name}>{organizer.name}</li>;
      })}
    </ul>
  );
};
