-
Notifications
You must be signed in to change notification settings - Fork 6
[Feat] 구독한 전략 페이지 구현 #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[Feat] 구독한 전략 페이지 구현 #153
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb81159
feat: 수정된 api 명세에 따른 데이터 수정 (#151)
devdeun 8e5ceec
feat: 구독한 전략 페이지 구현 (#151)
devdeun f9e04b6
refactor: usePagination 훅 분리 (#151)
devdeun 7d889ec
fix: 전략리스트 컴포넌트 스토리북 오류 수정 (#151)
devdeun 50b225a
fix: 전략 페이지 목데이터 출력 위치 수정 (#151)
devdeun 8283c0b
fix: header 대시보드 링크 경로 수정 (#149)
devdeun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
| import { strategiesMockData } from '@/mocks/handlers/strategies' | ||
|
|
||
| import axiosInstance from '@/shared/api/axios' | ||
| import { StrategiesModel } from '@/shared/types/strategy-details-data' | ||
|
|
||
| interface Props { | ||
| page: number | ||
| size: number | ||
| } | ||
|
|
||
| const getFavoriteStrategyList = async ({ | ||
| page = 1, | ||
| size = 6, | ||
| }: Props): Promise<{ strategiesData: StrategiesModel[]; totalPages: number } | undefined> => { | ||
| try { | ||
| const response = await axiosInstance.get( | ||
| `/api/my-strategies/subscribed?page=${page}&size=${size}` | ||
| ) | ||
|
|
||
| const { | ||
| content: strategiesData, | ||
| totalPages, | ||
| }: { content: StrategiesModel[]; totalPages: number } = await response.data.result | ||
|
|
||
| return { strategiesData, totalPages } | ||
| } catch (err) { | ||
| console.error(err) | ||
| // throw new Error('구독한 전략 조회에 실패했습니다.') | ||
| // 임시 목데이터 | ||
| return { strategiesData: strategiesMockData.filter((data) => data.isSubscribed), totalPages: 1 } | ||
| } | ||
| } | ||
|
|
||
| export default getFavoriteStrategyList |
17 changes: 17 additions & 0 deletions
17
app/(dashboard)/my/_hooks/query/use-get-favorite-strategy-list.ts
This file contains hidden or 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,17 @@ | ||
| import { useQuery } from '@tanstack/react-query' | ||
|
|
||
| import getFavoriteStrategyList from '../../_api/get-favorite-strategy-list' | ||
|
|
||
| interface Props { | ||
| page: number | ||
| size: number | ||
| } | ||
|
|
||
| const useGetFavoriteStrategyList = ({ page, size }: Props) => { | ||
| return useQuery({ | ||
| queryKey: ['favoriteStrategies', page, size], | ||
| queryFn: () => getFavoriteStrategyList({ page, size }), | ||
| }) | ||
| } | ||
|
|
||
| export default useGetFavoriteStrategyList |
44 changes: 44 additions & 0 deletions
44
app/(dashboard)/my/favorites/_ui/favorite-strategy-list/index.tsx
This file contains hidden or 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,44 @@ | ||
| 'use client' | ||
|
|
||
| import ListHeader from '@/app/(dashboard)/_ui/list-header' | ||
| import StrategiesItem from '@/app/(dashboard)/_ui/strategies-item' | ||
| import classNames from 'classnames/bind' | ||
|
|
||
| import { PATH } from '@/shared/constants/path' | ||
| import { usePagination } from '@/shared/hooks/custom/use-pagination' | ||
| import Pagination from '@/shared/ui/pagination' | ||
|
|
||
| import useGetFavoriteStrategyList from '../../../_hooks/query/use-get-favorite-strategy-list' | ||
| import styles from './styles.module.scss' | ||
|
|
||
| const cx = classNames.bind(styles) | ||
|
|
||
| const COUNT_PER_PAGE = 6 | ||
|
|
||
| const FavoriteStrategyList = () => { | ||
| const { page, handlePageChange } = usePagination({ | ||
| basePath: PATH.FAVORITES, | ||
| pageSize: COUNT_PER_PAGE, | ||
| }) | ||
|
|
||
| const { data } = useGetFavoriteStrategyList({ page, size: COUNT_PER_PAGE }) | ||
|
|
||
| const strategiesData = data?.strategiesData || [] | ||
| const totalPages = data?.totalPages || null | ||
|
|
||
| return ( | ||
| <> | ||
| <ListHeader /> | ||
| <div className={cx('pagination')}> | ||
| {strategiesData?.map((strategy) => ( | ||
| <StrategiesItem key={strategy.strategyId} strategiesData={strategy} /> | ||
| ))} | ||
| {totalPages && ( | ||
| <Pagination currentPage={page} maxPage={totalPages} onPageChange={handlePageChange} /> | ||
| )} | ||
| </div> | ||
| </> | ||
| ) | ||
| } | ||
|
|
||
| export default FavoriteStrategyList |
3 changes: 3 additions & 0 deletions
3
app/(dashboard)/my/favorites/_ui/favorite-strategy-list/styles.module.scss
This file contains hidden or 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,3 @@ | ||
| .pagination { | ||
| margin-bottom: 24px; | ||
| } |
This file contains hidden or 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,5 @@ | ||
| .container { | ||
| h1 { | ||
| margin: 80px 0 24px; | ||
| } | ||
| } |
This file contains hidden or 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,5 +1,23 @@ | ||
| import { Suspense } from 'react' | ||
|
|
||
| import classNames from 'classnames/bind' | ||
|
|
||
| import Title from '@/shared/ui/title' | ||
|
|
||
| import FavoriteStrategyList from './_ui/favorite-strategy-list' | ||
| import styles from './page.module.scss' | ||
|
|
||
| const cx = classNames.bind(styles) | ||
|
|
||
| const MyFavoritesPage = () => { | ||
| return <></> | ||
| return ( | ||
| <div className={cx('container')}> | ||
| <Title label="구독한 전략" /> | ||
| <Suspense fallback={<div>Loading...</div>}> | ||
| <FavoriteStrategyList /> | ||
| </Suspense> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default MyFavoritesPage |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 다시보니 size도 searchParams로 구하는게 좋겠네요,,,,