Refactored to use app folder.

This commit is contained in:
Mike Cao committed 2023-09-29 05:29:22 -07:00
1 parent 40cfcd41e9
commit 9a52cdd2e1
258 files changed
+2025 -2258

No files matched your search

+2 -4
View File
@@ -1,10 +1,8 @@
import { useEffect } from 'react';
import { useRouter } from 'next/router';
import useApi from 'components/hooks/useApi';
import useUser from 'components/hooks/useUser';
export function useRequireLogin(handler: (data?: object) => void) {
const { basePath } = useRouter();
export function useRequireLogin(handler?: (data?: object) => void) {
const { get } = useApi();
const { user, setUser } = useUser();
@@ -15,7 +13,7 @@ export function useRequireLogin(handler: (data?: object) => void) {
setUser(typeof handler === 'function' ? handler(data) : (data as any)?.user);
} catch {
location.href = `${basePath}/login`;
location.href = `${process.env.basePath}/login`;
}
}