about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/reducers/identity_proofs.js
diff options
context:
space:
mode:
authorAlex Gessner <alex.gessner@gmail.com>2019-03-28 13:01:09 -0400
committerThibG <thib@sitedethib.com>2019-03-29 10:13:44 +0100
commitb6fa500806f68d5394174e1f341dc61e3578760e (patch)
tree64f5887dc8f69ebe59c97c92ed8b60f1eb201087 /app/javascript/flavours/glitch/reducers/identity_proofs.js
parenta74d300b68ca992aece2763556de87bd65e0ba73 (diff)
[Glitch] squashed identity proof updates
Port JS from 69141dca26f8a28d3aff63387b1c8d2bba7fdfa3 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/reducers/identity_proofs.js')
-rw-r--r--app/javascript/flavours/glitch/reducers/identity_proofs.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/reducers/identity_proofs.js b/app/javascript/flavours/glitch/reducers/identity_proofs.js
new file mode 100644
index 000000000..58af0a5fa
--- /dev/null
+++ b/app/javascript/flavours/glitch/reducers/identity_proofs.js
@@ -0,0 +1,25 @@
+import { Map as ImmutableMap, fromJS } from 'immutable';
+import {
+  IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST,
+  IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS,
+  IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
+} from '../actions/identity_proofs';
+
+const initialState = ImmutableMap();
+
+export default function identityProofsReducer(state = initialState, action) {
+  switch(action.type) {
+  case IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST:
+    return state.set('isLoading', true);
+  case IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL:
+    return state.set('isLoading', false);
+  case IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS:
+    return state.update(identity_proofs => identity_proofs.withMutations(map => {
+      map.set('isLoading', false);
+      map.set('loaded', true);
+      map.set(action.accountId, fromJS(action.identity_proofs));
+    }));
+  default:
+    return state;
+  }
+};