update fastfood,
This commit is contained in:
17
03_source/mobile/src/pages/DemoFastFoodApp/data/CartStore.js
Normal file
17
03_source/mobile/src/pages/DemoFastFoodApp/data/CartStore.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Store } from "pullstate";
|
||||
|
||||
export const CartStore = new Store({
|
||||
|
||||
total: 0,
|
||||
product_ids: []
|
||||
});
|
||||
|
||||
export const addToCart = (categorySlug, productID) => {
|
||||
|
||||
CartStore.update(s => { s.product_ids = [ ...s.product_ids, `${ categorySlug }/${ parseInt(productID) }` ]; });
|
||||
}
|
||||
|
||||
export const removeFromCart = productIndex => {
|
||||
|
||||
CartStore.update(s => { s.product_ids.splice(productIndex, 1) });
|
||||
}
|
Reference in New Issue
Block a user