Park Byung Eun 02c2645e01 0524 sync
2020-05-24 13:11:32 +09:00

58 lines
1.1 KiB
TypeScript

import { createReducer, on } from '@ngrx/store';
import { initialState } from './state';
import { loginSuccess, logoutSuccess, infoUserSuccess } from './actions';
import { UserInfoUpdateType } from '@ucap/protocol-info';
export const reducer = createReducer(
initialState,
on(loginSuccess, (state, action) => {
return {
...state,
loginRes: action.res
};
}),
on(logoutSuccess, (state, action) => {
return {
...initialState
};
}),
on(infoUserSuccess, (state, action) => {
let loginRes = {
...state.loginRes
};
switch (action.res.type) {
case UserInfoUpdateType.Image:
loginRes = {
...loginRes
};
break;
case UserInfoUpdateType.Intro:
loginRes = {
...loginRes,
userInfo: {
...loginRes.userInfo,
intro: action.res.info
}
};
break;
case UserInfoUpdateType.TelephoneVisible:
loginRes = {
...loginRes
};
break;
default:
break;
}
return {
...state,
loginRes: {
...loginRes
}
};
})
);