Skip to content

Instantly share code, notes, and snippets.

@iskenxan
Created May 10, 2021 00:51
Show Gist options
  • Save iskenxan/24776c9f2b2157643df87a7c81b88632 to your computer and use it in GitHub Desktop.
Save iskenxan/24776c9f2b2157643df87a7c81b88632 to your computer and use it in GitHub Desktop.
processInventory = (action, widget) => {
displayLoader();
return this.updateInventories(action, widget);
};
updateInventories = (action, widget) => {
switch (action) {
case "REQUEST": {
const { first, inventoryItems } = this.requestInventory(
this.inventoryItems
);
this.inventoryItems = inventoryItems;
return first;
}
case "CLEAR": {
return this.clearInventory();
}
case "ADD": {
return this.addToInventory(widget);
}
case "DELETE": {
return this.deleteFromInventory(widget);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment