Fixed 'use client' usage.

This commit is contained in:
Mike Cao 2024-02-05 23:59:33 -08:00
parent be5592446a
commit f7151a880e
208 changed files with 323 additions and 385 deletions

View file

@ -1,32 +0,0 @@
'use client';
import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useApi } from 'components/hooks';
import { setUser } from 'store/app';
import { removeClientAuthToken } from 'lib/client';
export function Logout() {
const disabled = !!(process.env.disableLogin || process.env.cloudMode);
const router = useRouter();
const { post } = useApi();
useEffect(() => {
async function logout() {
await post('/auth/logout');
}
if (!disabled) {
removeClientAuthToken();
logout();
router.push('/login');
return () => setUser(null);
}
}, [disabled, router, post]);
return null;
}
export default Logout;