45 lines
829 B
TypeScript
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;
|
|
}
|
|
}
|
|
}
|