import type { Context } from "hono";
import { listAllMovements } from "../wallets.service";

export async function listAllMovementsHandler(c: Context) {
  const walletId = c.req.query("walletId")
    ? Number(c.req.query("walletId"))
    : undefined;
  const startDate = c.req.query("startDate") || undefined;
  const endDate = c.req.query("endDate") || undefined;
  const page = parseInt(c.req.query("page") ?? "1", 10);
  const pageSize = parseInt(c.req.query("pageSize") ?? "20", 10);

  const result = await listAllMovements({
    walletId,
    startDate,
    endDate,
    page,
    pageSize,
  });
  return c.json(result);
}
