import React, { Fragment } from 'react'
import { Breadcrumb } from 'antd'
import { useHistory } from 'react-router-dom'
import '@platformuiserver/platformui.assets/css/index.less'

function Breadcrumbs (props) {
  const { breadcrumbList } = props
  const history = useHistory()
  return (
    <Breadcrumb>
      {breadcrumbList.map((t) =>
        t.link ? (
          <Breadcrumb.Item key={t.key}>
            <span
              key={t.key}
              className="pointer"
              onClick={() => {
                history.push(t.link)
                t.back()
              }}
            >
              {t.name}
            </span>
          </Breadcrumb.Item>
        ) : (
          <Breadcrumb.Item key={t.key}>
            <span key={t.key}>{t.name}</span>
          </Breadcrumb.Item>
        )
      )}
    </Breadcrumb>
  )
}

export default Breadcrumbs
