feat: 이미지 및 동영상 게시글 작업(cs, features)
This commit is contained in:
@@ -35,7 +35,7 @@ function PostAction({ children, handleDelete }: PostActionProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<>
|
||||
{children}
|
||||
<div className="flex justify-center gap-4 pb-12 pt-10">
|
||||
<Button
|
||||
@@ -68,7 +68,7 @@ function PostAction({ children, handleDelete }: PostActionProps) {
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,8 @@ function PostComment({ bbsId, pstNo }: { bbsId: number; pstNo: number }) {
|
||||
if (userInfo?.userUnqId) {
|
||||
cmntPswd = userInfo?.userUnqId;
|
||||
} else {
|
||||
cmntPswd = await prompt("비밀번호를 입력해주세요.");
|
||||
const { resolved, value } = await prompt("비밀번호를 입력해주세요.");
|
||||
if (resolved) cmntPswd = value ?? "";
|
||||
}
|
||||
return cmntPswd;
|
||||
};
|
||||
|
||||
@@ -24,11 +24,10 @@ import {
|
||||
} from "@common/components";
|
||||
import { PostApi, type Post, type PostParams } from "@/entities/post";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type { BbsType } from "@/shared/store/menu-store";
|
||||
import { useMenuStore, useUserStore } from "@/shared/lib";
|
||||
import { GridViewDataTable } from "@/shared/ui/grid-view-data-table";
|
||||
import { columns } from "../model/post-table-columns";
|
||||
import { createColumns } from "../model/grid-view-table-columns";
|
||||
import { columns as tableColumns } from "../model/post-table-columns";
|
||||
import { createColumns as createGridViewColumns } from "../model/grid-view-table-columns";
|
||||
|
||||
function PostPage({ bbsId }: { bbsId: string }) {
|
||||
const router = useRouter();
|
||||
@@ -36,7 +35,6 @@ function PostPage({ bbsId }: { bbsId: string }) {
|
||||
const { confirm } = useConfirm();
|
||||
const { userInfo } = useUserStore((state) => state);
|
||||
const { bbsInfo, pageMenuAuthority } = useMenuStore((state) => state);
|
||||
const bbsType = bbsInfo?.bbsTypeCd as BbsType;
|
||||
|
||||
const [postParams, setPostParams] = useState<PostParams>({
|
||||
keywordType: "title",
|
||||
@@ -53,7 +51,7 @@ function PostPage({ bbsId }: { bbsId: string }) {
|
||||
const { data: upndFixPostList } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, bbsInfo],
|
||||
queryFn: () =>
|
||||
PostApi.getPostList(bbsId, {
|
||||
PostApi.getPostList(parseInt(bbsId), {
|
||||
...postParams,
|
||||
upndFixYn: bbsInfo?.upndFixUseYn,
|
||||
}),
|
||||
@@ -77,7 +75,7 @@ function PostPage({ bbsId }: { bbsId: string }) {
|
||||
} = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId],
|
||||
queryFn: () =>
|
||||
PostApi.getPostList(bbsId, {
|
||||
PostApi.getPostList(parseInt(bbsId), {
|
||||
...postParams,
|
||||
page: pagination.pageIndex,
|
||||
size: pagination.pageSize,
|
||||
@@ -85,9 +83,14 @@ function PostPage({ bbsId }: { bbsId: string }) {
|
||||
enabled: false,
|
||||
});
|
||||
|
||||
const isGridViewPage =
|
||||
bbsInfo?.bbsTypeCd === "BBSIMAGE" || bbsInfo?.bbsTypeCd === "BBSMOVIE";
|
||||
|
||||
const table = useReactTable({
|
||||
data: [...(upndFixPostList?.content ?? []), ...(postList?.content ?? [])],
|
||||
columns,
|
||||
data: isGridViewPage
|
||||
? (postList?.content ?? [])
|
||||
: [...(upndFixPostList?.content ?? []), ...(postList?.content ?? [])],
|
||||
columns: isGridViewPage ? createGridViewColumns(thumbRefs) : tableColumns,
|
||||
state: { pagination, rowSelection },
|
||||
rowCount: postList?.totalElements ?? 0,
|
||||
manualPagination: true,
|
||||
@@ -95,19 +98,10 @@ function PostPage({ bbsId }: { bbsId: string }) {
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onPaginationChange: setPagination,
|
||||
onRowSelectionChange: setRowSelection,
|
||||
meta: { bbsTypeCd: bbsInfo?.bbsTypeCd },
|
||||
});
|
||||
|
||||
const gridViewTable = useReactTable({
|
||||
data: postList?.content ?? [],
|
||||
columns: createColumns(thumbRefs),
|
||||
state: { pagination, rowSelection },
|
||||
rowCount: postList?.totalElements ?? 0,
|
||||
manualPagination: true,
|
||||
enableMultiRowSelection: true,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onPaginationChange: setPagination,
|
||||
onRowSelectionChange: setRowSelection,
|
||||
});
|
||||
const DataTableComponent = isGridViewPage ? GridViewDataTable : DataTable;
|
||||
|
||||
const onPostDelete = async () => {
|
||||
const selectedPosts = table
|
||||
@@ -118,7 +112,7 @@ function PostPage({ bbsId }: { bbsId: string }) {
|
||||
setRowSelection({});
|
||||
await Promise.all(
|
||||
selectedPosts.map((pstNo) =>
|
||||
PostApi.deletePost(bbsId, pstNo.toString(), userInfo?.userUnqId),
|
||||
PostApi.deletePost(parseInt(bbsId), pstNo, userInfo?.userUnqId),
|
||||
),
|
||||
);
|
||||
refetch();
|
||||
@@ -211,19 +205,11 @@ function PostPage({ bbsId }: { bbsId: string }) {
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] h-full overflow-auto !p-0">
|
||||
{isFetched ? (
|
||||
bbsType === "BBSIMAGE" ? (
|
||||
<GridViewDataTable
|
||||
table={gridViewTable}
|
||||
onRowClick={handleRowClick}
|
||||
viewPagination
|
||||
/>
|
||||
) : (
|
||||
<DataTable
|
||||
table={table}
|
||||
onRowClick={handleRowClick}
|
||||
viewPagination
|
||||
/>
|
||||
)
|
||||
<DataTableComponent
|
||||
table={table}
|
||||
onRowClick={handleRowClick}
|
||||
viewPagination
|
||||
/>
|
||||
) : (
|
||||
<Skeleton className="h-[36rem] w-full" />
|
||||
)}
|
||||
|
||||
@@ -29,7 +29,7 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
|
||||
const { data: postData } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, pstNo],
|
||||
queryFn: () => PostApi.getPostInfo(bbsId, pstNo),
|
||||
queryFn: () => PostApi.getPostInfo(parseInt(bbsId), parseInt(pstNo)),
|
||||
});
|
||||
|
||||
const { data: downloadResponse, isFetching } = useQuery({
|
||||
@@ -47,7 +47,8 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
});
|
||||
|
||||
const { mutate: deletePost } = useMutation({
|
||||
mutationFn: (pstPswd: string) => PostApi.deletePost(bbsId, pstNo, pstPswd),
|
||||
mutationFn: (pstPswd: string) =>
|
||||
PostApi.deletePost(parseInt(bbsId), parseInt(pstNo), pstPswd),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.", router.back);
|
||||
},
|
||||
@@ -58,7 +59,8 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
if (userInfo?.userUnqId) {
|
||||
pstPswd = userInfo?.userUnqId;
|
||||
} else {
|
||||
pstPswd = await prompt("비밀번호를 입력해주세요.");
|
||||
const { resolved, value } = await prompt("비밀번호를 입력해주세요.");
|
||||
if (resolved) pstPswd = value ?? "";
|
||||
}
|
||||
deletePost(pstPswd);
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ function WithPreviewFileUploader<T extends PostFormData | PostUpdateFormData>({
|
||||
imageUrl = await AttachmentApi.getImageUrlByAtflId(atflId);
|
||||
}
|
||||
if (bbsInfo?.bbsTypeCd === "BBSMOVIE") {
|
||||
imageUrl = await AttachmentApi.getMovieThumbnailUrl(atflId);
|
||||
imageUrl = await AttachmentApi.getMovieThumbnailUrlByAtflId(atflId);
|
||||
}
|
||||
setThumbnailUrl(imageUrl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user