Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
27 lines
648 B
TypeScript
27 lines
648 B
TypeScript
'use client'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
/** Default delay — keeps deferred chrome out of the LCP window on cold loads. */
|
|
export const DEFERRED_CHROME_DELAY_MS = 4000
|
|
|
|
/**
|
|
* Returns true after `delayMs` so non-critical client UI (PWA banner, etc.) mounts
|
|
* after the first paint / LCP candidates.
|
|
*/
|
|
export function useDeferredClientMount(delayMs = DEFERRED_CHROME_DELAY_MS) {
|
|
const [ready, setReady] = useState(false)
|
|
|
|
useEffect(() => {
|
|
const timeoutId = window.setTimeout(() => {
|
|
setReady(true)
|
|
}, delayMs)
|
|
|
|
return () => {
|
|
window.clearTimeout(timeoutId)
|
|
}
|
|
}, [delayMs])
|
|
|
|
return ready
|
|
}
|