import type { Metadata } from "next";

import { MyRenders } from "@/components/dashboard/MyRenders";
import { ACTIVE_STEPS, listMyExports, listMyRenders } from "@/lib/api/my-renders";
import { createPageMetadata } from "@/lib/metadata";

export const metadata: Metadata = createPageMetadata({
  title: "My Renders",
  description: "Your render jobs and finished videos.",
  path: "/dashboard/renders",
});

export const dynamic = "force-dynamic";

export default async function MyRendersPage() {
  const [allJobs, exports] = await Promise.all([listMyRenders(), listMyExports()]);
  // Show active/failed jobs in the "processing" section; Done ones live as exports.
  const jobs = allJobs.filter((j) => ACTIVE_STEPS.has(j.step) || j.step === "Failed");
  return <MyRenders jobs={jobs} exports={exports} />;
}
