From cc21f5a044991e830549da8141c72acd1f5303f2 Mon Sep 17 00:00:00 2001 From: bicochan Date: Thu, 10 Jul 2025 11:26:15 +0900 Subject: [PATCH] =?UTF-8?q?[common/features]=20feat:=20=EA=B2=80=EC=83=89?= =?UTF-8?q?=20=EC=B4=88=EA=B8=B0=ED=99=94=20=EB=A1=9C=EC=A7=81=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=20(CS=5FUT01010101)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/widgets/post/ui/post-page.tsx | 61 ++++++++++++++----- 1 file changed, 46 insertions(+), 15 deletions(-) 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 509087b68..7aaa390fc 100644 --- a/apps/common/features/src/widgets/post/ui/post-page.tsx +++ b/apps/common/features/src/widgets/post/ui/post-page.tsx @@ -44,7 +44,9 @@ function PostPage({ bbsId }: { bbsId: string }) { const thumbRefs = useRef>(new Map()); const [tableSort, setTableSort] = useState(""); - const [postParams, setPostParams] = useState({ + const [keywordType, setKeywordType] = useState("title"); + const [keyword, setKeyword] = useState(""); + const [searchParams, setSearchParams] = useState({ keywordType: "title", keyword: "", }); @@ -58,7 +60,7 @@ function PostPage({ bbsId }: { bbsId: string }) { queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, bbsInfo], queryFn: () => PostApi.getPostList(parseInt(bbsId), { - ...postParams, + ...searchParams, upndFixYn: bbsInfo?.upndFixUseYn, }), select: (data) => { @@ -79,10 +81,16 @@ function PostPage({ bbsId }: { bbsId: string }) { isLoading, refetch, } = useQuery({ - queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, pagination, tableSort], + queryKey: [ + ENDPOINT.BOARD_SERVICE.POSTS_USER, + bbsId, + searchParams, + pagination, + tableSort, + ], queryFn: () => PostApi.getPostList(parseInt(bbsId), { - ...postParams, + ...searchParams, ansUseYn: bbsInfo?.ansUseYn, page: pagination.pageIndex, size: pagination.pageSize, @@ -128,7 +136,29 @@ function PostPage({ bbsId }: { bbsId: string }) { const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - refetch(); + setPagination({ + ...pagination, + pageIndex: 0, + }); + setSearchParams({ + ...searchParams, + keywordType, + keyword, + }); + }; + + const handleReset = () => { + setKeywordType("title"); + setKeyword(""); + setPagination({ + ...pagination, + pageIndex: 0, + }); + setSearchParams({ + ...searchParams, + keywordType: "title", + keyword: "", + }); }; const handleRowClick = (row: Post) => { @@ -141,12 +171,7 @@ function PostPage({ bbsId }: { bbsId: string }) {
- @@ -157,15 +182,21 @@ function PostPage({ bbsId }: { bbsId: string }) { - setPostParams({ ...postParams, keyword: e.target.value }) - } + value={keyword} + onChange={(e) => setKeyword(e.target.value)} className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem]" /> +