From e6b9ed19b42d5b3cc4db89253a806441ca9d9c89 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Wed, 22 Nov 2023 13:42:03 +0100 Subject: [PATCH] Added the demand table to the SettingsProvider.jsx --- client/src/common/contexts/SettingsProvider.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/src/common/contexts/SettingsProvider.jsx b/client/src/common/contexts/SettingsProvider.jsx index fdd35be..ffa12b4 100644 --- a/client/src/common/contexts/SettingsProvider.jsx +++ b/client/src/common/contexts/SettingsProvider.jsx @@ -4,14 +4,24 @@ export const SettingsContext = createContext({}); export const SettingsProvider = ({children}) => { const [rounds, setRounds] = useState(localStorage.getItem("rounds") || 10); + const [demandTable, setDemandTable] = useState(JSON.parse(localStorage.getItem("demandTable")) || { + 0: 50, + 1800: 40, + 2200: 30 + }); const updateRounds = (newValue) => { localStorage.setItem("rounds", newValue); setRounds(newValue); } + const updateDemandTable = (newValue) => { + localStorage.setItem("demandTable", JSON.stringify(newValue)); + setDemandTable(newValue); + } + return ( - + {children} );