mirror of
https://github.com/TrentSPalmer/fcc-challenges.git
synced 2025-08-23 18:23:58 -07:00
initial version random-quote-machine
This commit is contained in:
13
random-quote-machine/src/reducers/asyncQuoteReducer.js
Normal file
13
random-quote-machine/src/reducers/asyncQuoteReducer.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { REQUESTING_QUOTE } from "../actions/quoteFetchActionCreator";
|
||||
import { RECEIVED_QUOTE } from "../actions/quoteFetchActionCreator";
|
||||
|
||||
export default (state = { fetching: false, quote: "" }, action) => {
|
||||
switch (action.type) {
|
||||
case REQUESTING_QUOTE:
|
||||
return { fetching: true, quote: "" };
|
||||
case RECEIVED_QUOTE:
|
||||
return { fetching: false, quote: action.newQuote };
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
10
random-quote-machine/src/reducers/colorCounterReducer.js
Normal file
10
random-quote-machine/src/reducers/colorCounterReducer.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { INCCOLORCOUNT } from "../actions/colorCounterAction";
|
||||
|
||||
export default (state = 1, action) => {
|
||||
switch (action.type) {
|
||||
case INCCOLORCOUNT:
|
||||
return action.count;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
8
random-quote-machine/src/reducers/rootReducer.js
Normal file
8
random-quote-machine/src/reducers/rootReducer.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { combineReducers } from "redux";
|
||||
import colorCounterReducer from "./colorCounterReducer";
|
||||
import asyncQuoteReducer from "./asyncQuoteReducer";
|
||||
|
||||
export default combineReducers({
|
||||
colorCount: colorCounterReducer,
|
||||
newQuote: asyncQuoteReducer,
|
||||
});
|
Reference in New Issue
Block a user