-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 검색 api에서 태그 검색일때의 endpoint 추가 * feat: 태그 검색 기능 구현 * feat: 검색결과 없을 때 화면 구현 * feat: 태그 검색 결과 리스트 컴포넌트 구현 * feat: Text 컴포넌트에서 외부 className을 받을 수 있게 수정 * feat: 검색 페이지에서 태그 검색 결과일 경우 분기처리 * feat: 더보기 버튼을 리스트 컴포넌트로 위치 이동 * feat: 태그 검색을 일반 검색과 분리 * feat: 상품 검색 더보기 페이지 구현 * feat: 태그 검색을 했을 때 input value 스타일 변경 * style: 사용 안하는 코드 import 제거 * feat: ProductSearchResultList 스토리북 추가 * fix: 검색이 되었을 때 resetQuery를 하도록 수정 * style: fix lint error * feat: 태그 검색 페이지 분리 * feat: 말풍선 아이콘 교체 * feat: ProductItem 디자인 수정 * feat: ProductSearchResultList -> ProductSearchResultPreviewList로 이름 변경 * feat: 버튼 스타일 변경 * feat: ProductOverviewList로 교체 * fix: 상품 상세 경로 수정 * refactor: 인자로 endpoint를 넘겨주게끔 변경
- Loading branch information
Showing
30 changed files
with
546 additions
and
119 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
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
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
34 changes: 0 additions & 34 deletions
34
src/components/Search/ProductSearchResultList/ProductSearchResultList.tsx
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
src/components/Search/ProductSearchResultList/ProductSearchResultPreviewList.stories.tsx
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,16 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import ProductSearchResultPreviewList from './ProductSearchResultPreviewList'; | ||
|
||
const meta: Meta<typeof ProductSearchResultPreviewList> = { | ||
title: 'search/ProductSearchResultPreviewList', | ||
component: ProductSearchResultPreviewList, | ||
args: { | ||
searchQuery: '꼬북칩', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; |
51 changes: 51 additions & 0 deletions
51
src/components/Search/ProductSearchResultList/ProductSearchResultPreviewList.tsx
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,51 @@ | ||
import { useRef } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import { showMoreLink } from './productSearchResultPreivewList.css'; | ||
import SearchNotFound from '../SearchNotFound/SearchNotFound'; | ||
|
||
import { Text } from '@/components/Common'; | ||
import { ProductOverviewList } from '@/components/Product'; | ||
import { PATH } from '@/constants/path'; | ||
import { useIntersectionObserver } from '@/hooks/common'; | ||
import { useInfiniteProductSearchResultsQuery } from '@/hooks/queries/search'; | ||
import displaySlice from '@/utils/displaySlice'; | ||
|
||
interface ProductSearchResultPreviewListProps { | ||
searchQuery: string; | ||
} | ||
|
||
const ProductSearchResultPreviewList = ({ searchQuery }: ProductSearchResultPreviewListProps) => { | ||
const { | ||
data: searchResponse, | ||
fetchNextPage, | ||
hasNextPage, | ||
} = useInfiniteProductSearchResultsQuery(searchQuery, 'products'); | ||
const scrollRef = useRef<HTMLDivElement>(null); | ||
useIntersectionObserver<HTMLDivElement>(fetchNextPage, scrollRef, hasNextPage); | ||
|
||
if (!searchResponse) { | ||
return null; | ||
} | ||
|
||
const products = searchResponse.pages.flatMap((page) => page.products); | ||
const productToDisplay = displaySlice(true, products); | ||
|
||
if (products.length === 0) { | ||
return <SearchNotFound />; | ||
} | ||
|
||
return ( | ||
<> | ||
<ProductOverviewList products={productToDisplay} /> | ||
<Link to={`${PATH.SEARCH}/products?query=${searchQuery}`} className={showMoreLink}> | ||
<Text size="caption1" weight="medium" color="info"> | ||
더보기 | ||
</Text> | ||
</Link> | ||
<div ref={scrollRef} aria-hidden /> | ||
</> | ||
); | ||
}; | ||
|
||
export default ProductSearchResultPreviewList; |
15 changes: 15 additions & 0 deletions
15
src/components/Search/ProductSearchResultList/productSearchResultPreivewList.css.ts
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,15 @@ | ||
import { vars } from '@/styles/theme.css'; | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const showMoreLink = style({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
width: '100%', | ||
height: 44, | ||
padding: '12px 0', | ||
margin: '20px 0', | ||
border: `1px solid ${vars.colors.border.default}`, | ||
fontSize: 14, | ||
borderRadius: 6, | ||
}); |
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
Oops, something went wrong.