From f95dcfd2e5824a4ec0844006cfb54c66bfff70b0 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Tue, 27 Jun 2017 21:58:41 +0800 Subject: [PATCH] [web] Add js/ducks/options.js --- web/src/js/ducks/options.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 web/src/js/ducks/options.js diff --git a/web/src/js/ducks/options.js b/web/src/js/ducks/options.js new file mode 100644 index 000000000..39c2f3fc0 --- /dev/null +++ b/web/src/js/ducks/options.js @@ -0,0 +1,32 @@ +import { fetchApi } from '../utils' + +export const RECEIVE = 'OPTIONS_RECEIVE' +export const UPDATE = 'OPTIONS_UPDATE' +export const REQUEST_UPDATE = 'REQUEST_UPDATE' +export const UNKNOWN_CMD = 'OPTIONS_UNKNOWN_CMD' + +const defaultState = { + +} + +export default function reducer(state = defaultState, action) { + switch (action.type) { + + case RECEIVE: + return action.data + + case UPDATE: + return { + ...state, + ...action.data, + } + + default: + return state + } +} + +export function update(options) { + fetchApi.put('/options', options) + return { type: REQUEST_UPDATE } +}