commit 7906ded0616aac733ab0795aa6e29e1fdf3279c2
parent 855e4152323a6e34222b2f5cfb5d9bc23fc8d42b
Author: tanhengyeow <E0032242@u.nus.edu>
Date: Thu, 11 Jun 2020 02:36:44 +0800
Update reducers folder
Diffstat:
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/frontend/src/reducers/index.tsx b/frontend/src/reducers/index.tsx
@@ -0,0 +1,22 @@
+import { Authenticate, Unauthenticate } from '../actions/auth';
+import { AUTHENTICATE, UNAUTHENTICATE } from '../constants';
+import { Store } from '../types';
+
+export default function rootReducer(
+ state: Store = {
+ isAuthenticated: false,
+ },
+ action: Authenticate | Unauthenticate
+): Store {
+ switch (action.type) {
+ case AUTHENTICATE:
+ return {
+ ...state,
+ isAuthenticated: true,
+ };
+ case UNAUTHENTICATE:
+ return { ...state, isAuthenticated: false };
+ default:
+ return state;
+ }
+}