import react, {Children, ReactNode} from 'react'
import TimelineCardSummary from './TimelineCardSummary'

type TimelineCardProps = {
  children: react.ReactElement<any, react.JSXElementConstructor<any>>[]
}

function TimelineCard({ children } : TimelineCardProps) {
  let titles : ReactNode[] = []
  let childrens : ReactNode[] = []
  Children.forEach(children, (c) => {
    if (c.type === TimelineCardSummary) {
      titles.push(c)
    } else {
      childrens.push(c)
    }
  });
  return (
    <details>
      <summary>{titles}</summary>
      <div>{childrens}</div>
    </details>
  )
}

export default TimelineCard