This commit is contained in:
2026-04-05 00:43:23 +05:30
commit 8be37d3e92
425 changed files with 101853 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
'use client';
import { AuthModal } from '@/components/modals/AuthModal';
import { onAuthSuccess } from '@/lib/api';
import { useEffect, useState } from 'react';
/**
* Global authentication handler that shows auth modal when needed
*/
export function AuthProvider({ children }: { children: React.ReactNode }) {
const [showAuthModal, setShowAuthModal] = useState(false);
useEffect(() => {
const handleAuthRequired = () => {
setShowAuthModal(true);
};
window.addEventListener('auth-required', handleAuthRequired);
return () => window.removeEventListener('auth-required', handleAuthRequired);
}, []);
const handleAuthSuccess = () => {
setShowAuthModal(false);
onAuthSuccess(); // Notify any pending requests
};
return (
<>
{children}
<AuthModal
isOpen={showAuthModal}
onClose={() => setShowAuthModal(false)}
onSuccess={handleAuthSuccess}
/>
</>
);
}