Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/packages / features / Authentication / AuthenticationSwitchContainer.js
Size: Mime:
import * as tslib_1 from "tslib";
import { observable, action } from 'xmobx/mobx';
import { oneRouter } from '@skava/router';
import { stepList, stepConfig as steps, wording } from './fixture';
import { toStatus } from './deps';
// @todo - needs pagination stepper stack
export class AuthenticationSwitchContainer {
    constructor() {
        this.currentStep = steps.signin;
        this.freezeErrorMsg = '';
        this.rehydrateFromRouter();
    }
    /**
     * @private
     * @description load from url params, or update url params
     */
    rehydrateFromRouter() {
        if (typeof window !== 'object') {
            return;
        }
        if (oneRouter.has('step')) {
            const step = oneRouter.get('step') || steps.signin;
            // make sure it's valid
            if (stepList.includes(step) === true) {
                console.debug('rehydrateFromRouter_step', stepList);
                this.currentStep = step;
            }
            else {
                console.warn('step was not valid', step);
                this.currentStep = steps.signin;
            }
        }
        else {
            oneRouter.set('step', this.currentStep);
        }
    }
    goToSignin() {
        oneRouter.update({ step: steps.signin });
        // this.currentStep = steps.signin
    }
    gotoRegister() {
        oneRouter.update({ step: steps.register });
        // this.currentStep = steps.register
    }
    gotoFinal() {
        oneRouter.update({ step: steps.registerFinal });
        // this.currentStep = steps.registerFinal
    }
    gotoReset() {
        oneRouter.replace('/signin');
        oneRouter.update({ step: steps.resetPassword });
        // this.currentStep = steps.resetPassword
    }
    gotoNextStep(value) {
        const searchParams = oneRouter.searchParams
            ? oneRouter.searchParams
            : { ...oneRouter.searchParams };
        searchParams.stepvalue = value;
        oneRouter.update(searchParams);
    }
    gotoSuccess() {
        oneRouter.update({ step: steps.signinsuccess });
        this.currentStep = steps.signinsuccess;
    }
    gotoSecurityQuestions() {
        oneRouter.update({ step: steps.securityQuestions });
        // this.currentStep = steps.securityQuestions
    }
    gotoFreezeSignIn(response) {
        if (toStatus(response) === wording.signInFailure) {
            this.freezeErrorMsg = wording.freezeText;
        }
    }
}
tslib_1.__decorate([
    observable
], AuthenticationSwitchContainer.prototype, "currentStep", void 0);
tslib_1.__decorate([
    observable
], AuthenticationSwitchContainer.prototype, "freezeErrorMsg", void 0);
tslib_1.__decorate([
    action
], AuthenticationSwitchContainer.prototype, "rehydrateFromRouter", null);
tslib_1.__decorate([
    action.bound
], AuthenticationSwitchContainer.prototype, "goToSignin", null);
tslib_1.__decorate([
    action.bound
], AuthenticationSwitchContainer.prototype, "gotoRegister", null);
tslib_1.__decorate([
    action.bound
], AuthenticationSwitchContainer.prototype, "gotoFinal", null);
tslib_1.__decorate([
    action.bound
], AuthenticationSwitchContainer.prototype, "gotoReset", null);
tslib_1.__decorate([
    action.bound
], AuthenticationSwitchContainer.prototype, "gotoNextStep", null);
tslib_1.__decorate([
    action.bound
], AuthenticationSwitchContainer.prototype, "gotoSuccess", null);
tslib_1.__decorate([
    action.bound
], AuthenticationSwitchContainer.prototype, "gotoSecurityQuestions", null);
tslib_1.__decorate([
    action
], AuthenticationSwitchContainer.prototype, "gotoFreezeSignIn", null);
//# sourceMappingURL=AuthenticationSwitchContainer.js.map