diff --git a/apps/cs/src/entities/menu-authority/index.ts b/apps/cs/src/entities/menu-authority/index.ts index 07433a098..2a555b77e 100644 --- a/apps/cs/src/entities/menu-authority/index.ts +++ b/apps/cs/src/entities/menu-authority/index.ts @@ -1 +1,2 @@ +export { AuthorityButton } from "./ui/authority-button"; export { ManagementAuthorityDialog } from "./ui/management-authority-dialog"; diff --git a/apps/cs/src/entities/menu-authority/ui/authority-button.tsx b/apps/cs/src/entities/menu-authority/ui/authority-button.tsx new file mode 100644 index 000000000..257ab6e5d --- /dev/null +++ b/apps/cs/src/entities/menu-authority/ui/authority-button.tsx @@ -0,0 +1,26 @@ +import { useMenuStore } from "@/shared/lib"; +import { Button, cn, type ButtonProps } from "@common/components"; +import type { PageMenuAuthority } from "../model/menu-authority-interface"; + +type AuthorityButtonProps = { + authority: keyof PageMenuAuthority; +} & ButtonProps; + +function AuthorityButton({ + authority, + className, + children, + ...props +}: AuthorityButtonProps) { + const pageMenuAuthority = useMenuStore((state) => state.pageMenuAuthority); + + const isAuthority = pageMenuAuthority?.[authority] === "Y"; + + return ( + + ); +} + +export { AuthorityButton }; diff --git a/apps/cs/src/entities/menu/lib/menu-wrapper.tsx b/apps/cs/src/entities/menu/lib/menu-wrapper.tsx index 48fe5e6ed..cb5c92192 100644 --- a/apps/cs/src/entities/menu/lib/menu-wrapper.tsx +++ b/apps/cs/src/entities/menu/lib/menu-wrapper.tsx @@ -25,10 +25,10 @@ const MenuWrapper = ({ children }: { children: React.ReactNode }) => { const getPageMenuAuthority = async () => { const menuCd = getCookie("menu-code-key"); if (!menuCd) return; - const pageMenuAuthority = await MenuAuthorityApi.getPageMenuAuthority( + const response = await MenuAuthorityApi.getPageMenuAuthority( parseInt(menuCd), ); - return pageMenuAuthority; + return response; }; const checkInquiryAuthority = () => { @@ -40,9 +40,8 @@ const MenuWrapper = ({ children }: { children: React.ReactNode }) => { const currentMenu = await getCurrentMenuInfo(); if (currentMenu) setCurrentMenuInfo(currentMenu); - const pageMenuAuthority = await getPageMenuAuthority(); - if (pageMenuAuthority?.length) - setPageMenuAuthority(pageMenuAuthority[0]!); + const response = await getPageMenuAuthority(); + if (response?.length) setPageMenuAuthority(response[0]!); })(); }, []); diff --git a/apps/cs/src/entities/posting/ui/posting-dialog.tsx b/apps/cs/src/entities/posting/ui/posting-dialog.tsx index ac31ad0dc..6aef8cceb 100644 --- a/apps/cs/src/entities/posting/ui/posting-dialog.tsx +++ b/apps/cs/src/entities/posting/ui/posting-dialog.tsx @@ -26,6 +26,7 @@ import { cn, } from "@common/components"; import { CodeSelect } from "@/entities/code/@x/posting"; +import { AuthorityButton } from "@/entities/menu-authority"; import { SiteApi, type Site } from "@/entities/site/@x/posting"; import type { PageableList } from "@/shared/model"; import { ENDPOINT } from "@/shared/config"; @@ -218,10 +219,14 @@ function PostingDialog({ postingType, postingTargets }: PostingDialogProps) { return ( - + diff --git a/apps/cs/src/pages/(post)/faq/ui/faq-page.tsx b/apps/cs/src/pages/(post)/faq/ui/faq-page.tsx index 24ffada45..2c1858899 100644 --- a/apps/cs/src/pages/(post)/faq/ui/faq-page.tsx +++ b/apps/cs/src/pages/(post)/faq/ui/faq-page.tsx @@ -22,6 +22,7 @@ import { } from "@common/components"; import { AttachmentApi } from "@/entities/attachment"; import { PostApi, type PostParams } from "@/entities/post"; +import { AuthorityButton } from "@/entities/menu-authority"; import { useAlertStore, useMenuStore, usePrompt } from "@/shared/lib"; import { ENDPOINT } from "@/shared/config"; @@ -30,7 +31,7 @@ function FaqPage({ bbsId }: { bbsId: string }) { const pathname = usePathname(); const { prompt } = usePrompt(); const { setMessage: alert } = useAlertStore((state) => state); - const { bbsInfo, pageMenuAuthority } = useMenuStore((state) => state); + const { bbsInfo } = useMenuStore((state) => state); const [postParams, setPostParams] = useState({ keywordType: "title", @@ -140,20 +141,20 @@ function FaqPage({ bbsId }: { bbsId: string }) {

콘텐츠 목록

- {pageMenuAuthority?.regAuthrtYn === "Y" && ( - - )} - {pageMenuAuthority?.delAuthrtYn === "Y" && ( - - )} + router.push(`${pathname}/register`)} + > + 등록 + + + 선택삭제 +
diff --git a/apps/cs/src/pages/recent/ui/move-post-dialog.tsx b/apps/cs/src/pages/recent/ui/move-post-dialog.tsx index 64afef317..0afa6b75c 100644 --- a/apps/cs/src/pages/recent/ui/move-post-dialog.tsx +++ b/apps/cs/src/pages/recent/ui/move-post-dialog.tsx @@ -12,6 +12,7 @@ import { } from "@common/components"; import type { Board } from "@/entities/board"; import type { MovePost } from "@/entities/post"; +import { AuthorityButton } from "@/entities/menu-authority"; type MovePostDialogProps = { selectedPosts: MovePost[]; @@ -36,9 +37,12 @@ function MovePostDialog({ return ( - +

diff --git a/apps/cs/src/pages/recent/ui/recent-page.tsx b/apps/cs/src/pages/recent/ui/recent-page.tsx index 407b90d49..217e4318a 100644 --- a/apps/cs/src/pages/recent/ui/recent-page.tsx +++ b/apps/cs/src/pages/recent/ui/recent-page.tsx @@ -30,8 +30,9 @@ import { type RecentPost, type RecentPostParams, } from "@/entities/post"; -import { useAlertStore, useMenuStore, usePrompt } from "@/shared/lib"; import { BoardApi } from "@/entities/board"; +import { AuthorityButton } from "@/entities/menu-authority"; +import { useAlertStore, usePrompt } from "@/shared/lib"; import { ENDPOINT } from "@/shared/config"; import { columns } from "../model/table-columns"; import { MovePostDialog } from "./move-post-dialog"; @@ -46,7 +47,6 @@ function RecentPage() { const { prompt } = usePrompt(); const { confirm } = useConfirm(); const { setMessage: alert } = useAlertStore((state) => state); - const { pageMenuAuthority } = useMenuStore((state) => state); const [dateRange, setDateRange] = useState(); const [pagination, setPagination] = useState({ pageIndex: 0, @@ -272,45 +272,46 @@ function RecentPage() {

콘텐츠 목록

- {pageMenuAuthority?.mngAuthrtYn === "Y" && - (isDeletePostData ? ( - <> - - - - ) : ( - <> - ({ - fromBbsId: row.original.bbsId, - pstNo: row.original.pstNo, - }))} - boardList={boardList?.content ?? []} - onMovePost={movePost} - /> - - - ))} + {isDeletePostData ? ( + <> + + 게시물 복원 + + + 완전삭제 + + + ) : ( + <> + ({ + fromBbsId: row.original.bbsId, + pstNo: row.original.pstNo, + }))} + boardList={boardList?.content ?? []} + onMovePost={movePost} + /> + + 선택삭제 + + + )} {