- Remove all cards
+ Reset the order
diff --git a/static/js/shop/SummaryCrateHeader.jsx b/static/js/shop/SummaryCrateHeader.jsx
index 232921b7..f8f69237 100644
--- a/static/js/shop/SummaryCrateHeader.jsx
+++ b/static/js/shop/SummaryCrateHeader.jsx
@@ -4,6 +4,7 @@ import {useShopStore} from "./shop_store";
// #!render_count
import {useRenderCount} from "@uidotdev/usehooks";
+import {CrateMode} from "./CrateMode";
export function SummaryCrateHeader({crate_index}) {
// #!render_count
@@ -16,6 +17,9 @@ export function SummaryCrateHeader({crate_index}) {
const crate_mode = useShopStore((state) => state.crates[crate_index].crate_mode);
const crate_id = useShopStore((state) => state.crates[crate_index].id);
+ const crate_name = useShopStore((state) => state.crates[crate_index].name);
+ const modes_order = useShopStore((state) => state.modes_order);
+
// #!render_count
console.log("SummaryCrateHeader renders: ", renderCount)
@@ -24,7 +28,7 @@ export function SummaryCrateHeader({crate_index}) {
return (
- {crate_type.name}
+ {!!crate_name ? crate_name : crate_type.name + " #" + crate_index}
{`${currency} ${formatMoney(crate_type.price)}`}
@@ -33,9 +37,14 @@ export function SummaryCrateHeader({crate_index}) {
-
delCrate(crate_id)}>
-
-
+ {
+ modes_order.includes(crate_mode) ? (
+
delCrate(crate_id)}>
+
+
+ ) :
+ }
+
diff --git a/static/js/shop/shop_store.js b/static/js/shop/shop_store.js
index 0f08ba85..aeea2977 100644
--- a/static/js/shop/shop_store.js
+++ b/static/js/shop/shop_store.js
@@ -238,19 +238,17 @@ const useHighlighted = ((set, get) => ({
const useCart = ((set, get) => ({
crates: shared_data.columns.crates,
active_crate: "crate0",
+ _defaultCrates: Array.from(shared_data.columns.crates),
_newCrate: (crate_id) => set((state) => ({
crates: state.crates.toSpliced(-1, 0, {
+ ...state._defaultCrates[0],
id: crate_id || "crate" + state.crates.length,
- crate_mode: "rack",
- items: [],
- warnings: [],
- occupiedHP: 0
}),
active_crate: crate_id || "crate" + state.crates.length
})),
delCrate: (id) => set(state => ({
- crates: state.crates.filter((crate => crate.id !== id)),
+ crates: state.crates.filter((crate => crate.id !== id || !state.modes_order.includes(crate.crate_mode))),
active_crate: state.active_crate === id ? null : state.active_crate,
})),
_setCrateMode: (id, mode) => set(state => ({
@@ -332,7 +330,7 @@ const useCart = ((set, get) => ({
})
})),
clearAll: () => set(state => ({
- crates: []
+ crates: state._defaultCrates
})),
_updateOptions: (crate_id, index, new_options) => set(state => ({
crates: state.crates.map((crate, _i) => {