Migrate actions,reducers and action types to TS #15

This commit is contained in:
Qolzam
2017-10-10 08:01:25 +07:00
parent 3b3899e7af
commit f9d213f741
113 changed files with 2692 additions and 1275 deletions

View File

@@ -0,0 +1,50 @@
// - Import react components
import {Reducer, Action} from "redux";
// - Import action types
import {AuthorizeActionType} from 'constants/authorizeActionType'
import { IAuthorizeAction } from "./IAuthorizeAction";
import { AuthorizeState } from "./AuthorizeState";
/**
* Authorize reducer
* @param {object} state
* @param {object} action
*/
export var authorizeReducer = (state : AuthorizeState = new AuthorizeState(), action: IAuthorizeAction) =>{
const { payload } = action;
switch (action.type) {
case AuthorizeActionType.LOGIN:
return{
...state,
uid: payload.uid,
authed: true,
guest:false
}
case AuthorizeActionType.LOGOUT:
return{
...state,
uid: 0,
authed: false,
guest:true
}
case AuthorizeActionType.SIGNUP:
return{
...state,
uid: payload.userId
}
case AuthorizeActionType.UPDATE_PASSWORD:
return{
...state,
updatePassword: payload.updatePassword
}
default:
return state
}
}