import {
  ApproveTable,
} from "@/app/features/Pages/Approve/Approve";
import { getApproves } from "@/app/services/approve";


export default async function Approve({
  searchParams,
}: {
  searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
  // Await searchParams before processing
  const params = await searchParams;
  // Create a safe query string by filtering only string values
  const safeParams: Record<string, string> = {};
  for (const [key, value] of Object.entries(params)) {
    if (typeof value === "string") {
      safeParams[key] = value;
    }
  }
  const query = new URLSearchParams(safeParams).toString();
  const data = await getApproves({ query });

  return (
    <ApproveTable data={data} />
  );
};

