-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #583 from depromeet/develop
배포용 PR
- Loading branch information
Showing
7 changed files
with
114 additions
and
6 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
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,53 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
import { type FeedVisibilityType, useGetFeedList } from '@/apis/feed'; | ||
import FeedList from '@/app/feed/FeedList'; | ||
import Tab from '@/components/Tab/Tab'; | ||
import { useTab } from '@/components/Tab/Tab.hooks'; | ||
import useShowGuide, { GUIDE_KEY } from '@/hooks/useShowGuide'; | ||
import { css } from '@/styled-system/css'; | ||
|
||
const FEED_TABS: { id: FeedVisibilityType; tabName: string }[] = [ | ||
{ | ||
id: 'ALL', | ||
tabName: '전체', | ||
}, | ||
{ | ||
id: 'FOLLOWER', | ||
tabName: '팔로워', | ||
}, | ||
]; | ||
|
||
function FeedSection() { | ||
const tabProps = useTab(FEED_TABS, 'FOLLOWER'); | ||
|
||
const { data, isLoading } = useGetFeedList(tabProps.activeTab as FeedVisibilityType); | ||
const feeds = data?.filter((feed) => feed.recordImageUrl); // 이미지 없는 경우가 있음. 나중에 리팩토링 + 서버와 이야기, FeedItem에 ErrorBoundary 적용해도 좋을 듯. | ||
|
||
// NOTE: 초기에 팔로워의 피드가 없는 상태라면, 전체 피드로 변경 | ||
useEffect(() => { | ||
if (!isLoading) { | ||
if (feeds?.length === 0) { | ||
tabProps.onTabClick(FEED_TABS[0]); | ||
} | ||
} | ||
}, [isLoading]); | ||
|
||
useShowGuide(GUIDE_KEY.ALL_FEED_OPEN, 'appBar'); | ||
|
||
return ( | ||
<div> | ||
<div className={tabWrapperCss}> | ||
<Tab {...tabProps} /> | ||
</div> | ||
<FeedList data={feeds} /> | ||
</div> | ||
); | ||
} | ||
|
||
export default FeedSection; | ||
|
||
const tabWrapperCss = css({ | ||
padding: '16px 16px 4px 16px', | ||
}); |
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,35 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
import { type SnackBarOffset } from '@/components/SnackBar/SnackBar.types'; | ||
import { useSnackBar } from '@/components/SnackBar/SnackBarProvider'; | ||
|
||
export enum GUIDE_KEY { | ||
ALL_FEED_OPEN = 'ALL_FEED_OPEN', | ||
} | ||
|
||
const GuideMessage: Record<GUIDE_KEY, string> = { | ||
[GUIDE_KEY.ALL_FEED_OPEN]: '상단에 전체 피드 기능이 추가되었습니다. 확인해보세요!', | ||
}; | ||
|
||
function useShowGuide(key: GUIDE_KEY, offset?: SnackBarOffset) { | ||
const { triggerSnackBar } = useSnackBar(); | ||
|
||
const showGuide = () => { | ||
triggerSnackBar({ | ||
message: GuideMessage[key], | ||
offset, | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
if (typeof window === 'undefined') return; | ||
if (!key) return; | ||
if (localStorage.getItem(key)) return; | ||
|
||
showGuide(); | ||
localStorage.setItem(key, 'true'); | ||
}, []); | ||
} | ||
|
||
export default useShowGuide; |