import moment from "moment-jalaali";
import axios from "../../../config/axios";

export const getTransactions = async (
  page: number,
  userSearch: string,
  dateSearch: string,
  search: string
) => {
  let query = `?page=${page}`;
  if (userSearch) {
    query += `&user=${userSearch}`;
  }
  if (dateSearch) {
    query += `&date=${moment(dateSearch, "jYYYY-jMM-jDD").format(
      "YYYY-MM-DD"
    )}`;
  }
  if (search) {
    query += `&q=${search}`;
  }
  const { data } = await axios.get(`/payments/transactions${query}`);
  return data;
};
