parent
c45a2bdf5a
commit
a660ff6b78
11 changed files with 148 additions and 80 deletions
@ -0,0 +1,17 @@ |
|||||||
|
// Message component actions and action creators.
|
||||||
|
export const MESSAGE_ACTION = 'MESSAGE_ACTION'; |
||||||
|
export const DISPLAY = 'DISPLAY'; |
||||||
|
export const HIDE = 'HIDE'; |
||||||
|
|
||||||
|
export const display = (msg1, msg2, hidden) => ({ |
||||||
|
type: MESSAGE_ACTION, |
||||||
|
action: DISPLAY, |
||||||
|
message1: msg1, |
||||||
|
message2: msg2, |
||||||
|
hidden: hidden |
||||||
|
}); |
||||||
|
|
||||||
|
export const hide = () => ({ |
||||||
|
type: MESSAGE_ACTION, |
||||||
|
action: HIDE |
||||||
|
}); |
@ -1,9 +1,14 @@ |
|||||||
// Scorebar component actions and action creators.
|
// Scorebar component actions and action creators.
|
||||||
export const SCOREBAR_ACTION = 'SCOREBAR_ACTION'; |
export const SCOREBAR_ACTION = 'SCOREBAR_ACTION'; |
||||||
export const MUNCH = 'MUNCH'; |
export const MUNCH_SUCCEEDED = 'MUNCH_SUCCEEDED'; |
||||||
|
export const MUNCH_FAILED = 'MUNCH_FAILED'; |
||||||
|
|
||||||
export const munch = (success) => ({ |
export const munchSucceeded = () => ({ |
||||||
type: SCOREBAR_ACTION, |
type: SCOREBAR_ACTION, |
||||||
action: MUNCH, |
action: MUNCH_SUCCEEDED, |
||||||
success: success |
}); |
||||||
|
|
||||||
|
export const munchFailed = () => ({ |
||||||
|
type: SCOREBAR_ACTION, |
||||||
|
action: MUNCH_FAILED |
||||||
}); |
}); |
||||||
|
@ -0,0 +1,29 @@ |
|||||||
|
const Immutable = require('immutable'); |
||||||
|
|
||||||
|
import * as MessageActions from '../../actions/board/message.actions'; |
||||||
|
|
||||||
|
const initial = { message1: '', message2: '', hidden: true }; |
||||||
|
|
||||||
|
const reducer = (state = initial, action) => { |
||||||
|
if (action.type !== MessageActions.MESSAGE_ACTION) { |
||||||
|
return state; |
||||||
|
} |
||||||
|
|
||||||
|
switch (action.action) { |
||||||
|
case MessageActions.DISPLAY: |
||||||
|
return Immutable.Map(state) |
||||||
|
.set('message1', action.message1) |
||||||
|
.set('message2', action.message2) |
||||||
|
.set('hidden', false) |
||||||
|
.toObject(); |
||||||
|
|
||||||
|
case MessageActions.HIDE: |
||||||
|
return Immutable.Map(state) |
||||||
|
.set('hidden', true) |
||||||
|
.toObject(); |
||||||
|
} |
||||||
|
|
||||||
|
return state; |
||||||
|
}; |
||||||
|
|
||||||
|
export default reducer; |
Loading…
Reference in new issue