-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
114 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,54 @@ | ||
import type { BlogPostType } from '@src/lib/types/blog'; | ||
import type { PartCategoryType } from '@src/lib/types/blog'; | ||
import BlogPost from '@src/views/BlogPage/components/BlogPost'; | ||
import { OvalSpinner } from '@src/views/ProjectPage/components'; | ||
import { useGetResponse } from '../../hooks/queries/useGetResponse'; | ||
import useInfiniteScroll from '../../hooks/useInfiniteScroll'; | ||
import { selectedType } from '../BlogTab/types'; | ||
import EmptyBlogPostList from '../EmptyBlogPostList'; | ||
import * as S from './style'; | ||
|
||
interface BlogPostListProps { | ||
selectedTap: string; // review || article | ||
blogPostList: BlogPostType[]; | ||
selected: selectedType; | ||
setMajorCategory: (newValue: number) => void; | ||
setSubCategory: (newValue: PartCategoryType) => void; | ||
} | ||
|
||
export default function BlogPostList({ selectedTap, blogPostList }: BlogPostListProps) { | ||
export default function BlogPostList({ | ||
selected, | ||
setMajorCategory, | ||
setSubCategory, | ||
}: BlogPostListProps) { | ||
const { selectedTab, selectedMajorCategory, selectedSubCategory } = selected; | ||
|
||
const { response, hasNextPage, fetchNextPage, isFetching } = useGetResponse( | ||
selectedTab, | ||
selectedMajorCategory, | ||
selectedSubCategory, | ||
); | ||
const { ref } = useInfiniteScroll(fetchNextPage); | ||
|
||
return ( | ||
<S.BlogPostList> | ||
{blogPostList?.map((blogPost) => ( | ||
<BlogPost key={blogPost.id} blogPost={blogPost} selectedTap={selectedTap} /> | ||
))} | ||
</S.BlogPostList> | ||
<> | ||
{response?.length == 0 ? ( | ||
<EmptyBlogPostList | ||
selectedTab={selectedTab} | ||
setMajorCategory={setMajorCategory} | ||
setSubCategory={setSubCategory} | ||
/> | ||
) : ( | ||
<> | ||
<S.BlogPostList> | ||
{response?.map((blogPost) => ( | ||
<BlogPost key={blogPost.id} blogPost={blogPost} selectedTab={selectedTab} /> | ||
))} | ||
</S.BlogPostList> | ||
{(hasNextPage || isFetching) && ( | ||
<S.SpinnerWrapper ref={hasNextPage ? ref : undefined}> | ||
<OvalSpinner /> | ||
</S.SpinnerWrapper> | ||
)} | ||
</> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { activeGenerationCategoryList } from '@src/lib/constants/tabs'; | ||
import { PartCategoryType } from '@src/lib/types/blog'; | ||
import { BlogTabType } from '../BlogTab/types'; | ||
import * as S from './style'; | ||
|
||
interface EmptyBlogPostListProps { | ||
selectedTab: BlogTabType; | ||
setMajorCategory: (newValue: number) => void; | ||
setSubCategory: (newValue: PartCategoryType) => void; | ||
} | ||
export default function EmptyBlogPostList({ | ||
selectedTab, | ||
setMajorCategory, | ||
setSubCategory, | ||
}: EmptyBlogPostListProps) { | ||
const showTotalPostList = () => { | ||
setMajorCategory(activeGenerationCategoryList[0]); | ||
setSubCategory(PartCategoryType.ALL); | ||
}; | ||
|
||
return ( | ||
<S.EmptyBlogPostListWrapper> | ||
<S.EmptyBlogPostList> | ||
{`아직 올라온 ${selectedTab === 'article' ? '아티클이' : '활동후기가'} 없어요`} | ||
</S.EmptyBlogPostList> | ||
<S.Total onClick={showTotalPostList}>{`${ | ||
selectedTab === 'article' ? '아티클' : '활동후기' | ||
} 전체 보기`}</S.Total> | ||
</S.EmptyBlogPostListWrapper> | ||
); | ||
} |
7 changes: 0 additions & 7 deletions
7
src/views/BlogPage/style.ts → ...age/components/EmptyBlogPostList/style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters