summaryrefslogtreecommitdiff
path: root/frontend/src/reducers/index.tsx
blob: 76e2d0c06f7f14339f4e143eb23b2ac629d2c474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
  }
}