import { apiFetch } from "../../fetch";

interface IBody {
  moderator?: number[];
  consumer?: number[];
}

export async function fetchChangeRolesOfAccounts(
  moderators?: string[],
  consumers?: string[]
) {
  const path = `/account/administrator/accounts`;
  const body: IBody = {};

  if (moderators && moderators.length !== 0) {
    body.moderator = moderators.map((id) => Number(id));
  }

  if (consumers && consumers.length !== 0) {
    body.consumer = consumers.map((id) => Number(id));
  }

  await apiFetch(path, { method: "POST", body });

  return true;
}
