update adding demo app,

This commit is contained in:
louiscklaw
2025-06-04 14:46:31 +08:00
parent b78709db9b
commit dff07ddcb0
82 changed files with 3552 additions and 97 deletions

View File

@@ -0,0 +1,27 @@
import { Store } from "pullstate";
const CartStore = new Store({
cart: []
});
export default CartStore;
export const addToCart = product => {
const currentCart = CartStore.getRawState().cart;
const added = !currentCart.includes(product);
CartStore.update(s => {
if (currentCart.includes(product)) {
s.cart = currentCart.filter(current => current !== product);
} else {
s.cart = [ ...s.cart, product ];
}
});
return added;
}