[common/features] refactor: 통합 검색 기능 공통 기능으로 변경
This commit is contained in:
@@ -12,6 +12,8 @@ type PostActionProps = {
|
||||
handleDelete: () => Promise<void>;
|
||||
};
|
||||
|
||||
const basePath = process.env.NODE_ENV === "production" ? "/cms" : "";
|
||||
|
||||
function PostAction({ registerId, children, handleDelete }: PostActionProps) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
@@ -19,6 +21,7 @@ function PostAction({ registerId, children, handleDelete }: PostActionProps) {
|
||||
const { copyText, copied } = useClipboard();
|
||||
const bbsInfo = useMenuStore((state) => state.bbsInfo);
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const postPageLink = `${basePath}/${bbsInfo?.bbsTypeCd.toLowerCase()}/${bbsInfo?.bbsId}`;
|
||||
|
||||
const actionButtonAuthrt =
|
||||
userInfo?.adminRoleYn === "Y" || userInfo?.userUnqId === registerId;
|
||||
@@ -60,7 +63,7 @@ function PostAction({ registerId, children, handleDelete }: PostActionProps) {
|
||||
size="lg"
|
||||
color="white"
|
||||
type="button"
|
||||
onClick={() => router.back()}
|
||||
onClick={() => router.push(postPageLink)}
|
||||
>
|
||||
목록
|
||||
</Button>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Skeleton,
|
||||
} from "@common/components";
|
||||
import { AttachmentApi } from "@/entities/attachment";
|
||||
import { BoardApi } from "@/entities/board";
|
||||
import { PostApi } from "@/entities/post";
|
||||
import {
|
||||
useAlertStore,
|
||||
@@ -31,10 +32,17 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const bbsInfo = useMenuStore((state) => state.bbsInfo);
|
||||
const setBbsInfo = useMenuStore((state) => state.setBbsInfo);
|
||||
|
||||
const [filename, setFilename] = useState("");
|
||||
const [evlScr, setEvlScr] = useState(5);
|
||||
|
||||
const { data: boardInfo } = useQuery({
|
||||
queryKey: [bbsId],
|
||||
queryFn: () => BoardApi.getBoardInfo(bbsId),
|
||||
enabled: !bbsInfo,
|
||||
});
|
||||
|
||||
const { data: postData } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, pstNo],
|
||||
queryFn: () => PostApi.getPostInfo(parseInt(bbsId), parseInt(pstNo)),
|
||||
@@ -142,6 +150,12 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
}
|
||||
}, [downloadResponse]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!boardInfo) return;
|
||||
if (bbsInfo) return;
|
||||
setBbsInfo(boardInfo);
|
||||
}, [boardInfo, bbsInfo]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PostAction registerId={postData?.rgtr} handleDelete={handleDelete}>
|
||||
|
||||
Reference in New Issue
Block a user