import { Button } from 'antd';
import React from 'react'
import { Link } from 'react-router-dom';
import { RouteProps } from '../@types';
import config from '../router.config'
import style from './style.module.css'

function SubHead(props: RouteProps) {
  const item = config.find(item => props.match.path === item.path)
  const renderHomeBtn = item.joinTab && (
    <Button type="primary" className={style.manage}>
      <Link to="/scene">场景管理</Link>
    </Button>
  )
  
  return item.joinTab ? (
    <h2 className={style.subhead}>
      {item.title}
      { renderHomeBtn }
    </h2>
  ): null
}

export default SubHead