From e7a7673d68c0782c76b0bf427012cb726aaf6851 Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Fri, 28 Feb 2020 11:58:16 -0800 Subject: [PATCH] add clear output to Options component, remove future options --- src/components/Options.js | 21 ++++++++++++++------- src/components/Options.scss | 4 ++-- src/reducers/reducer.clear.js | 3 +++ src/reducers/reducer.js | 3 +++ src/reducers/reducer.results.js | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 src/reducers/reducer.clear.js diff --git a/src/components/Options.js b/src/components/Options.js index f4ef7bc..33eb612 100644 --- a/src/components/Options.js +++ b/src/components/Options.js @@ -24,14 +24,20 @@ const Options = ({ options, dispatch }) => { }); } + const handleOutputClearSubmit = e => { + e.preventDefault(); + console.log('clearing') + dispatch({ + type: 'CLEAR', + value: {} + }); + } + return (

Modeling Options

handleFormSubmit(e, options)} data-testid="Options-form"> - - {/*
Output
*/} - { output - handleRadioChange(e)} @@ -57,13 +63,14 @@ const Options = ({ options, dispatch }) => { /> + */} + handleOutputClearSubmit(e)}/>
-
{}}> + {/* {}}> -
+ */}
); } diff --git a/src/components/Options.scss b/src/components/Options.scss index 3fc726f..263ca2f 100644 --- a/src/components/Options.scss +++ b/src/components/Options.scss @@ -1,8 +1,8 @@ div.Options { form { - display: flex; - flex-flow: column nowrap; + display: grid; + grid-template-columns: 1fr 1fr; } } \ No newline at end of file diff --git a/src/reducers/reducer.clear.js b/src/reducers/reducer.clear.js new file mode 100644 index 0000000..0a94b19 --- /dev/null +++ b/src/reducers/reducer.clear.js @@ -0,0 +1,3 @@ +export const clearOutput = (state, action) => { + return { ...state, results: [], errors: {} }; +} \ No newline at end of file diff --git a/src/reducers/reducer.js b/src/reducers/reducer.js index 92de082..b14da78 100644 --- a/src/reducers/reducer.js +++ b/src/reducers/reducer.js @@ -11,6 +11,7 @@ import { run } from './reducer.results'; import type { resultsAction } from './reducer.results' import { initState } from './reducer.init'; import type { initAction } from './reducer.init'; +import { clearOutput } from './reducer.clear'; export type stateType = { lexicon: Array<{lexeme: string, epoch: epochType}>, @@ -57,6 +58,8 @@ export const stateReducer = (state: stateType, action: actionType): stateType => case 'SET_OPTIONS': return setOptions(state, action); + case 'CLEAR': return clearOutput(state, action); + case 'RUN': return run(state, action); default: return state; diff --git a/src/reducers/reducer.results.js b/src/reducers/reducer.results.js index dba1101..ca86976 100644 --- a/src/reducers/reducer.results.js +++ b/src/reducers/reducer.results.js @@ -280,6 +280,6 @@ export const run = (state: stateType, action: resultsAction): stateType => { return {...state, results, errors: {} } } catch (err) { console.log(err) - return {...state, errors: err }; + return {...state, errors: err, results:[] }; } } \ No newline at end of file