All files / src/components AlertBlock.tsx

66.66% Statements 4/6
33.33% Branches 2/6
50% Functions 1/2
66.66% Lines 4/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                        13x 26x 26x   26x                                  
import { useTranslation } from 'next-i18next'
 
import { AlertPage } from '../lib/types'
import { useAlerts } from '../lib/useAlerts'
import AlertSection from './AlertSection'
import { MarkdownContent } from './MarkdownContent'
 
export interface AlertBlockProps {
  page?: AlertPage
  className?: string
}
 
const AlertBlock = ({ page, className }: AlertBlockProps) => {
  const { data } = useAlerts({ page })
  const { i18n } = useTranslation()
 
  return data && data.length > 0 ? (
    <div className={`${className} pt-4`}>
      {data?.map(({ textEn, textFr, type, uid }) => {
        const markdown = i18n.language === 'fr' ? textFr : textEn
        return (
          <AlertSection key={uid} type={type} background>
            <MarkdownContent markdown={markdown} />
          </AlertSection>
        )
      })}
    </div>
  ) : (
    <></>
  )
}
 
export default AlertBlock