Added the demand table to the SettingsProvider.jsx
This commit is contained in:
parent
36ae37025d
commit
e6b9ed19b4
@ -4,14 +4,24 @@ export const SettingsContext = createContext({});
|
|||||||
|
|
||||||
export const SettingsProvider = ({children}) => {
|
export const SettingsProvider = ({children}) => {
|
||||||
const [rounds, setRounds] = useState(localStorage.getItem("rounds") || 10);
|
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) => {
|
const updateRounds = (newValue) => {
|
||||||
localStorage.setItem("rounds", newValue);
|
localStorage.setItem("rounds", newValue);
|
||||||
setRounds(newValue);
|
setRounds(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateDemandTable = (newValue) => {
|
||||||
|
localStorage.setItem("demandTable", JSON.stringify(newValue));
|
||||||
|
setDemandTable(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsContext.Provider value={{rounds, updateRounds}}>
|
<SettingsContext.Provider value={{rounds, updateRounds, demandTable, updateDemandTable}}>
|
||||||
{children}
|
{children}
|
||||||
</SettingsContext.Provider>
|
</SettingsContext.Provider>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user