import { Ban } from "lucide-react";

import { ListPageCard } from "@/app/dashboard/_components";
import { ErrorBanner } from "@/components/shared/error-banner";

import { ExcludedFromTotalValueHeaderActions } from "./_components/list-header-actions";
import { ExcludedFromTotalValueTable } from "./_components/excluded-from-total-value-table";
import { fetchBackendExcludedFromTotalValue } from "./_lib/excluded-from-total-value-server-api";


export const dynamic = "force-dynamic";
export default async function ExcludedFromTotalValuePage() {
  const { rows, errorMessage, totalCount } =
    await fetchBackendExcludedFromTotalValue();

  const countLabel =
    totalCount > 0
      ? `${totalCount} holding${totalCount === 1 ? "" : "s"} omitted from Total Value`
      : "Holdings omitted from dashboard Total Value (currency convert error + null value)";

  return (
    <ListPageCard
      icon={Ban}
      title="Excluded from Total Value"
      description={countLabel}
      breadcrumb={[
        { label: "Master Table" },
        { label: "Excluded from Total Value" },
      ]}
      actions={<ExcludedFromTotalValueHeaderActions />}
    >
      <ErrorBanner message={errorMessage} className="mb-4" />
      <ExcludedFromTotalValueTable data={rows} />
    </ListPageCard>
  );
}
