summaryrefslogtreecommitdiff
path: root/src/redux
diff options
context:
space:
mode:
Diffstat (limited to 'src/redux')
-rw-r--r--src/redux/preference/actions.js19
-rw-r--r--src/redux/preference/reducer.js30
-rw-r--r--src/redux/preference/types.js3
-rw-r--r--src/redux/reducers.js7
4 files changed, 59 insertions, 0 deletions
diff --git a/src/redux/preference/actions.js b/src/redux/preference/actions.js
new file mode 100644
index 0000000..1045b6b
--- /dev/null
+++ b/src/redux/preference/actions.js
@@ -0,0 +1,19 @@
+import { UPDATE_OPTIONS, UPDATE_VIEW_TYPE } from './types';
+
+export const updateOptions = function (setting) {
+ return dispatch => {
+ dispatch({
+ type: UPDATE_OPTIONS,
+ payload: setting,
+ });
+ };
+};
+
+export const updateViewType = function (viewType = 'grid') {
+ return dispatch => {
+ dispatch({
+ type: UPDATE_VIEW_TYPE,
+ payload: viewType
+ });
+ };
+};
diff --git a/src/redux/preference/reducer.js b/src/redux/preference/reducer.js
new file mode 100644
index 0000000..a72c8b2
--- /dev/null
+++ b/src/redux/preference/reducer.js
@@ -0,0 +1,30 @@
+import { RESET_OPTIONS, UPDATE_OPTIONS, UPDATE_VIEW_TYPE } from './types';
+
+const initialState = {
+ view: 'grid',
+ options: {
+ token: '',
+ },
+};
+
+export default function reducer(state = initialState, action) {
+ switch (action.type) {
+ case UPDATE_OPTIONS:
+ return {
+ ...state,
+ options: action.payload
+ };
+ case RESET_OPTIONS:
+ return {
+ ...state,
+ options: initialState.options
+ };
+ case UPDATE_VIEW_TYPE:
+ return {
+ ...state,
+ view: action.payload
+ };
+ default:
+ return state;
+ }
+}
diff --git a/src/redux/preference/types.js b/src/redux/preference/types.js
new file mode 100644
index 0000000..ac613c6
--- /dev/null
+++ b/src/redux/preference/types.js
@@ -0,0 +1,3 @@
+export const UPDATE_OPTIONS = 'update_options';
+export const RESET_OPTIONS = 'reset_options';
+export const UPDATE_VIEW_TYPE = 'update_view_type';
diff --git a/src/redux/reducers.js b/src/redux/reducers.js
new file mode 100644
index 0000000..7afbc67
--- /dev/null
+++ b/src/redux/reducers.js
@@ -0,0 +1,7 @@
+import { combineReducers } from 'redux';
+
+import preference from './preference/reducer';
+
+export default combineReducers({
+ preference,
+});