UNPKG

674 BJavaScriptView Raw
1import * as types from '../types';
2
3/*
4 * Message store for global messages, i.e. Network messages / Redirect messages
5 * that need to be communicated on the page itself. Ideally
6 * messages/notifications should appear within the component to give the user
7 * more context. - My 2 cents.
8 */
9export default function message(state = {
10 message: '',
11 type: 'SUCCESS'
12}, action = {}) {
13 switch (action.type) {
14 case types.LOGIN_SUCCESS_USER:
15 case types.SIGNUP_SUCCESS_USER:
16 return {...state, message: action.message, type: 'SUCCESS'};
17 case types.DISMISS_MESSAGE:
18 return {...state, message: '', type: 'SUCCESS'};
19 default:
20 return state;
21 }
22}