mirror of
https://github.com/PlayEdu/backend
synced 2025-06-22 00:02:50 +08:00
34 lines
724 B
TypeScript
34 lines
724 B
TypeScript
import {
|
|
UserLoginAction,
|
|
IS_LOGIN,
|
|
LOGIN_OUT,
|
|
SET_USER,
|
|
SET_PERMISSSIONS,
|
|
} from "./userActions";
|
|
|
|
interface UserState {
|
|
permisssions: any[];
|
|
user: any[];
|
|
isLogin: boolean;
|
|
}
|
|
export const defaultState: UserState = {
|
|
isLogin: false,
|
|
permisssions: [],
|
|
user: [],
|
|
};
|
|
|
|
export default (state = defaultState, action: UserLoginAction) => {
|
|
switch (action.type) {
|
|
case IS_LOGIN:
|
|
return { ...state, isLogin: true };
|
|
case LOGIN_OUT:
|
|
return { ...state, isLogin: false, user: [], permisssions: [] };
|
|
case SET_USER:
|
|
return { ...state, user: action.payload };
|
|
case SET_PERMISSSIONS:
|
|
return { ...state, permisssions: action.payload };
|
|
default:
|
|
return state;
|
|
}
|
|
};
|