import TransactionsTable from "@/app/features/pages/transactions/transactionsTable";
import { getTransactions } from "@/app/services/transactions";

export default async function DepositTransactionPage({
  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 transactionType = 'deposit';
  const data = await getTransactions({ transactionType, query });

  return <TransactionsTable res={data}/>;
}
