From 59f8af3ef427c05318735f793b71dfb84fffa5f5 Mon Sep 17 00:00:00 2001 From: Voiddp Date: Thu, 6 Mar 2025 16:04:11 +0000 Subject: [PATCH] added summary dialog summary as button added statistic into summary --- .../planner/depot/MaterialsNeeded.tsx | 37 +- .../planner/depot/MaterialsSummaryDialog.tsx | 416 ++++++++++++++++++ 2 files changed, 446 insertions(+), 7 deletions(-) create mode 100644 src/components/planner/depot/MaterialsSummaryDialog.tsx diff --git a/src/components/planner/depot/MaterialsNeeded.tsx b/src/components/planner/depot/MaterialsNeeded.tsx index b3f669b6..ea20acfb 100644 --- a/src/components/planner/depot/MaterialsNeeded.tsx +++ b/src/components/planner/depot/MaterialsNeeded.tsx @@ -12,6 +12,7 @@ import ItemNeeded from "./ItemNeeded"; import getGoalIngredients from "util/fns/depot/getGoalIngredients"; import DepotItem from "types/depotItem"; import ExportImportDialog from "./ExportImportDialog"; +import MaterialsSummaryDialog from "./MaterialsSummaryDialog"; import Board from "components/base/Board"; import canCompleteByCrafting from "util/fns/depot/canCompleteByCrafting"; import { LocalStorageSettings } from "types/localStorageSettings"; @@ -43,6 +44,8 @@ const MaterialsNeeded = React.memo((props: Props) => { const [exportImportOpen, setExportImportOpen] = useState(false); + const [summaryOpen, setSummaryOpen] = useState(false); + const {setAnchorEl, menuProps, menuButtonProps} = useMenu(); const craftToggleTooltips = ["Toggle only craftable materials ON - use with Goals and Filters","Toggle all crafting states ON","Reset all crafting states"]; @@ -78,6 +81,7 @@ const MaterialsNeeded = React.memo((props: Props) => { const [ rawValues, setRawValues ] = useState({} as Record); //states to keep data beetwen renders const [ savedStates, setSavedStates ] = useState({ + goalsMaterials: {} as Record, materialsNeeded: {} as Record, craftableItems: {} as Record, sortedMaterialsNeeded: [] as [string, number][], @@ -100,6 +104,8 @@ const MaterialsNeeded = React.memo((props: Props) => { }); } + const goalsMaterials = {...materialsNeeded}; + // 3. calculate what ingredients can be fulfilled by crafting const _depot = { ...depot, ..._rawValues }; // need to hypothetically deduct from stock const { craftableItems, ingredientToCraftedItemsMapping } = canCompleteByCrafting( @@ -132,6 +138,7 @@ const MaterialsNeeded = React.memo((props: Props) => { }); setSavedStates({ + goalsMaterials, materialsNeeded, craftableItems, sortedMaterialsNeeded, @@ -359,22 +366,27 @@ const MaterialsNeeded = React.memo((props: Props) => { <> - Depot + !depotIsUnsaved + ? + Depot - : ( - Depot + Depot unsaved + sx={{ color: "primary.main", display: { xs: "none", lg: "unset" } }}>unsaved ) } TitleAction={ +