member_webapp/src/packages/member/store/totp/totp.reducer.ts

72 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-04-06 11:02:18 +00:00
import {
Actions,
ActionType,
} from './totp.action';
import {
State,
initialState,
} from './totp.state';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.CreateTotp: {
return {
...state,
error: null,
pending: true,
};
}
case ActionType.CreateTotpSuccess: {
const secretKey = action.payload.key;
const keyURI = action.payload.uri;
return {
...state,
error: null,
pending: false,
secretKey: secretKey,
keyURI: keyURI,
};
}
case ActionType.CreateTotpFailure: {
return {
...state,
error: action.payload,
pending: false,
secretKey: null,
keyURI: null,
};
}
case ActionType.Regist: {
return {
...state,
error: null,
pending: true,
};
}
case ActionType.RegistSuccess: {
return {
...state,
error: null,
pending: false,
};
}
case ActionType.RegistFailure: {
return {
...state,
error: action.payload,
pending: false,
};
}
default: {
return state;
}
}
}