import { getVisitorMessages, getVisitorSessions } from "@/service/visitor";
import { TSessionItem, TVisitorMessage } from "@/types/visitor";
import { useLoadMore } from "@/utils/loadMore";

export const useVisitorMessages = (visitorId: string|number, sessionId: string) => {
  const fetcher = async ([_url, nextId, page, pageSize, sessionId]) => {
    const res = await getVisitorMessages({ startId: nextId, pageSize, visitorId, sessionId });
    return res.data;
  };

  const { data, loadMore, refetch } = useLoadMore<{
    data?: TVisitorMessage[]
    nextId?: string,
    totalCount?: number
  }>({
    url: `api/v1/my/visitor/messages/${visitorId}`,
    fetcher,
    params: [sessionId]
  });

  return {
    data,
    loadMore,
    refetch
  }
}

export const useVisitorSessions = (visitorId: string|number) => {
  

  return {
    data,
    loadMore,
    refetch
  }
}