import { fetchAllPages } from "@/utils";
import { SpaceProps } from "@/utils/type";
import { Spaces } from "@/components/spaces";

async function getSpaces() {
  try {
    const response = await fetchAllPages();
    return response as SpaceProps[];
  } catch {
    return [];
  }
}

export default async function Home() {
  const spaces = await getSpaces();
  return (
    <section className="flex h-screen overflow-auto">
      <div className="w-full container px-6 py-10 lg:py-20 mx-auto space-y-10 lg:space-y-14">
        <Spaces spaces={spaces} />
      </div>
    </section>
  );
}
