UNPKG

@bigfishtv/cockpit

Version:

40 lines (36 loc) 1.09 kB
/** * @module Reducers/preview */ import * as ActionTypes from '../constants/ActionTypes' import moment from 'moment' const initialState = { data: null, enabled: false, url: null, deviceWidth: '100%', date: moment().format(), } /** * Reducer for managing the state of a content (typically a page) preview * @param {Object} state * @param {Object} action * @param {String} action.type - const action type from constants/ActionTypes * @return {Object} returns state */ export default function(state = initialState, action) { switch (action.type) { case ActionTypes.PREVIEW_ENABLED: return { ...state, enabled: true } case ActionTypes.PREVIEW_DISABLED: return { ...state, enabled: false } case ActionTypes.PREVIEW_DATA_UPDATED: return { ...state, data: action.data } case ActionTypes.PREVIEW_URL_UPDATED: return { ...state, url: action.url } case ActionTypes.PREVIEW_DEVICE_WIDTH_CHANGED: return { ...state, deviceWidth: action.deviceWidth } case ActionTypes.PREVIEW_DATE_UPDATED: return { ...state, date: action.date } } return state }