refactor: setBbsInfo 로직 리팩토링

This commit is contained in:
2025-05-20 10:42:58 +09:00
parent 480e402d4e
commit 4a5f9c7488
3 changed files with 30 additions and 18 deletions
+2 -14
View File
@@ -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 { setMessage: alert } = useAlertStore((state) => state);
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}</>;
};