UNPKG

instantjob-recruiter-client

Version:

a set of tools for creating an instantjob recruiter react client

17 lines (14 loc) 495 B
import {browserHistory} from 'react-router' export default function make_tabs_with_routes(tabs, root, current_path) { return tabs.map(({label, route}) => { const path = `${root}${route ? '/' : ''}${route}` return { label, onClick: () => browserHistory.push(path), active: is_active(path, route, current_path), } }) } export function is_active(path, route, current_path) { return (new RegExp(`${path}${route ? "(/\\w\+)\*" : ""}/\?\$`)).test(current_path) }