chore: update
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
import {
|
||||
createContext,
|
||||
useContext,
|
||||
useState,
|
||||
useEffect,
|
||||
type ReactNode,
|
||||
@@ -55,7 +54,7 @@ interface ToastMessage {
|
||||
type: "success" | "error" | "warning" | "info";
|
||||
}
|
||||
|
||||
const CartContext = createContext<CartContextType | undefined>(undefined);
|
||||
export const CartContext = createContext<CartContextType | undefined>(undefined);
|
||||
|
||||
export function CartProvider({ children }: { children: ReactNode }) {
|
||||
const [cartItems, setCartItems] = useState<CartItem[]>([]);
|
||||
@@ -201,9 +200,10 @@ export function CartProvider({ children }: { children: ReactNode }) {
|
||||
|
||||
const requestData = {
|
||||
username,
|
||||
product_id: item.product_id || 0,
|
||||
name_product: cleanName,
|
||||
category: category,
|
||||
quantity: Number(item.quantity), // ✨ Grammes (5, 10, 25)
|
||||
quantity: Number(item.quantity),
|
||||
price: Number(item.price) || 0,
|
||||
};
|
||||
|
||||
@@ -345,10 +345,3 @@ export function CartProvider({ children }: { children: ReactNode }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function useCart() {
|
||||
const context = useContext(CartContext);
|
||||
if (!context) {
|
||||
throw new Error("useCart must be used within a CartProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { useContext } from "react";
|
||||
import { CartContext } from "./CartContext";
|
||||
|
||||
export function useCart() {
|
||||
const context = useContext(CartContext);
|
||||
if (!context) {
|
||||
throw new Error("useCart must be used within a CartProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in New Issue
Block a user