instantjob-recruiter-client
Version:
a set of tools for creating an instantjob recruiter react client
29 lines (24 loc) • 743 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = make_tabs_with_routes;
exports.is_active = is_active;
var _reactRouter = require('react-router');
function make_tabs_with_routes(tabs, root, current_path) {
return tabs.map(function (_ref) {
var label = _ref.label,
route = _ref.route;
var path = '' + root + (route ? '/' : '') + route;
return {
label: label,
onClick: function onClick() {
return _reactRouter.browserHistory.push(path);
},
active: is_active(path, route, current_path)
};
});
}
function is_active(path, route, current_path) {
return new RegExp('' + path + (route ? "(/\\w\+)\*" : "") + '/?$').test(current_path);
}