commit 1ca666a40422cb1cd7b03126ec2b13a76bc50bd6
parent e8ad95a7d7974780850ffe20829ab60e5a67399c
Author: tanhengyeow <E0032242@u.nus.edu>
Date: Tue, 2 Jun 2020 18:11:42 +0800
Setup auth reducer
Diffstat:
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/frontend/src/reducers/auth.tsx b/frontend/src/reducers/auth.tsx
@@ -0,0 +1,22 @@
+import { Authenticate, Unauthenticate } from '../actions/auth';
+import { AUTHENTICATE, UNAUTHENTICATE } from '../constants';
+import { Auth } from '../types';
+
+export default function authReducer(
+ state: Auth = {
+ isAuthenticated: null,
+ },
+ action: Authenticate | Unauthenticate
+): Auth {
+ switch (action.type) {
+ case AUTHENTICATE:
+ return {
+ ...state,
+ isAuthenticated: true,
+ };
+ case UNAUTHENTICATE:
+ return { ...state, isAuthenticated: false };
+ default:
+ return state;
+ }
+}