import { AdminPermissionGate } from "@/components/admin/admin-permission-gate";
import { InvalidSettlementBatchId } from "@/modules/settlement/invalid-settlement-batch-id";
import { SettlementBatchDetailsConsole } from "@/modules/settlement/settlement-batch-details-console";
import { PRD_PAYOUT_ACCESS_ANY } from "@/lib/admin-prd";
import { buildPageMetadata } from "@/lib/page-metadata";
import type { Metadata } from "next";

export const metadata: Metadata = buildPageMetadata("settlement", "details");

export default async function AdminSettlementBatchDetailsPage(props: {
  params: Promise<{ batchId: string }>;
}) {
  const { batchId } = await props.params;
  const id = Number.parseInt(batchId, 10);
  if (!Number.isFinite(id) || id < 1) {
    return <InvalidSettlementBatchId />;
  }

  return (
    <AdminPermissionGate requiredAny={PRD_PAYOUT_ACCESS_ANY}>
      <SettlementBatchDetailsConsole batchId={id} />
    </AdminPermissionGate>
  );
}
