import { Fragment, type ReactNode } from "react";
import { resolveHomeSectionOrder, type HomeSectionKey } from "../homeSectionOrder";

/** Shared by the public server page and authenticated client page. */
export default function HomepageSections({ order, sections, contributionBanner }: {
  order?: readonly string[] | null;
  contributionBanner?: ReactNode;
  sections: Record<HomeSectionKey, ReactNode>;
}) {
  return <>{resolveHomeSectionOrder(order).map(key => <Fragment key={key}>{sections[key]}{key === "volunteer" && contributionBanner && <div className="home-contribution-spacing">{contributionBanner}</div>}</Fragment>)}</>;
}
