Skip to content

Instantly share code, notes, and snippets.

@alexbrillant
Created May 12, 2017 18:29
Show Gist options
  • Save alexbrillant/2130834cf4316f49c982a520e94df723 to your computer and use it in GitHub Desktop.
Save alexbrillant/2130834cf4316f49c982a520e94df723 to your computer and use it in GitHub Desktop.
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
};
};
@matthewperron
Copy link

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