import React from 'react'
import { Modal, ModalBody, ModalHeader } from 'flowbite-react'
import { LuBadgeCheck, LuCircleAlert, LuInfo } from 'react-icons/lu'
import { PopupProps } from '@/lib/hooks/usePopup'

interface PopupModalProps extends PopupProps {
  children?: React.ReactNode
  onClose: () => void
}

export default function PopupModal({
  show,
  title,
  type,
  children,
  message,
  onClose,
}: PopupModalProps) {
  const icons = {
    info: <LuInfo className="mx-auto mb-4 h-14 w-14 text-blue-600" />,
    success: <LuBadgeCheck className="mx-auto mb-4 h-14 w-14 text-green-600" />,
    error: <LuCircleAlert className="mx-auto mb-4 h-14 w-14 text-red-600" />,
    warning: (
      <LuCircleAlert className="mx-auto mb-4 h-14 w-14 text-yellow-600" />
    ),
  }

  return (
    <Modal show={show} size="md" popup onClose={onClose}>
      <ModalHeader />
      <ModalBody>
        <div className="text-center">
          {icons[type]}
          <h3 className="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">
            {title}
          </h3>
          {message}
          {children}
        </div>
      </ModalBody>
    </Modal>
  )
}
