import { useEffect } from 'react'

type Props = {
  loadingData?: boolean
}

export const useCalendarLoadingSpinner = ({ loadingData }: Props) =>
  useEffect(() => {
    if (typeof document === 'undefined') return

    const loadingSpinner: HTMLElement | null = document.querySelector(
      '.will-filter-bar-calendar .rdp-months .will-calendar-spinner'
    )
    if (loadingData) {
      if (loadingSpinner) loadingSpinner.style.display = 'flex'
    } else {
      if (loadingSpinner) loadingSpinner.style.display = 'none'
    }
  })
