diff options
author | Matthew Shao <me@matshao.com> | 2017-06-27 21:58:41 +0800 |
---|---|---|
committer | Matthew Shao <me@matshao.com> | 2017-06-27 21:58:41 +0800 |
commit | f95dcfd2e5824a4ec0844006cfb54c66bfff70b0 (patch) | |
tree | a422b6b17da0508929ebf44e78cc03546784c94a /web | |
parent | 58af3a6ba4f57a792e56e79acb8b9c1c4c8c8841 (diff) | |
download | mitmproxy-f95dcfd2e5824a4ec0844006cfb54c66bfff70b0.tar.gz mitmproxy-f95dcfd2e5824a4ec0844006cfb54c66bfff70b0.tar.bz2 mitmproxy-f95dcfd2e5824a4ec0844006cfb54c66bfff70b0.zip |
[web] Add js/ducks/options.js
Diffstat (limited to 'web')
-rw-r--r-- | web/src/js/ducks/options.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/web/src/js/ducks/options.js b/web/src/js/ducks/options.js new file mode 100644 index 00000000..39c2f3fc --- /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 } +} |