import { api } from "@/config/axios";
import { BulkCartItem, CartResponse, SaveAllMethod } from "../types/Types";

export const bulkCart = async (params: BulkCartItem) => {
  const { data } = await api.post("/public/cart/items/bulk", params);
  return data;
};

export const increment = async (id: string | number) => {
  const { data } = await api.post(`/public/cart/items/${id}/increment`);
  return data;
};

export const decrement = async (id: string | number) => {
  const { data } = await api.post(`/public/cart/items/${id}/decrement`);
  return data;
};

export const clear = async () => {
  const { data } = await api.delete("/public/cart");
  return data;
};

export const getCartItems = async (): Promise<CartResponse> => {
  const { data } = await api.get<CartResponse>("/public/cart");
  return data;
};

export const getCartSummary = async () => {
  const { data } = await api.get("/public/cart/summary");
  return data;
};

export const saveAllMethod = async (params: SaveAllMethod) => {
  const { data } = await api.patch("/public/cart/all", params);
  return data;
};
