From 2352a395fb03d950f24f66c07156c7a8f1292415 Mon Sep 17 00:00:00 2001 From: bicochan Date: Tue, 13 May 2025 17:03:22 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20=EB=8B=B5?= =?UTF-8?q?=EA=B8=80=20=EB=B2=84=ED=8A=BC=20=EA=B6=8C=ED=95=9C=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/entities/auth/lib/auth-wrapper.tsx | 2 +- .../features/src/shared/store/user-store.ts | 1 + .../src/widgets/post/ui/post-action.tsx | 17 ++++++++++++++++- apps/cs/src/entities/auth/lib/auth-wrapper.tsx | 2 +- .../ui/management-authority-dialog.tsx | 4 +++- .../module/ui/management-authority-dialog.tsx | 4 +++- packages/common/components/src/api/user.ts | 4 ++-- .../common/components/src/ui/header/index.tsx | 8 +++----- 8 files changed, 30 insertions(+), 12 deletions(-) diff --git a/apps/common/features/src/entities/auth/lib/auth-wrapper.tsx b/apps/common/features/src/entities/auth/lib/auth-wrapper.tsx index 6af88ae96..e518f938a 100644 --- a/apps/common/features/src/entities/auth/lib/auth-wrapper.tsx +++ b/apps/common/features/src/entities/auth/lib/auth-wrapper.tsx @@ -17,7 +17,7 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => { } const response = await client.get( - `${ENDPOINT.USER_SERVICE.USERS}/${userId}`, + `${ENDPOINT.USER_SERVICE.USERS}/info/me`, ); if (!userInfo) setUserInfo(response.data); } diff --git a/apps/common/features/src/shared/store/user-store.ts b/apps/common/features/src/shared/store/user-store.ts index 00379fb1f..65d897cf1 100644 --- a/apps/common/features/src/shared/store/user-store.ts +++ b/apps/common/features/src/shared/store/user-store.ts @@ -5,6 +5,7 @@ export interface IUserInfo { mdfcnDt: string; rgtr: string; mdfr: string; + adminRoleYn: string; userUnqId: string; userId: string; userName: string; diff --git a/apps/common/features/src/widgets/post/ui/post-action.tsx b/apps/common/features/src/widgets/post/ui/post-action.tsx index f0296138f..c74c76482 100644 --- a/apps/common/features/src/widgets/post/ui/post-action.tsx +++ b/apps/common/features/src/widgets/post/ui/post-action.tsx @@ -1,7 +1,7 @@ import { useRouter, usePathname } from "next/navigation"; import { useConfirm } from "@frontend-opensource/use-react-hooks"; import { Button } from "@common/components"; -import { useMenuStore } from "@/shared/lib"; +import { useMenuStore, useUserStore } from "@/shared/lib"; type PostActionProps = { bbsId: string; @@ -15,11 +15,25 @@ function PostAction({ children, handleDelete }: PostActionProps) { const pathname = usePathname(); const { confirm } = useConfirm(); const { bbsInfo } = useMenuStore((state) => state); + const { userInfo } = useUserStore((state) => state); const onDelete = async () => { if (await confirm("삭제하시겠습니까?")) handleDelete(); }; + const checkAnsUseAuthrt = () => { + // 관리자 + if (bbsInfo?.ansUseAuthrt === "A") { + return userInfo?.adminRoleYn === "Y"; + } + // 회원 + if (bbsInfo?.ansUseAuthrt === "M") { + return !!userInfo; + } + // 비회원 + return true; + }; + return (
{children} @@ -45,6 +59,7 @@ function PostAction({ children, handleDelete }: PostActionProps) { type="button" color="gray" onClick={() => router.push(`${pathname}/answer`)} + disabled={!checkAnsUseAuthrt()} > 답글 diff --git a/apps/cs/src/entities/auth/lib/auth-wrapper.tsx b/apps/cs/src/entities/auth/lib/auth-wrapper.tsx index 705c03231..c0be4c2dd 100644 --- a/apps/cs/src/entities/auth/lib/auth-wrapper.tsx +++ b/apps/cs/src/entities/auth/lib/auth-wrapper.tsx @@ -19,7 +19,7 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => { } const response = await client.get( - `${ENDPOINT.USER_SERVICE.USERS}/${userId}`, + `${ENDPOINT.USER_SERVICE.USERS}/info/me`, ); if (!userInfo) setUserInfo(response.data); } diff --git a/apps/cs/src/entities/menu-authority/ui/management-authority-dialog.tsx b/apps/cs/src/entities/menu-authority/ui/management-authority-dialog.tsx index a6d4d2128..1d9e6cb57 100644 --- a/apps/cs/src/entities/menu-authority/ui/management-authority-dialog.tsx +++ b/apps/cs/src/entities/menu-authority/ui/management-authority-dialog.tsx @@ -82,7 +82,9 @@ function ManagementAuthorityDialog({ 그룹별 메뉴 권한 - +
+ +