Skip to content

Commit

Permalink
#523 fix : community not exist page error (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsikkk authored Nov 2, 2023
1 parent 619b9d0 commit 3d182d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/Community/CommunityDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function CommunityDetail({ board, id, format }) {
setDetail(response_detail.data);
setLike(response_detail.data.likes);
setLoading(false);
if (response_detail.data.board != board) navigate("/notexistpage");
if (response_detail.data.board != board) navigate("/notexistpage", {state:{path: "/community/1?page=1"}});
}
catch(e) {
navigate("/notexistpage");
Expand Down
10 changes: 2 additions & 8 deletions src/components/Community/CommunityList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ export default function CommunityList({ board, format }) {
page : queryString.page
}
if (search) params.search = search
setList(response.data.data.results);
setSearchParams(params);
setList(response.data.data.results);
setTotal(response.data.data.count);
setLoading(false);
}
Expand All @@ -149,13 +149,8 @@ export default function CommunityList({ board, format }) {
if (e) {
e.preventDefault();
}
if (tempSearch === null || tempSearch === "") {
!tempSearch ? setSearch('') : setSearch(tempSearch);
//검색어 없을 경우 전체 리스트 반환
setSearch('');
} else {
//검색어 있는 경우
setSearch(tempSearch);
}
};

const otherUserData = async (email) => {
Expand Down Expand Up @@ -190,7 +185,6 @@ export default function CommunityList({ board, format }) {
setTotal(response.data.data.count);
setLoading(false);
}

useEffect(() => {
getItem();
setMode(false);
Expand Down
5 changes: 2 additions & 3 deletions src/pages/SpotCommunity.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ export default function SpotCommunity() {
try {
const response = await request.get(`/community/boards/${params.board}/`);
setFormat(response.data);
setLoading(false);
setLoading(false);
if (params.board > 4) {navigate(`/notexistpage`, {state: {path: "/community/1?page=1"}})}
}
catch (e) {
navigate(`/notexistpage`);
}
}

if (params.board > 4) {navigate(`/notexistpage`)}

useEffect(() => {
getFormat();
}, [params.board]);
Expand Down

0 comments on commit 3d182d1

Please sign in to comment.