import { FeatureEditor } from "@/components/FeatureEditor";
import { readCatalog } from "@/lib/storage";
import type { Feature } from "@/lib/types";

export const dynamic = "force-dynamic";

export default async function NewFeaturePage() {
  const catalog = await readCatalog();
  const now = new Date().toISOString();
  const feature: Feature = {
    id: crypto.randomUUID(),
    name: "",
    description: "",
    businessBenefit: "",
    categoryId: catalog.categories[0]?.id ?? "",
    screenshots: [],
    isDemo: false,
    sortOrder: catalog.features.length,
    createdAt: now,
    updatedAt: now,
  };

  return (
    <FeatureEditor feature={feature} categories={catalog.categories} isNew />
  );
}
