import Spinner from './spinner'

export default function Loading({
  loading,
  children,
}: {
  loading: boolean
  children: any
}) {
  return (
    <div data-testid="wrapper" className="relative">
      <div className={loading && 'opacity-50'}>{children}</div>
      {loading && (
        <div className="absolute inset-0 w-full h-full flex justify-center items-center pointer-events-node">
          <Spinner />
        </div>
      )}
    </div>
  )
}
