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]" /> +