You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
const Immutable = require('immutable');
|
|
|
|
const exclamations = [
|
|
'Congratulations!',
|
|
'Yippee!',
|
|
'Woohoo!',
|
|
'Nice work!',
|
|
'Great job!',
|
|
'Boom!',
|
|
'All finished!',
|
|
'Shazam!'
|
|
];
|
|
|
|
import * as MessageActions from '../../actions/board/message.actions';
|
|
|
|
const initial = { message: '', hidden: true };
|
|
|
|
const reducer = (state = initial, action) => {
|
|
if (action.type !== MessageActions.MESSAGE_ACTION) {
|
|
return state;
|
|
}
|
|
|
|
switch (action.action) {
|
|
case MessageActions.EXCLAIM:
|
|
const msg = exclamations[Math.floor(Math.random() * exclamations.length)];
|
|
return Immutable.Map(state)
|
|
.set('hidden', false)
|
|
.set('message', msg)
|
|
.toObject();
|
|
|
|
case MessageActions.SHOW:
|
|
return Immutable.Map(state)
|
|
.set('hidden', false)
|
|
.set('message', action.message)
|
|
.toObject();
|
|
|
|
case MessageActions.HIDE:
|
|
return Immutable.Map(state)
|
|
.set('hidden', true)
|
|
.toObject();
|
|
}
|
|
|
|
return state;
|
|
};
|
|
|
|
export default reducer;
|
|
|