feat: 게시물 답글 버튼 권한 적용
This commit is contained in:
@@ -17,7 +17,7 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
}
|
||||
|
||||
const response = await client.get<IUserInfo>(
|
||||
`${ENDPOINT.USER_SERVICE.USERS}/${userId}`,
|
||||
`${ENDPOINT.USER_SERVICE.USERS}/info/me`,
|
||||
);
|
||||
if (!userInfo) setUserInfo(response.data);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ export interface IUserInfo {
|
||||
mdfcnDt: string;
|
||||
rgtr: string;
|
||||
mdfr: string;
|
||||
adminRoleYn: string;
|
||||
userUnqId: string;
|
||||
userId: string;
|
||||
userName: string;
|
||||
|
||||
@@ -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 (
|
||||
<div>
|
||||
{children}
|
||||
@@ -45,6 +59,7 @@ function PostAction({ children, handleDelete }: PostActionProps) {
|
||||
type="button"
|
||||
color="gray"
|
||||
onClick={() => router.push(`${pathname}/answer`)}
|
||||
disabled={!checkAnsUseAuthrt()}
|
||||
>
|
||||
답글
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user