diff --git a/packages/ui/src/components/atoms/Loader.tsx b/packages/ui/src/components/atoms/Loader.tsx index 77f205b..4c3d06b 100644 --- a/packages/ui/src/components/atoms/Loader.tsx +++ b/packages/ui/src/components/atoms/Loader.tsx @@ -1,4 +1,6 @@ import Image from 'next/image'; +import {useEffect, useState} from 'react'; +import {useRouter} from 'next/router'; export interface LoaderProps { message?: string; @@ -9,6 +11,28 @@ export interface LoaderProps { * Full-screen loader component with animated logo and spinner */ export function Loader({message = 'Loading...', showLogo = true}: LoaderProps) { + const [showClearCache, setShowClearCache] = useState(false); + const router = useRouter(); + + useEffect(() => { + const timer = setTimeout(() => { + setShowClearCache(true); + }, 5000); + + return () => clearTimeout(timer); + }, []); + + const handleClearCache = () => { + document.cookie.split(';').forEach(c => { + document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/'); + }); + + localStorage.clear(); + sessionStorage.clear(); + + void router.push('/auth/login'); + }; + return (
@@ -48,6 +72,19 @@ export function Loader({message = 'Loading...', showLogo = true}: LoaderProps) { {/* Loading message */} {message &&

{message}

} + + {/* Clear cache button - appears after 5 seconds */} + {showClearCache && ( +
+

Taking too long?

+ +
+ )}
);