import { Pagination } from "../../../types/Pagination.ts";
import { ObjectListWithPagination } from "../../../hooks/objectList.tsx";
import { TransactionService } from "../../../client";

type TransitionType = {
    isIncome: boolean
};
type Props = Pagination & TransitionType;

export const useTransactionsList = (props: Props) =>
    ObjectListWithPagination({
        queryFn: () => TransactionService.getAllTransactions({
            requestBody: {
                isIncome: props.isIncome,
            },
            ...props,
        }),
        queryKey: "getTransactions",
        getObjectsFn: response => response.transactions,
        pagination: props,
    });
