Created
May 12, 2017 18:29
-
-
Save alexbrillant/2130834cf4316f49c982a520e94df723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ACTION_TYPES } from '../actions/branchActions'; | |
const { | |
NEAREST_BRANCH_SUCCESS, | |
NEAREST_BRANCH_REQUEST, | |
NEAREST_BRANCH_FAILURE | |
} = ACTION_TYPES; | |
export const INITIAL_STATE = { searching: false, nearestBranch: null }; | |
export default (state = INITIAL_STATE, action) => { | |
let reducer; | |
console.log(action.type); | |
switch (action.type) { | |
case NEAREST_BRANCH_REQUEST: | |
reducer = nearestBranchRequest; | |
case NEAREST_BRANCH_SUCCESS: | |
reducer = nearestBranchSuccess; | |
case NEAREST_BRANCH_FAILURE: | |
reducer = nearestBranchFailure; | |
default: | |
reducer = (state, action) => state; | |
} | |
return reducer(state, action); | |
}; | |
export const nearestBranchRequest = ( | |
state, | |
{ payload: { latitude, longitude } } | |
) => { | |
return { | |
...state, | |
latitude, | |
longitude, | |
searching: true | |
}; | |
}; | |
export const nearestBranchSuccess = (state, { payload: { nearestBranch } }) => { | |
return { | |
...state, | |
nearestBranch: nearestBranch, | |
searching: false | |
}; | |
}; | |
export const nearestBranchFailure = (state, action) => { | |
return { | |
...state, | |
searching: false | |
}; | |
}; |
j'imagine que tu dépasse 80 char ou whatever la limite acceptable dans tes réglages de linter... just curious!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking good! Question comme ça pourquoi dans
nearestBranchSuccess
le header de la arrow function est sur 3 ligne tandis que dans nearestBranchSuccess tu le met inline?vs.