import * as api from "../service/MessagesService";
import { useQuery } from "@tanstack/react-query";

export const useGetMessages = (page: number, search: string, since: string) => {
  return useQuery({
    queryKey: ["messages", page, search, since],
    queryFn: () => api.getMessages(page, search, since),
  });
};

export const useGetMessageDetail = (id: string) => {
  return useQuery({
    queryKey: ["message", id],
    queryFn: () => api.getMessageDetail(id),
    enabled: !!id,
  });
};
