Update requirement files with new feature templates and fix backend API error message, along with mobile project config updates and documentation improvements
This commit is contained in:
@@ -1,27 +1,22 @@
|
||||
import { Store } from "pullstate";
|
||||
import { Store } from 'pullstate';
|
||||
|
||||
const CartStore = new Store({
|
||||
|
||||
cart: []
|
||||
cart: [],
|
||||
});
|
||||
|
||||
export default CartStore;
|
||||
|
||||
export const addToCart = product => {
|
||||
export const addToCart = (product) => {
|
||||
const currentCart = CartStore.getRawState().cart;
|
||||
const added = !currentCart.includes(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];
|
||||
}
|
||||
});
|
||||
|
||||
CartStore.update(s => {
|
||||
|
||||
if (currentCart.includes(product)) {
|
||||
|
||||
s.cart = currentCart.filter(current => current !== product);
|
||||
} else {
|
||||
|
||||
s.cart = [ ...s.cart, product ];
|
||||
}
|
||||
});
|
||||
|
||||
return added;
|
||||
}
|
||||
return added;
|
||||
};
|
||||
|
@@ -1,35 +1,29 @@
|
||||
import { Store } from "pullstate";
|
||||
import { Store } from 'pullstate';
|
||||
|
||||
const FavouritesStore = new Store({
|
||||
|
||||
favourites: []
|
||||
favourites: [],
|
||||
});
|
||||
|
||||
export default FavouritesStore;
|
||||
|
||||
export const checkIfFavourite = product => {
|
||||
|
||||
const currentFavourites = FavouritesStore.getRawState().favourites;
|
||||
export const checkIfFavourite = (product) => {
|
||||
const currentFavourites = FavouritesStore.getRawState().favourites;
|
||||
const isFavourite = currentFavourites.includes(product);
|
||||
|
||||
return isFavourite;
|
||||
}
|
||||
return isFavourite;
|
||||
};
|
||||
|
||||
export const addToFavourites = (product, category) => {
|
||||
const currentFavourites = FavouritesStore.getRawState().favourites;
|
||||
const added = !currentFavourites.includes(product);
|
||||
|
||||
const currentFavourites = FavouritesStore.getRawState().favourites;
|
||||
const added = !currentFavourites.includes(product);
|
||||
FavouritesStore.update((s) => {
|
||||
if (!added) {
|
||||
s.favourites = currentFavourites.filter((current) => current !== product);
|
||||
} else {
|
||||
s.favourites = [...s.favourites, product];
|
||||
}
|
||||
});
|
||||
|
||||
FavouritesStore.update(s => {
|
||||
|
||||
if (!added) {
|
||||
|
||||
s.favourites = currentFavourites.filter(current => current !== product);
|
||||
} else {
|
||||
|
||||
s.favourites = [ ...s.favourites, product ];
|
||||
}
|
||||
});
|
||||
|
||||
return added;
|
||||
}
|
||||
return added;
|
||||
};
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
const getState = state => state;
|
||||
const getState = (state) => state;
|
||||
|
||||
// General getters
|
||||
export const getFavourites = createSelector(getState, state => state.favourites);
|
||||
export const checkFavourites = product => createSelector(getState, state => state.favourites.includes(product));
|
||||
export const getCart = createSelector(getState, state => state.cart);
|
||||
export const getCartCount = createSelector(getState, state => state.cart.length);
|
||||
export const getFavourites = createSelector(getState, (state) => state.favourites);
|
||||
export const checkFavourites = (product) =>
|
||||
createSelector(getState, (state) => state.favourites.includes(product));
|
||||
export const getCart = createSelector(getState, (state) => state.cart);
|
||||
export const getCartCount = createSelector(getState, (state) => state.cart.length);
|
||||
|
@@ -1,2 +1,2 @@
|
||||
export { default as FavouritesStore } from "./FavouritesStore";
|
||||
export { default as CartStore } from "./CartStore";
|
||||
export { default as FavouritesStore } from './FavouritesStore';
|
||||
export { default as CartStore } from './CartStore';
|
||||
|
Reference in New Issue
Block a user