import axios from "../../../config/axios";
import { getMailboxId } from "../../../config/func";
import { MessageListQueryDto, ArchiveResponse } from "../types/ArchiveTypes";

export const getArchiveMessages = async (
  query: MessageListQueryDto
): Promise<ArchiveResponse> => {
  const isSearch =
    !!query.search || !!query.datestart || query.dateend || query.from;
  const url = isSearch ? "search" : "messages/archive";

  // اضافه کردن mailbox id از localStorage
  const mailboxId = getMailboxId("Archive");
  const queryWithMailbox = {
    ...query,
    mailbox: mailboxId,
  };

  const { data } = await axios.get(`/email/${url}`, {
    params: queryWithMailbox,
  });
  return data;
};

// Note: moveMessageToArchive and unarchiveMessage are now handled by EmailActionsService
