import { useEffect } from 'react'
import { useState } from 'react'
import pageContentApi from '../api/pageContentApi'

const PageContent = ({ path }) => {
  const [content, setContent] = useState(<></>)

  useEffect(() => {
    const loadContent = async () => {
      const dataContent = await pageContentApi({ path })
      if (dataContent) {
        setContent(
          <div
            className='p-4 prose prose-gray prose-a:text-red_r-10 prose-p:my-0'
            dangerouslySetInnerHTML={{ __html: dataContent.content }}
          />
        )
      }
    }
    loadContent()
  }, [path])

  return content
}

export default PageContent
