member_webapp/@overflow/member/store/container/totp/member-totp.reducer.ts
2018-05-29 18:32:22 +09:00

98 lines
1.8 KiB
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,
};
}
case ActionType.Regist: {
return {
secretKey: null,
sourceURI: null,
pending: true,
error: null,
};
}
case ActionType.RegistSuccess: {
return {
secretKey: null,
sourceURI: null,
pending: true,
error: null,
};
}
case ActionType.RegistFailure: {
return {
secretKey: null,
sourceURI: null,
pending: true,
error: action.payload,
};
}
case ActionType.CheckCodeForMember: {
return {
secretKey: null,
sourceURI: null,
pending: true,
error: null,
};
}
case ActionType.CheckCodeForMemberSuccess: {
return {
secretKey: null,
sourceURI: null,
pending: true,
error: null,
};
}
case ActionType.CheckCodeForMemberFailure: {
return {
secretKey: null,
sourceURI: null,
pending: true,
error: action.payload,
};
}
default: {
return state;
}
}
}