import { notFound } from "next/navigation";

import { IsinAssetsForm } from "../_components/isin-assets-form/isin-assets-form";
import { fetchBackendIsinAssetDetail } from "../_lib/isin-assets-server-api";

type PageProps = {
  params: Promise<{ id: string }>;
};

export default async function IsinAssetsUpdatePage({ params }: PageProps) {
  const { id } = await params;

  let row: Awaited<ReturnType<typeof fetchBackendIsinAssetDetail>>;
  try {
    row = await fetchBackendIsinAssetDetail(decodeURIComponent(id));
  } catch {
    notFound();
  }

  return <IsinAssetsForm mode="update" initialRow={row} />;
}
