[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

41 lines
1.1 KiB

import { Reducer } from 'redux'
import { AuthenticationActions } from '../actions/authentication'
import { AuthenticationState } from '../types'
const initialState: AuthenticationState = {
checked: false,
authenticated: false,
userId: undefined,
}
const reducer: Reducer<AuthenticationState, AuthenticationActions> = (state = initialState, action) => {
switch (action.type) {
case 'AUTHENTICATION_SET_CHECKED':
return {
...state,
checked: true,
}
case 'AUTHENTICATION_SET_AUTHENTICATED':
return {
...state,
authenticated: action.payload,
checked: true,
}
case 'AUTHENTICATION_SET_USER':
return {
...state,
userId: action.payload,
}
case 'AUTHENTICATION_UNAUTHENTICATE':
return {
...state,
authenticated: false,
userId: undefined,
}
default:
return state
}
}
export default reducer