Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions frontend/src/pages/MainPage/MainPage.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ export const FilterWrapper = styled.div`
justify-content: right;
margin: 20px 0;
`;

export const EmptyResult = styled.div`
padding: 80px 20px;
text-align: center;
color: #555;
font-size: 1.125rem;
line-height: 1.6;
white-space: pre-line;

@media (max-width: 500px) {
font-size: 0.95rem;
}
`;
26 changes: 18 additions & 8 deletions frontend/src/pages/MainPage/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Banner from '@/pages/MainPage/components/Banner/Banner';
import { DesktopBannerImageList } from '@/constants/banners';
import { MobileBannerImageList } from '@/constants/banners';
import { Club } from '@/types/club';
import Spinner from '@/components/common/Spinner/Spinner';
import * as Styled from './MainPage.styles';

const MainPage = () => {
Expand All @@ -23,13 +24,12 @@ const MainPage = () => {
const recruitmentStatus = isFilterActive ? 'OPEN' : 'all';
const division = 'all';

const { data: clubs, error } = useGetCardList(
keyword,
recruitmentStatus,
division,
selectedCategory,
);

const {
data: clubs,
error,
isLoading,
} = useGetCardList(keyword, recruitmentStatus, division, selectedCategory);
const isEmpty = !isLoading && (!clubs || clubs.length === 0);
const hasData = clubs && clubs.length > 0;

const clubList = useMemo(() => {
Expand All @@ -54,7 +54,17 @@ const MainPage = () => {
<StatusRadioButton onChange={setIsFilterActive} />
</Styled.FilterWrapper>
<Styled.ContentWrapper>
<Styled.CardList>{hasData && clubList}</Styled.CardList>
{isLoading ? (
<Spinner />
) : isEmpty ? (
<Styled.EmptyResult>
앗, 조건에 맞는 동아리가 없어요.
<br />
다른 키워드나 조건으로 다시 시도해보세요!
</Styled.EmptyResult>
) : (
<Styled.CardList>{clubList}</Styled.CardList>
)}
</Styled.ContentWrapper>
</Styled.PageContainer>
<Footer />
Expand Down