import { useState, useEffect } from 'react';
import PasswordPrompt from '@/components/shared/Security/PasswordPrompt';
import Cookies from 'js-cookie';
export default function withAdminProtection(Component) {
return function ProtectedComponent(props) {
const [isAuthenticated, setIsAuthenticated] = useState(false);
useEffect(() => {
const checkAuth = async () => {
const res = await fetch('/api/post/check-auth', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
});
if (res.ok) {
setIsAuthenticated(true);
}
};
checkAuth();
}, []);
const handleAuthenticated = () => {
setIsAuthenticated(true);
};
if (!isAuthenticated) {
return ;
}
return ;
};
}