-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 기기 검색 API 구현 #149
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: 기기 검색 API 구현 #149
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
16a43ae
comment: 주석 제거
6273513
feat: 기기검색 API 연동 ( 수정사항 일부 남아있음 )
5d0d042
feat: 검색할 때 새 데이터가 준비되면 로딩되도록 구현, (깜빡거림 해결)
861fea5
feat: 브랜드 이름 중복 해결
866978c
feat: 제품 사진 구현
944eca7
fix: 충전기 ( 로 인해 너비가 넓게 잡혀서, 19로 줄임
9b43188
design: RootLayout과의 css 문제를 뷰포트 이용하여 반응형 해결
f06c152
design: spinner 연결
7fad2c3
feat: 기기 상세보기 스펙: 색상 삭제, 충전방식 출시일 API 데이터로 변경
49d71d2
fix: 기기 상세모달에서 사진 보이도록 수정
b488c98
design: 기기 상세보기 모달 라이프스타일 제거
f9e5ff7
feat: 기기 상세보기 스펙 넘어오지 않는 행 hidden
f2395df
feat: 기기 상세보기 스펙 인치 추가
7e9e42e
fix: 빌드에러 해결
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { axiosInstance } from '@/apis/axios/axios'; | ||
| import type { | ||
| SearchDevicesParams, | ||
| GetDevicesSearchResponse, | ||
| DeviceSearchResult, | ||
| } from '@/types/devices'; | ||
| import { useInfiniteQuery } from '@tanstack/react-query'; | ||
| import { queryKey } from '@/constants/queryKey'; | ||
|
|
||
| export const searchDevices = async ( | ||
| params: SearchDevicesParams | ||
| ): Promise<DeviceSearchResult> => { | ||
| const { data } = await axiosInstance.get<GetDevicesSearchResponse>( | ||
| '/api/devices/search', | ||
| { params } | ||
| ); | ||
| return data.result ?? { devices: [], nextCursor: null, hasNext: false }; | ||
| }; | ||
|
|
||
| export const useSearchDevices = (params: Omit<SearchDevicesParams, 'cursor'>) => { | ||
| return useInfiniteQuery<DeviceSearchResult, Error>({ | ||
| queryKey: [queryKey.DEVICE_SEARCH, params], | ||
| queryFn: ({ pageParam }) => | ||
| searchDevices({ | ||
| ...params, | ||
| cursor: pageParam as string | undefined, | ||
| }), | ||
| initialPageParam: undefined as string | undefined, | ||
| getNextPageParam: (lastPage) => | ||
| lastPage?.hasNext ? lastPage.nextCursor : undefined, | ||
| enabled: true, | ||
| staleTime: 1000 * 60 * 5, | ||
| }); | ||
| }; |
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,38 @@ | ||
| import { useEffect, useRef, useState } from 'react'; | ||
|
|
||
| interface UseIntersectionObserverOptions { | ||
| root?: Element | null; | ||
| rootMargin?: string; | ||
| threshold?: number | number[]; | ||
| } | ||
|
|
||
| export const useIntersectionObserver = ( | ||
| options: UseIntersectionObserverOptions = {} | ||
| ) => { | ||
| const [isIntersecting, setIsIntersecting] = useState(false); | ||
| const targetRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| useEffect(() => { | ||
| const target = targetRef.current; | ||
| if (!target) return; | ||
|
|
||
| const observer = new IntersectionObserver( | ||
| ([entry]) => { | ||
| setIsIntersecting(entry.isIntersecting); | ||
| }, | ||
| { | ||
| root: options.root ?? null, | ||
| rootMargin: options.rootMargin ?? '0px', | ||
| threshold: options.threshold ?? 0, | ||
| } | ||
| ); | ||
|
|
||
| observer.observe(target); | ||
|
|
||
| return () => { | ||
| observer.disconnect(); | ||
| }; | ||
| }, [options.root, options.rootMargin, options.threshold]); | ||
|
|
||
| return { targetRef, isIntersecting }; | ||
| }; |
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
여기
<LoadingSpinner />로 연결하시면 될 거 같습니다.아래 더 불러오는 중... 도 마찬가지입니다!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.
463만 해결했습니다