feat: 게시판 페이지 가드 로직 작성
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { useLocalStorage } from "@frontend-opensource/use-react-hooks";
|
||||
import { MenuAuthorityApi } from "@/entities/menu-authority/@x/menu";
|
||||
import { getCookie, useAlertStore, useMenuStore } from "@/shared/lib";
|
||||
import { SITE_ID } from "@/shared/config";
|
||||
@@ -14,14 +13,8 @@ const MenuWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
const pathname = usePathname();
|
||||
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const {
|
||||
pageMenuAuthority,
|
||||
setBbsInfo,
|
||||
setCurrentMenuInfo,
|
||||
setPageMenuAuthority,
|
||||
} = useMenuStore((state) => state);
|
||||
|
||||
const [storedBbsInfo] = useLocalStorage("bbs-info", "");
|
||||
const { pageMenuAuthority, setCurrentMenuInfo, setPageMenuAuthority } =
|
||||
useMenuStore((state) => state);
|
||||
|
||||
const getCurrentMenuInfo = async () => {
|
||||
const menuRoles = await MenuApi.getMenuRoles(SITE_ID);
|
||||
@@ -60,11 +53,6 @@ const MenuWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
alert("페이지에 대한 조회 권한이 없습니다.", () => router.push("/"));
|
||||
}, [pageMenuAuthority]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!storedBbsInfo) return;
|
||||
setBbsInfo(JSON.parse(storedBbsInfo));
|
||||
}, [storedBbsInfo]);
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user