Coupon system working properly
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
apiRemoveCartItem,
|
||||
apiClearCart,
|
||||
apiApplyCoupon,
|
||||
apiRemoveCoupon,
|
||||
apiCheckout,
|
||||
apiCancelCheckout,
|
||||
} from "@/lib/cartApi";
|
||||
@@ -124,6 +125,17 @@ export function CartProvider({ children }) {
|
||||
[token, selectedStoreId]
|
||||
);
|
||||
|
||||
const removeCoupon = useCallback(
|
||||
async () => {
|
||||
if (!token || !selectedStoreId) throw new Error("Select a store first");
|
||||
const updated = await apiRemoveCoupon(token, selectedStoreId);
|
||||
setCart(updated);
|
||||
|
||||
return updated;
|
||||
},
|
||||
[token, selectedStoreId]
|
||||
);
|
||||
|
||||
const checkout = useCallback(
|
||||
async () => {
|
||||
if (!token || !selectedStoreId) throw new Error("Select a store first");
|
||||
@@ -159,6 +171,7 @@ export function CartProvider({ children }) {
|
||||
removeItem,
|
||||
clearCart,
|
||||
applyCoupon,
|
||||
removeCoupon,
|
||||
checkout,
|
||||
cancelCheckout,
|
||||
refreshCart,
|
||||
|
||||
Reference in New Issue
Block a user