Skip to content

Commit

Permalink
#83 feat: 검색결과 존재하지 않을때 조건부 렌더링
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamong0620 committed Sep 25, 2024
1 parent 4646cda commit 759407a
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/pages/ChallengeCommunityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ChallengeCard from '../components/ChallengeCard';
import { Link } from 'react-router-dom';
import { Challenge, ChallengeCategory, ChallengeResponse } from '../types/ChallengeType';
import { getSearchChallenge } from '../api/ChallengeApi';
import { NotExistingDocument } from '../styles/TeamDocumentStyled';

const ChallengeCommunityPage = () => {
const [count, setCount] = useState<number>(1); // 총 페이지 수
Expand Down Expand Up @@ -130,17 +131,25 @@ const ChallengeCommunityPage = () => {
</S.SearchBar>
</S.SearchContainer>

<Flex justifyContent="center">
<S.ChallengeContainer>
{challenges?.map((challenge, index) => (
<ChallengeCard key={index} challenge={challenge} />
))}
</S.ChallengeContainer>
</Flex>
{challenges?.length !== 0 ? (
<>
<Flex justifyContent="center">
<S.ChallengeContainer>
{challenges?.map((challenge, index) => (
<ChallengeCard key={index} challenge={challenge} />
))}
</S.ChallengeContainer>
</Flex>

<S.PaginationWrapper>
<Pagination count={pageInfo?.totalPages} page={page} onChange={handleChangePage} />
</S.PaginationWrapper>
<S.PaginationWrapper>
<Pagination count={pageInfo?.totalPages} page={page} onChange={handleChangePage} />
</S.PaginationWrapper>
</>
) : (
<Flex justifyContent="center" alignItems="center" height={400}>
<NotExistingDocument>해당하는 검색결과가 존재하지 않아요</NotExistingDocument>
</Flex>
)}
</S.MainDashBoardContainer>
</S.MainDashBoardLayout>
);
Expand Down

0 comments on commit 759407a

Please sign in to comment.