instantjob-recruiter-client
Version:
a set of tools for creating an instantjob recruiter react client
41 lines (38 loc) • 1.21 kB
JSX
import {hash_with_key} from '../common/utilities'
import {create_item, update_item_id, store_items, remove_item} from './base'
const initial_state = {
events: {},
current_user: null,
current_events: [],
current_month: (new Date()).getMonth(),
current_year: (new Date()).getFullYear(),
current_date: (new Date()).getDate(),
idGenerator: 0,
}
export function calendar(state = initial_state, action) {
switch (action.type) {
case "store_events":
return store_items(state, "events", action.events)
case "set_current_user":
return Object.assign({}, state, {
current_user: action.user_id,
})
case 'change_current_month':
return Object.assign({}, state, {
current_month: action.month,
current_year: action.year,
})
case 'set_current_date':
return Object.assign({}, state, {
current_date: action.date,
})
case 'create_event':
return create_item(state, "events", action.event)
case 'update_event_id':
return update_item_id(state, "events", action.event, action.temp_id)
case 'remove_event':
return remove_item(state, "events", action.event_id)
default:
return state
}
}