add form to load prior runs from local storage

This commit is contained in:
Sorrel Bri 2019-11-29 23:22:58 -08:00
parent 02b21b2aec
commit 949ae87026
3 changed files with 25 additions and 2 deletions

5
package-lock.json generated
View file

@ -9253,6 +9253,11 @@
}
}
},
"local-storage": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/local-storage/-/local-storage-2.0.0.tgz",
"integrity": "sha512-/0sRoeijw7yr/igbVVygDuq6dlYCmtsuTmmpnweVlVtl/s10pf5BCq8LWBxW/AMyFJ3MhMUuggMZiYlx6qr9tw=="
},
"locate-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",

View file

@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"local-storage": "^2.0.0",
"node-sass": "^4.13.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",

View file

@ -1,7 +1,10 @@
import React from 'react';
import React, { useState } from 'react';
import './Options.scss';
import ls from 'local-storage';
const Options = props => {
const [ load, setLoad ] = useState('');
const handleRadioChange = e => {
props.setOptions({...props.options, [e.target.name]: e.target.id})
}
@ -9,7 +12,6 @@ const Options = props => {
const handleCheckChange = e => {
props.setOptions({...props.options, [e.target.name]: e.target.checked})
}
return (
<div className="Options" data-testid="Options">
<h3>Modeling Options</h3>
@ -53,6 +55,21 @@ const Options = props => {
<input type="submit"></input>
</form>
<form onSubmit={() => {}}>
<label>
Load from a prior run:
<select value={load} onChange={e=>setLoad(e.target.value)}>
{localStorage.phonoChange
? ls.get('phonoChange').map(priorRun => {
return <option key={priorRun.name} value={priorRun.name}>{priorRun.name}</option>
}
) : <></>}
</select>
</label>
<input type="submit" value="Submit" />
</form>
</div>
);
}