import { Spinner } from '@components/ui/spinner/spinner'
import { APP_CONFIG } from '@lib/config'

export function Loader({ label }: Readonly<{ label: string }>) {
  // disable loader during e2e tests to avoid slowdown due to transitions
  if (APP_CONFIG.mapBoxDisableTransitions) {
    return null
  }
  return (
    <div className="flex absolute z-1 left-0 top-0 bottom-0 right-0 bg-secondary/50">
      <div className="flex items-center justify-center flex-1 flex-col">
        <Spinner classNames="w-[24px] h-[25px]" />
        <h3 className="pb-0 pt-3 font-medium text-xl mb-2 text-muted-foreground">{label}</h3>
      </div>
    </div>
  )
}
