diff --git a/package-lock.json b/package-lock.json
index 4c8b0154..b1e5e38c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -24,7 +24,8 @@
"react-dom": "^18.2.0",
"uuid": "^9.0.1",
"webpack": "^5.89.0",
- "webpack-cli": "^5.1.4"
+ "webpack-cli": "^5.1.4",
+ "zustand": "^4.4.7"
}
},
"node_modules/@ampproject/remapping": {
@@ -4915,6 +4916,34 @@
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
+ },
+ "node_modules/zustand": {
+ "version": "4.4.7",
+ "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.4.7.tgz",
+ "integrity": "sha512-QFJWJMdlETcI69paJwhSMJz7PPWjVP8Sjhclxmxmxv/RYI7ZOvR5BHX+ktH0we9gTWQMxcne8q1OY8xxz604gw==",
+ "dev": true,
+ "dependencies": {
+ "use-sync-external-store": "1.2.0"
+ },
+ "engines": {
+ "node": ">=12.7.0"
+ },
+ "peerDependencies": {
+ "@types/react": ">=16.8",
+ "immer": ">=9.0",
+ "react": ">=16.8"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "immer": {
+ "optional": true
+ },
+ "react": {
+ "optional": true
+ }
+ }
}
}
}
diff --git a/package.json b/package.json
index cdf0984e..3aa28660 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,8 @@
"uuid": "^9.0.1",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
- "json-logic-js": "^2.0.2"
+ "json-logic-js": "^2.0.2",
+ "zustand": "^4.4.7"
},
"babel": {
"presets": [
diff --git a/static/js/shop/Backlog.jsx b/static/js/shop/Backlog.jsx
index dc0985a9..c207e6a0 100644
--- a/static/js/shop/Backlog.jsx
+++ b/static/js/shop/Backlog.jsx
@@ -1,118 +1,106 @@
-import React, {PureComponent} from 'react';
-import PropTypes from "prop-types";
+import React from 'react';
import {v4 as uuidv4} from "uuid";
import {Droppable} from "@hello-pangea/dnd";
import {ProductItem} from "./ProductItem.jsx";
+import {useShopStore} from "./shop_store";
/**
* Component that renders the backlog in the aside
*/
-export class Backlog extends PureComponent {
-
- static get propTypes() {
- return {
- currency: PropTypes.string,
- data: PropTypes.object.isRequired,
- items: PropTypes.object,
- isMobile: PropTypes.bool,
- onClickAddItem: PropTypes.func,
- onClickToggleMobileSideMenu: PropTypes.func,
- };
- }
-
- static get defaultProps() {
- return {
- items: {},
- };
- }
-
- render() {
- const {
- currency,
- data,
- items,
- onClickAddItem,
- onClickToggleMobileSideMenu,
- isMobile,
- } = this.props;
+export function Backlog() {
+ const {
+ currency,
+ data,
+ items,
+ onClickAddItem,
+ onClickToggleMobileSideMenu,
+ isMobile,
+ } = useShopStore(state=> ({
+ currency: state.currency,
+ data: state.groups,
+ items: state.cards,
+ onClickAddItem: state.addCardFromBacklog,
+ onClickToggleMobileSideMenu: state.switchSideMenu,
+ isMobile: state.isMobile
+ }));
- const ordered_groups = data.categories.map(groupItem => ({
- name: groupItem.name,
- items: groupItem.itemIds.map(itemId => items[itemId])
- }));
- let item_index = -1;
- const groups = ordered_groups.map((group, g_index) => {
- return (
-
-
-