import api from "src/api";

export const getKanbans = async () => {
  const { data } = await api.get("/franchisee/activities");
  return data.payload;
};

export const createKanban = async (payload) => {
  const { data } = await api.post("/franchisee/activities", payload);
  return data.payload;
};

export const updateKanban = async (id, payload) => {
  const { data } = await api.put(`/franchisee/activities/${id}`, payload);
  return data.payload;
};

export const deleteKanban = async (id) => {
  const { data } = await api.delete(`/franchisee/activities/${id}`);
  return data;
};

/**
 * Persists drag-and-drop reorder.
 * @param {Array<{id: number, phase: string, order: number}>} items
 */
export const reorderKanbans = async (items) => {
  const { data } = await api.post("/franchisee/activities/reorder", { items });
  return data;
};
