patch revert some of Epoch refactor

This commit is contained in:
Sorrel Bri 2020-03-01 15:49:56 -08:00
parent 74bbca028f
commit 6bdd0a9d65
4 changed files with 22 additions and 14 deletions

View file

@ -7,25 +7,22 @@ import { render } from 'react-dom';
const Epochs = ({epochs, errors, dispatch}) => {
const handleEvent = func => e => {
e.preventDefault();
return func;
}
const addEpoch = e => handleEvent(() => {
const addEpoch = e => {
e.preventDefault()
let index = epochs.length + 1;
dispatch({
type: 'ADD_EPOCH',
value: {name: `epoch ${index}`}
})
})(e)
}
const removeEpoch = e => handleEvent(
const removeEpoch = (e, epochName) => {
e.preventDefault()
dispatch({
type: 'REMOVE_EPOCH',
value: {name: epochName}
})
)(e);
});
}
const updateEpoch = (epoch, epochIndex) => {
const dispatchValue = {

View file

@ -3,12 +3,22 @@ import './Latl.scss';
const Latl = ({latl, dispatch}) => {
const { innerWidth, innerHeight } = window;
console.log(innerWidth, innerHeight)
const handleChange = e => {
console.log(e.target.value)
const setLatlAction = {
type: 'SET_LATL',
value: e.target.value
}
dispatch(setLatlAction)
}
return (
<div className="Latl">
<h3>.LATL</h3>
<textarea name="latl" id="latl"
cols={'' + Math.floor(innerWidth / 15)} rows={'' + Math.floor(innerHeight / 30)}
cols={'' + Math.floor(innerWidth / 15)} rows={'' + Math.floor(innerHeight / 30)}
onChange={e => dispatch({type:'SET_LATL', value: e.target.value})}
/>
</div>
);

View file

@ -1,5 +1,6 @@
export const setLatl = (state, action) => {
return {...state};
let latl = action.value;
return {...state, latl};
}

View file

@ -6,7 +6,7 @@ describe('LATL', () => {
const state = initState();
const action = {
type: 'SET_LATL',
value: {}
value: ''
}
const returnedState = stateReducer(state, action)
expect(returnedState).toStrictEqual(state);