doc: add getBasketTotal method
This commit is contained in:
1 parent
27462887ac
commit
d64671d0f5
1 file changed
+3
@@ -2,6 +2,9 @@ export const initialState = {
|
|||||||
basket: [],
|
basket: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getBasketTotal = (basket) =>
|
||||||
|
basket?.reduce((amount, item) => item.price + amount, 0);
|
||||||
|
|
||||||
const reducer = (state, action) => {
|
const reducer = (state, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case "ADD_TO_BASKET":
|
case "ADD_TO_BASKET":
|
||||||
|
|||||||
Reference in new issue
Block a user