-
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.
* fix: 이전으로 버튼 라우팅 오류 수정 * feat: 실시간 검색어 랜덤 다섯개 선정 * feat: 검색 결과 공공 api 연결 * fix: 결과 렌더링 return문 빠진 오류 수정 * feat: 무한 스크롤 구현 - hook 작성 * feat: 무한 스크롤 로딩처리 * feat: 연관 검색어 로직 * refactor: SearchPage useRef 사용 및 리팩토링 * refactor: SearchResultPage 리팩토링 * feat: 연관 검색어 누르면 검색 결과 이동 * feat: 검색 결과 없음 뷰 구현 * feat: 좋아요 누름 구현 * fix: 이전으로 가기 관련 오류 수정 * feat: 연관 검색어 키워드 색 다르게 처리 * feat: 최근 검색어 setStorage 조건 추가 * feat: 공공 api 호출 IOS -> ETC * feat: placecard background linear gradient 추가 * feat: 장소 이름 말줄임표 적용 * feat: 검색 결과 없을시 인기 검색어 없애기 * feat: contentTypeId 추가 * chore: stylelint fix
- Loading branch information
Showing
24 changed files
with
704 additions
and
242 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
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,33 @@ | ||
// 검색 관련 공공 데이터 API | ||
|
||
import { Response } from '@/types/public'; | ||
import { SearchWord } from '@/types/search'; | ||
|
||
import { publicDataClient } from '..'; | ||
|
||
interface searchKeywordParams { | ||
pageNo: number; | ||
numOfRows: number; | ||
MobileOS: 'IOS' | 'AND' | 'WIN' | 'ETC'; | ||
keyword: string; | ||
contentTypeId: number; | ||
} | ||
|
||
export const getSearchKeyword = async (paramsInfo: searchKeywordParams) => { | ||
let params = `MobileApp=UNITRIP&_type=json&arrange=O&serviceKey=${import.meta.env.VITE_PUBLIC_DATA_SERVICE_KEY}`; | ||
|
||
for (const [key, value] of Object.entries(paramsInfo)) { | ||
params += `&${key}=${value}`; | ||
} | ||
|
||
const { | ||
data: { | ||
response: { | ||
body: { items }, | ||
}, | ||
}, | ||
} = await publicDataClient.get<Response<SearchWord>>( | ||
`/searchKeyword1?${params}`, | ||
); | ||
return items; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
import { useEffect } from 'react'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const useAsyncEffect = (effect: () => Promise<void>, deps: any[]) => { | ||
useEffect(() => { | ||
effect(); | ||
}, deps); | ||
}; |
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,46 @@ | ||
import { MutableRefObject, useEffect, useRef } from 'react'; | ||
|
||
interface InfiniteScrollParams { | ||
options?: { root: Element | null; rootMargin: string; threshold: number }; | ||
handleObserver: ( | ||
observer: IntersectionObserver, | ||
target: MutableRefObject<HTMLElement | null>, | ||
page: MutableRefObject<number>, | ||
) => Promise<void>; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
deps: any[]; | ||
} | ||
|
||
/** | ||
* @param options IntersectionObserver options | ||
* @param handleObserver target 감지시 실행함수 | ||
* @param deps useEffect 의존성 배열 | ||
*/ | ||
|
||
export const useInfiniteScroll = ({ | ||
options, | ||
handleObserver, | ||
deps, | ||
}: InfiniteScrollParams) => { | ||
const target = useRef<HTMLDivElement | null>(null); | ||
const page = useRef(1); | ||
|
||
useEffect(() => { | ||
page.current = 1; | ||
|
||
const observer = new IntersectionObserver((entries, observer) => { | ||
if (entries[0].intersectionRatio <= 0) return; | ||
|
||
handleObserver(observer, target, page); | ||
}, options); | ||
|
||
//주시 시작 | ||
target.current && observer.observe(target.current); | ||
|
||
return () => { | ||
target.current && observer.unobserve(target.current); | ||
}; | ||
}, deps); | ||
|
||
return target; | ||
}; |
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,3 @@ | ||
export interface Response<T> { | ||
response: T; | ||
} |
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,39 @@ | ||
export interface SearchResItem { | ||
cat2: string; | ||
cat3: string; | ||
tel: string; | ||
modifiedtime: string; | ||
sigungucode: string; | ||
contentid: string; | ||
mlevel: string; | ||
title: string; | ||
addr1: string; | ||
addr2: string; | ||
areacode: string; | ||
booktour: string; | ||
cat1: string; | ||
firstimage2: string; | ||
mapx: string; | ||
mapy: string; | ||
cpyrhtDivCd: string; | ||
contenttypeid: string; | ||
createdtime: string; | ||
firstimage: string; | ||
} | ||
|
||
export interface SearchWord { | ||
header: { | ||
resultCode: string; | ||
resultMsg: string; | ||
}; | ||
body: { | ||
numOfRows: number; | ||
pageNo: number; | ||
totalCount: number; | ||
items: | ||
| { | ||
item: SearchResItem[]; | ||
} | ||
| ''; | ||
}; | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.