patch revert some of Epoch refactor
This commit is contained in:
parent
74bbca028f
commit
6bdd0a9d65
4 changed files with 22 additions and 14 deletions
|
@ -7,25 +7,22 @@ import { render } from 'react-dom';
|
||||||
|
|
||||||
|
|
||||||
const Epochs = ({epochs, errors, dispatch}) => {
|
const Epochs = ({epochs, errors, dispatch}) => {
|
||||||
const handleEvent = func => e => {
|
const addEpoch = e => {
|
||||||
e.preventDefault();
|
e.preventDefault()
|
||||||
return func;
|
|
||||||
}
|
|
||||||
|
|
||||||
const addEpoch = e => handleEvent(() => {
|
|
||||||
let index = epochs.length + 1;
|
let index = epochs.length + 1;
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'ADD_EPOCH',
|
type: 'ADD_EPOCH',
|
||||||
value: {name: `epoch ${index}`}
|
value: {name: `epoch ${index}`}
|
||||||
})
|
})
|
||||||
})(e)
|
}
|
||||||
|
|
||||||
const removeEpoch = e => handleEvent(
|
const removeEpoch = (e, epochName) => {
|
||||||
|
e.preventDefault()
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'REMOVE_EPOCH',
|
type: 'REMOVE_EPOCH',
|
||||||
value: {name: epochName}
|
value: {name: epochName}
|
||||||
})
|
});
|
||||||
)(e);
|
}
|
||||||
|
|
||||||
const updateEpoch = (epoch, epochIndex) => {
|
const updateEpoch = (epoch, epochIndex) => {
|
||||||
const dispatchValue = {
|
const dispatchValue = {
|
||||||
|
|
|
@ -3,12 +3,22 @@ import './Latl.scss';
|
||||||
|
|
||||||
const Latl = ({latl, dispatch}) => {
|
const Latl = ({latl, dispatch}) => {
|
||||||
const { innerWidth, innerHeight } = window;
|
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 (
|
return (
|
||||||
<div className="Latl">
|
<div className="Latl">
|
||||||
<h3>.LATL</h3>
|
<h3>.LATL</h3>
|
||||||
<textarea name="latl" id="latl"
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
export const setLatl = (state, action) => {
|
export const setLatl = (state, action) => {
|
||||||
return {...state};
|
let latl = action.value;
|
||||||
|
return {...state, latl};
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ describe('LATL', () => {
|
||||||
const state = initState();
|
const state = initState();
|
||||||
const action = {
|
const action = {
|
||||||
type: 'SET_LATL',
|
type: 'SET_LATL',
|
||||||
value: {}
|
value: ''
|
||||||
}
|
}
|
||||||
const returnedState = stateReducer(state, action)
|
const returnedState = stateReducer(state, action)
|
||||||
expect(returnedState).toStrictEqual(state);
|
expect(returnedState).toStrictEqual(state);
|
||||||
|
|
Loading…
Reference in a new issue