-
Notifications
You must be signed in to change notification settings - Fork 6
Feat: 페이지네이션 merge 이후 Link 페이지 개선, useViewport useFetchLinks 훅 추가 #91
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
The head ref may contain hidden characters: "feature/Link-\uD398\uC774\uC9C0"
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7dd4754
Feat: 검색했을 때 000으로 검색했습니다. 문구 표시 뜨게 하는 UI 추가
junjeeong 4055f2b
Working: 링크 검색, 추가 기능 작업중
junjeeong 6eaaace
Feat: 링크 검색기능 추가, CardsLayout margin 추가
junjeeong 68874c1
Feat: 링크 추가하기 기본 기능 구현
junjeeong db99170
Fix: input에 값 남는 버그, CI 버그 해결
junjeeong ba25f72
Fix: console.log 삭제
junjeeong 729e5a5
Merge branch 'develop' into feature/Link-페이지
junjeeong b00868b
Feat: 폴더추가 기능 구현
junjeeong 866a0f4
Feat: 폴더 추가 기능
junjeeong 9f10236
Feat: 페이지네이션 merge 이후 Link 페이지 개선, useViewport useFetchLinks 훅 추가
junjeeong d63c126
Fix: CI 에러 제거
junjeeong 8230c3f
Fix: fetchProxy.ts 주석 오타 수정
junjeeong 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 was deleted.
Oops, something went wrong.
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,19 +1,32 @@ | ||
| import { useEffect } from "react"; | ||
| import { proxy } from "@/lib/api/axiosInstanceApi"; | ||
| import { LinkData } from "@/types/linkTypes"; | ||
| import useViewport from "./useViewport"; | ||
|
|
||
| // 검색어에 맞는 리스트로 setLinkCardList 해주는 함수 | ||
| // 링크페이지의 query가 바뀌면 새로운 리스트로 업데이트 해주는 훅 | ||
| const useFetchLinks = ( | ||
| search: string | string[] | undefined, | ||
| query: { | ||
| page?: number; | ||
| search?: string; | ||
| }, | ||
| setLinkCardList: (list: LinkData[]) => void | ||
| ) => { | ||
| const { isTablet } = useViewport(); | ||
|
|
||
| useEffect(() => { | ||
| const fetchLinks = async () => { | ||
| const res = await proxy.get("/api/links", { params: { search } }); | ||
| const res = await proxy.get("/api/links", { | ||
| params: { | ||
| page: query.page, | ||
| pageSize: isTablet ? 6 : 10, | ||
| search: query.search, | ||
| }, | ||
| }); | ||
| setLinkCardList(res.data.list); | ||
| }; | ||
| if (search) fetchLinks(); | ||
| }, [search, setLinkCardList]); | ||
|
|
||
| if (query) fetchLinks(); | ||
| }, [query, setLinkCardList, isTablet]); | ||
| }; | ||
|
|
||
| export default useFetchLinks; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 잘 사용하겠습니다 😭 |
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,32 @@ | ||
| import { useState, useEffect } from "react"; | ||
|
|
||
| const breakpoints = { | ||
| PC: { min: 1200 }, | ||
| Tablet: { min: 768, max: 1199 }, | ||
| Mobile: { min: 343, max: 767 }, | ||
| }; | ||
|
|
||
| // 현재 브라우저의 innerWidth와 반응형 상태를 반환하는 훅 | ||
| function useViewport(initialWidth = 0) { | ||
| const [width, setWidth] = useState(initialWidth); | ||
|
|
||
| const handleResize = () => { | ||
| setWidth(window.innerWidth); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| handleResize(); | ||
| window.addEventListener("resize", handleResize); | ||
| return () => window.removeEventListener("resize", handleResize); | ||
| }, []); | ||
|
|
||
| const isPC = width >= breakpoints.PC.min; | ||
| const isTablet = | ||
| width >= breakpoints.Tablet.min && width <= breakpoints.Tablet.max; | ||
| const isMobile = | ||
| width >= breakpoints.Mobile.min && width <= breakpoints.Mobile.max; | ||
|
|
||
| return { width, isPC, isTablet, isMobile }; | ||
| } | ||
|
|
||
| export default useViewport; |
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
Oops, something went wrong.
You are viewing a condensed version of this merge commit. You can view the full changes here.
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.
설명 감사합니당 👍