import api from "src/api";

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

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

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

export const deleteKanban = async (id) => {
  const { data } = await api.delete(`/kanban/${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("/kanban/reorder", { items });
  return data;
};
