import React from 'react'
import RichText, { ComponentsContext } from '../../RichText'
import type { BodyProps } from '../../Body'

const ArticleBody: React.FC<BodyProps> = ({ content, richTextComponents }) => {
  if (!content?.body?.structured) {
    return null
  }

  return (
    <ComponentsContext.Provider value={richTextComponents}>
      <article className="n-content-body o3-type-body-content-base">
        <RichText
          structuredContent={content.body.structured}
          components={richTextComponents}
        />
      </article>
    </ComponentsContext.Provider>
  )
}

export default ArticleBody
