diff --git a/static/js/shop/Cart.jsx b/static/js/shop/Cart.jsx index 9a1b7e52..e85bc94d 100644 --- a/static/js/shop/Cart.jsx +++ b/static/js/shop/Cart.jsx @@ -1,6 +1,6 @@ import React from 'react' import {Droppable} from "@hello-pangea/dnd"; -import {cartStyle, nbrOccupiedSlotsInCrate} from "./utils"; +import {cartStyle} from "./utils"; import {ProductCartItem} from "./ProductCartItem.jsx"; import {FakePlaceholder} from "./FakePlaceholder.jsx"; import {FillExtData} from "./options/utils"; diff --git a/static/js/shop/Crate.jsx b/static/js/shop/Crate.jsx index 0b9fabb2..805c82fd 100644 --- a/static/js/shop/Crate.jsx +++ b/static/js/shop/Crate.jsx @@ -7,12 +7,19 @@ import {CrateWarnings} from "./CrateWarnings.jsx"; * Component that displays the main crate with reminder rules. * It includes and rules */ -export function Crate({data, handleToggleOverlayRemove, handleDeleteItem, handleShowOverlayRemove, handleCardsUpdated, isMobile, isTouch}) { +export function Crate({data, handleToggleOverlayRemove, handleDeleteItem, handleShowOverlayRemove, handleCardsUpdated, isMobile, isTouch, onDelete}) { return (
+
+ Delete crate + +
+
{ + onAddCrate("crate" + Object.entries(crates).length); + } + return ( {Object.entries(crates).map(([crate_id, crate], index) => Crate #{`${index}`} - + )} + + + Add new crate + + + ) } \ No newline at end of file diff --git a/static/js/shop/Shop.jsx b/static/js/shop/Shop.jsx index 41e4d9d7..4dd5ed31 100644 --- a/static/js/shop/Shop.jsx +++ b/static/js/shop/Shop.jsx @@ -48,6 +48,8 @@ export class Shop extends PureComponent { this.handleClickOpenImport = this.handleClickOpenImport.bind(this); this.handleLoadCustomConf = this.handleLoadCustomConf.bind(this); this.handleCardsUpdated = this.handleCardsUpdated.bind(this); + this.onAddCrate = this.onAddCrate.bind(this); + this.onDeleteCrate = this.onDeleteCrate.bind(this); this.timer = null; this.timer_remove = null; @@ -81,6 +83,7 @@ export class Shop extends PureComponent { * trigger again this function (componentDidUpdate) and thus, * making an infinite loop. */ + console.log("componentDidUpdate") return; if ( (prevState.columns.crates !== this.state.columns.crates.items) || @@ -493,6 +496,34 @@ export class Shop extends PureComponent { }); } + onAddCrate(id) { + this.setState({ + ...this.state, + columns: { + ...this.state.columns, + crates: { + ...this.state.columns.crates, + [id]: { + crate_type: "rack", + items: [] + }} + } + }); + } + onDeleteCrate(id) { + let new_state = { + ...this.state, + columns: { + ...this.state.columns, + crates: { + ...this.state.columns.crates, + [id]: undefined + } + }}; + delete new_state.columns.crates[id]; + this.setState(new_state); + } + render() { const { @@ -551,6 +582,10 @@ export class Shop extends PureComponent { cratesList={ } summaryPrice={