import api from "src/api";

export const getTreasuryAccountsMe = async () => {
  const { data } = await api.get("/franchisee/financial/treasury/accounts");
  return data.payload;
};

export const createTreasuryAccountMe = async (payload) => {
  const { data } = await api.post("/franchisee/financial/treasury/accounts", payload);
  return data.payload;
};

export const updateTreasuryAccountMe = async (id, payload) => {
  const { data } = await api.put(`/franchisee/financial/treasury/accounts/${id}`, payload);
  return data.payload;
};

export const deleteTreasuryAccountMe = async (id) => {
  const { data } = await api.delete(`/franchisee/financial/treasury/accounts/${id}`);
  return data;
};

export const getTreasuryLaunchesMe = async (accountId) => {
  const { data } = await api.get("/franchisee/financial/treasury/launches", {
    params: accountId ? { account_id: accountId } : {},
  });
  return data.payload;
};

export const createTreasuryLaunchMe = async (payload) => {
  const { data } = await api.post("/franchisee/financial/treasury/launches", payload);
  return data.payload;
};

export const updateTreasuryLaunchMe = async (id, payload) => {
  const { data } = await api.put(`/franchisee/financial/treasury/launches/${id}`, payload);
  return data.payload;
};

export const deleteTreasuryLaunchMe = async (id) => {
  await api.delete(`/franchisee/financial/treasury/launches/${id}`);
};
