// __SDEFILE__ - This file is a dependency for the stand-alone environment
/* eslint-disable */
// Not sure why but eslint does not seem to understand this file
// and I don't have time to hold its hand.
import { useState, useEffect, createContext } from 'react'
import { Spinner } from 'shared/components/spinner.mjs'
import { OkIcon, WarningIcon } from 'shared/components/icons.mjs'
import { useTranslation } from 'next-i18next'
export const ns = ['status']
export const LoadingStatusContext = createContext([false])
/*
* Timeout in seconds before the loading status dissapears
*/
const timeout = 2
const LoadingStatus = ({ loadingStatus }) => {
const { t } = useTranslation(ns)
const [fade, setFade] = useState('opacity-100')
const [timer, setTimer] = useState(false)
useEffect(() => {
if (loadingStatus[2]) {
if (timer) clearTimeout(timer)
setTimer(
window.setTimeout(
() => {
setFade('opacity-0')
},
timeout * 1000 - 350
)
)
}
}, [loadingStatus[2]])
if (!loadingStatus[0]) return null
let color = 'secondary'
let icon =