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
(function (history, trackingId, options) { | |
const generateId = () => { | |
return '_' + Math.random().toString(36).substr(2, 9); | |
}; | |
const getId = () => { | |
if (!localStorage.cid) { | |
localStorage.cid = generateId() | |
} | |
return localStorage.cid; | |
}; |
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 { combineReducers } from 'redux'; | |
import AppReducer from './AppReducer'; | |
import UsersReducer from './UsersReducer'; | |
import OrderReducer from './OrderReducer'; | |
import NotificationReducer from './NotificationReducer'; | |
import CommentReducer from './CommentReducer'; | |
const appReducer = combineReducers({ | |
/* your app’s top-level reducers */ |
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
const rootReducer = (state, action) => { | |
if (action.type === USER_LOGGED_OUT) { | |
// for all keys defined in your persistConfig(s) | |
storage.removeItem('persist:root') | |
// storage.removeItem('persist:otherKey') | |
state = undefined; | |
} | |
return appReducer(state, action); | |
}; |
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 { combineReducers } from 'redux'; | |
import AppReducer from './AppReducer'; | |
import UsersReducer from './UsersReducer'; | |
import OrderReducer from './OrderReducer'; | |
import NotificationReducer from './NotificationReducer'; | |
import CommentReducer from './CommentReducer'; | |
const appReducer = combineReducers({ | |
/* your app’s top-level reducers */ |
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
const rootReducer = (state, action) => { | |
// when a logout action is dispatched it will reset redux state | |
if (action.type === 'USER_LOGGED_OUT') { | |
const { users, comment } = state; | |
state = { users, comment }; | |
} | |
if (action.type === 'USER_LOGGED_IN') { |
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
const INITIAL_STATE = { | |
orderList: {}, | |
isRetrievingOrder: false, | |
errorRetrievingOrder: false, | |
errorRetrievingOrderMessage: null, | |
isSavingOrder: false, | |
errorSavingOrder: false, | |
errorSavingOrderMessage: null, | |
isCancellingOrder: false, | |
errorCancellingOrder: false, |
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 { createStore } from 'redux'; | |
// local import | |
import reducers from '../reducers'; | |
const store = | |
reducers && | |
createStore(reducers); | |
export default store; |
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
// events/reducer.js | |
const initialState = { todos: [] }; | |
export const eventsReducer = (state = initialState, action) => { | |
switch(action.type) { | |
case 'GET_EVENTS_REQUEST': | |
return { ...state, isFetching: true }; | |
case 'GET_EVENTS_SUCCESS': | |
return { ...state, isFetching: false, todos: action.payload }; | |
case 'GET_EVENTS_FAILURE': | |
return { ...state, isFetching: false, errorMessage: action.payload.message }; |
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
// todo/actions.js | |
export const getEvents = (dispatch) => () => { | |
dispatch({ type: 'GET_EVENTS_REQUEST' }); | |
return fetch('/api/v1/events') | |
.then((todos) => dispatch({ type: 'GET_EVENTS_SUCCESS', payload: todos }) | |
.catch((error) => dispatch({ type: 'GET_EVENTS_FAILURE', payload: error, error: true }); | |
}; |
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
export const FETCH_TODOS_REQUEST = 'FETCH_TODOS_REQUEST'; | |
export const FETCH_TODOS_SUCCESS = 'FETCH_TODOS_SUCCESS'; | |
export const FETCH_TODOS_FAILURE = 'FETCH_TODOS_FAILURE'; |
OlderNewer