member_webapp/@overflow/member/store/container/totp/member-totp.reducer.ts
2018-05-28 21:37:47 +09:00

45 lines
829 B
TypeScript

import {
Actions,
ActionType,
} from '../../entity/member-totp/member-totp.action';
import {
State,
initialState,
} from './member-totp.state';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.CreateTotp: {
return {
secretKey: null,
sourceURI: null,
pending: true,
error: null,
};
}
case ActionType.CreateTotpSuccess: {
return {
secretKey: action.payload.key,
sourceURI: action.payload.uri,
pending: false,
error: null,
};
}
case ActionType.CreateTotpFailure: {
return {
secretKey: null,
sourceURI: null,
pending: false,
error: action.payload,
};
}
default: {
return state;
}
}
}