import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { Link } from 'react-router-dom';
import { connect } from 'react-redux'
import * as systemActions from '../system/system.actions'
import modules from '../modules'
function NavLink(props){
if (! props.to) {
return {props.children}
}
let children = props.to === props.location.pathname ? {props.children} : props.children
return (
{children}
)
}
function Header(props){
const { site, app, fps, playing, actions, location, history } = props
const tool_list = Object.keys(modules).map((name, i) => {
const label = name.replace(/_/, " ")
return
})
const tool = modules[app.tool]
const links = tool.links().map((link,i) => {
return (
{link.name}
)
})
return (
{site.name} cortex
system
dashboard
{links}
{playing && {fps} fps}
)
}
const mapStateToProps = state => ({
site: state.system.site,
app: state.system.app,
fps: state.live.fps,
playing: state.live.playing,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
actions: bindActionCreators(systemActions, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(Header)