1
0

Added the demand table to the SettingsProvider.jsx

This commit is contained in:
Mathias Wagner 2023-11-22 13:42:03 +01:00
parent 36ae37025d
commit e6b9ed19b4
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -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 (
<SettingsContext.Provider value={{rounds, updateRounds}}>
<SettingsContext.Provider value={{rounds, updateRounds, demandTable, updateDemandTable}}>
{children}
</SettingsContext.Provider>
);