import React from 'react'
import { Button } from 'flowbite-react'
import { HiDownload } from 'react-icons/hi'
import { usePWA } from '../hooks/usePWA'

interface PWAInstallButtonProps {
  className?: string
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
  color?: string
}

const PWAInstallButton: React.FC<PWAInstallButtonProps> = ({
  className = '',
  size = 'sm',
  color = 'blue',
}) => {
  const { isInstalled, isInstallable, handleInstall } = usePWA()

  if (isInstalled || !isInstallable) {
    return null
  }

  return (
    <Button
      color={color}
      size={size}
      onClick={handleInstall}
      className={className}
    >
      <HiDownload className="mr-2 h-4 w-4" />
      Install App
    </Button>
  )
}

export default PWAInstallButton
