From 20173a24ea7de6eb1aafebec30afd4eaa22ff433 Mon Sep 17 00:00:00 2001 From: bicochan Date: Wed, 2 Jul 2025 10:24:47 +0900 Subject: [PATCH] =?UTF-8?q?[common/features,=20apps/cs]=20refactor:=20Sort?= =?UTF-8?q?Select=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/features/src/widgets/post/index.ts | 1 + .../src/widgets/post/ui/post-page.tsx | 22 +++---------- .../src/widgets/post/ui/sort-select.tsx | 32 +++++++++++++++++++ apps/cs/src/pages/recent/ui/recent-page.tsx | 8 +++-- apps/cs/src/widgets/post/index.ts | 1 + apps/cs/src/widgets/post/ui/post-page.tsx | 22 +++---------- apps/cs/src/widgets/post/ui/sort-select.tsx | 32 +++++++++++++++++++ 7 files changed, 80 insertions(+), 38 deletions(-) create mode 100644 apps/common/features/src/widgets/post/ui/sort-select.tsx create mode 100644 apps/cs/src/widgets/post/ui/sort-select.tsx diff --git a/apps/common/features/src/widgets/post/index.ts b/apps/common/features/src/widgets/post/index.ts index 7d43c205d..a7ea4e48e 100644 --- a/apps/common/features/src/widgets/post/index.ts +++ b/apps/common/features/src/widgets/post/index.ts @@ -1,3 +1,4 @@ export { Post } from "./ui/post"; export { PostForm } from "./ui/post-form"; export { PostPage } from "./ui/post-page"; +export { SortSelect } from "./ui/sort-select"; diff --git a/apps/common/features/src/widgets/post/ui/post-page.tsx b/apps/common/features/src/widgets/post/ui/post-page.tsx index 5a459835f..509087b68 100644 --- a/apps/common/features/src/widgets/post/ui/post-page.tsx +++ b/apps/common/features/src/widgets/post/ui/post-page.tsx @@ -33,6 +33,7 @@ import { useMenuStore, useUserStore } from "@/shared/lib"; import { GridViewDataTable } from "@/shared/ui/grid-view-data-table"; import { columns as tableColumns } from "../model/post-table-columns"; import { createColumns as createGridViewColumns } from "../model/grid-view-table-columns"; +import { SortSelect } from "./sort-select"; function PostPage({ bbsId }: { bbsId: string }) { const router = useRouter(); @@ -203,24 +204,9 @@ function PostPage({ bbsId }: { bbsId: string }) { ))} - + {bbsInfo?.ansUseYn === "N" && ( + + )} diff --git a/apps/common/features/src/widgets/post/ui/sort-select.tsx b/apps/common/features/src/widgets/post/ui/sort-select.tsx new file mode 100644 index 000000000..57950e894 --- /dev/null +++ b/apps/common/features/src/widgets/post/ui/sort-select.tsx @@ -0,0 +1,32 @@ +import { + Select, + SelectTrigger, + SelectValue, + SelectContent, + SelectItem, +} from "@common/components"; + +type SortSelectProps = { + value: string; + onValueChange: (value: string) => void; +}; + +function SortSelect(props: SortSelectProps) { + return ( + + ); +} + +export { SortSelect }; diff --git a/apps/cs/src/pages/recent/ui/recent-page.tsx b/apps/cs/src/pages/recent/ui/recent-page.tsx index ec9fec78a..26cf3af85 100644 --- a/apps/cs/src/pages/recent/ui/recent-page.tsx +++ b/apps/cs/src/pages/recent/ui/recent-page.tsx @@ -21,6 +21,7 @@ import { SelectTrigger, SelectValue, } from "@common/components"; +import { SortSelect } from "@/widgets/post"; import { PostApi, deleteReasonMessages, @@ -49,7 +50,9 @@ function RecentPage() { const { prompt } = useSelectPrompt(selectData); const { confirm } = useConfirm(); const alert = useAlertStore((state) => state.setMessage); + const [dateRange, setDateRange] = useState(); + const [tableSort, setTableSort] = useState("regDt,desc"); const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10, @@ -62,17 +65,17 @@ function RecentPage() { delYn: "N", frDateYmd: "", toDateYmd: "", - sort:"regDt,desc" }); const [isDeletePostData, setIsDeletePostData] = useState(false); const query = useQuery({ - queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, pagination], + queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, pagination, tableSort], queryFn: () => PostApi.getRecentPostList({ ...recentPostQuery, page: pagination.pageIndex, size: pagination.pageSize, + sort: tableSort, }), placeholderData: keepPreviousData, }); @@ -342,6 +345,7 @@ function RecentPage() { ))} + diff --git a/apps/cs/src/widgets/post/index.ts b/apps/cs/src/widgets/post/index.ts index a80768562..feb886602 100644 --- a/apps/cs/src/widgets/post/index.ts +++ b/apps/cs/src/widgets/post/index.ts @@ -1,4 +1,5 @@ export { Post } from "./ui/post"; export { PostForm } from "./ui/post-form"; export { PostPage } from "./ui/post-page"; +export { SortSelect } from "./ui/sort-select"; export { GeneralFileUploader } from "./ui/general-file-uploader"; diff --git a/apps/cs/src/widgets/post/ui/post-page.tsx b/apps/cs/src/widgets/post/ui/post-page.tsx index a37cdec84..850513a94 100644 --- a/apps/cs/src/widgets/post/ui/post-page.tsx +++ b/apps/cs/src/widgets/post/ui/post-page.tsx @@ -34,6 +34,7 @@ import { useMenuStore, useSelectPrompt } from "@/shared/lib"; import { GridViewDataTable } from "@/shared/ui/grid-view-data-table"; import { columns as tableColumns } from "../model/post-table-columns"; import { createColumns as createGridViewColumns } from "../model/grid-view-table-columns"; +import { SortSelect } from "./sort-select"; const selectData = Object.entries(deleteReasonMessages).map( ([label, value]) => ({ label, value }), @@ -212,24 +213,9 @@ function PostPage({ bbsId }: { bbsId: string }) { ))} - + {bbsInfo?.ansUseYn === "N" && ( + + )} diff --git a/apps/cs/src/widgets/post/ui/sort-select.tsx b/apps/cs/src/widgets/post/ui/sort-select.tsx new file mode 100644 index 000000000..57950e894 --- /dev/null +++ b/apps/cs/src/widgets/post/ui/sort-select.tsx @@ -0,0 +1,32 @@ +import { + Select, + SelectTrigger, + SelectValue, + SelectContent, + SelectItem, +} from "@common/components"; + +type SortSelectProps = { + value: string; + onValueChange: (value: string) => void; +}; + +function SortSelect(props: SortSelectProps) { + return ( + + ); +} + +export { SortSelect };