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    
Size: Mime:
import * as tslib_1 from "tslib";
// modules
import { observable, action, computed } from 'xmobx/mobx';
// framework
import { oneRouter } from '@skava/router';
import { application } from '@skava/state';
// domain
import { ObservableContainer } from '@skava/packages/libraries/observable-container';
import { sessionContainer } from '@skava/packages/core/auth/session/container';
// local
import { accountSectionTypes } from '../ROUTE_PARAMS';
/**
 * @tutorial https://jira.skava.net/confluence/display/ux/JS+Binding
 */
const isRouteAllowed = (route) => {
    // currently we are just disallowing every route
    // const protectedRoutes = []
    // later, we can set some restricted routes in oneRouter :-)
    // ^ even before any other code even LOADS ON THE WEBPAGE
    // boolean
    return sessionContainer.isRegisteredUser;
};
export function getCurrentSection() {
    // const accountTab = window.location.href.split('/myacccount/').pop()!
    const accountTab = oneRouter.get('accountTab');
    const activeTab = accountSectionTypes[accountTab];
    return activeTab || application.isMobile ? activeTab : 'MY-PROFILE';
}
class SideBarContainer extends ObservableContainer {
    constructor() {
        super(...arguments);
        this.activeTab = getCurrentSection();
    }
    // @computed
    get activeField() {
        const activeTab = accountSectionTypes[oneRouter.get('accountTab')];
        return activeTab;
    }
    isActiveSatisfiedBy(name) {
        return name === this.activeTab;
    }
    get shouldRenderSideBar() {
        return !this.activeTab || !application.isMobile || this.activeTab === '@@EMPTY';
    }
    reset() {
        this.activeTab = '@@EMPTY';
    }
    handleClick(activeTab, link) {
        console.warn('sidebarStore.handleClick', activeTab);
        this.activeTab = activeTab;
        if (isRouteAllowed(link) === false) {
            console.warn('protectedRoute');
            // return
        }
        else {
            // console.debug('handlingClick', this)
        }
        if (link) {
            oneRouter.update(link);
        }
    }
}
SideBarContainer.debugName = 'SideBar';
tslib_1.__decorate([
    observable
], SideBarContainer.prototype, "activeTab", void 0);
tslib_1.__decorate([
    computed
], SideBarContainer.prototype, "shouldRenderSideBar", null);
tslib_1.__decorate([
    action.bound
], SideBarContainer.prototype, "reset", null);
tslib_1.__decorate([
    action.bound
], SideBarContainer.prototype, "handleClick", null);
const sidebarStore = new SideBarContainer();
export { sidebarStore, sidebarStore as store, sidebarStore as state };
export { SideBarContainer };
export default sidebarStore;
//# sourceMappingURL=state.js.map