import api from "src/api";

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

export const getMyCarts = async () => {
  const { data } = await api.get("/cart/me");
  return data.payload;
};

export const getCart = async (cartId) => {
  const { data } = await api.get(`/cart/${cartId}`);
  return data.payload;
};

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

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

export const createScheduleCart = createMyCart;

export const updateCart = async (cartId, payload) => {
  const { data } = await api.put(`/cart/${cartId}`, payload);
  return data.payload;
};

export const deleteCart = async (cartId) => {
  const { data } = await api.delete(`/cart/${cartId}`);
  return data.payload;
};

export const createCartItem = async (payload) => {
  const { data } = await api.post("/cart-item", payload);
  return data.payload;
};

export const updateCartItem = async (cartItemId, payload) => {
  const { data } = await api.put(`/cart-item/${cartItemId}`, payload);
  return data.payload;
};

export const deleteCartItem = async (cartItemId) => {
  const { data } = await api.delete(`/cart-item/${cartItemId}`);
  return data.payload;
};
