import React from 'react'
import { IPdfProps } from '../interfaces/IPdfProps'

export default function Preview({ pdfIsLoading, pdfError, pdfUrl }: IPdfProps) {
  if (pdfIsLoading) {
    return <div>Lade&hellip;</div>
  }

  if (pdfError) {
    return (
      <div className="flex items-center bg-red-100 border-solid border border-red-700 rounded text-red-700 py-2 px-3">
        <span role="img" aria-label="Crying Man">
          😢
        </span>{' '}
        {pdfError}
      </div>
    )
  }

  if (!pdfUrl) {
    return null
  }

  return <embed src={pdfUrl} className="h-screen w-auto" type="application/pdf" />
}
