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

export const getMessages = async (
  page: number,
  search: string,
  since: string
) => {
  let query = `?page=${page}`;
  if (search) {
    query += `&q=${search}`;
  }
  if (since) {
    query += `&since=${moment(since, "jYYYY-jMM-jDD").format("YYYY-MM-DD")}`;
  }
  const { data } = await axios.get(`/contact-us${query}`);
  return data;
};

export const getMessageDetail = async (id: string) => {
  const { data } = await axios.get(`/contact-us/${id}`);
  return data;
};
