-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: 태그 검색 기능 구현 #64
Changes from 19 commits
92c3b11
34a3314
95c3679
6f9c62e
c5626f1
902dda0
aa3bc0d
8709619
453b953
c1f3f7d
56bcc3b
d66ad0e
a3922e8
e67a69a
f7199a5
fbc062e
d0c4582
fbdb3aa
185455e
281395c
ca2d24f
e40319b
5a08969
e423552
12546c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import ProductSearchResultList from './ProductSearchResultList'; | ||
|
||
const meta: Meta<typeof ProductSearchResultList> = { | ||
title: 'search/ProductSearchResultList', | ||
component: ProductSearchResultList, | ||
args: { | ||
searchQuery: '꼬북칩', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { useRef } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import { container } from './productSearchResultList.css'; | ||
import { container, showMoreButton } from './productSearchResultList.css'; | ||
import SearchNotFound from '../SearchNotFound/SearchNotFound'; | ||
|
||
import { ProductOverviewItem } 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 ProductSearchResultListProps { | ||
searchQuery: string; | ||
|
@@ -22,23 +24,26 @@ const ProductSearchResultList = ({ searchQuery }: ProductSearchResultListProps) | |
} | ||
|
||
const products = searchResponse.pages.flatMap((page) => page.products); | ||
const productToDisplay = displaySlice(true, products); | ||
|
||
if (products.length === 0) { | ||
return <p>검색한 상품을 찾을 수 없습니다.</p>; | ||
return <SearchNotFound />; | ||
} | ||
|
||
return ( | ||
<> | ||
<ul className={container}> | ||
{products.map(({ id, categoryType, image, name, price, averageRating }) => ( | ||
{productToDisplay.map(({ id, categoryType, image, name, price, averageRating }) => ( | ||
<li key={id}> | ||
<Link to={`${PATH.PRODUCT_LIST}/${categoryType}/${id}`}> | ||
<ProductOverviewItem image={image} name={name} price={price} rate={averageRating} /> | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
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. 이 컴포넌트의 이름을 보고 떠오른거는 전체 상품 검색한 리스트를 다 뽑아오는건가 생각이 드는데 그래서 아예 이 컴포넌트 이름을 변경했으면 좋겠어요! 밑에도 적어놨는데 이거 제 레시피 PR에 있는 ProductOverviewList 재사용하면 좋을 거 같은데, 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. 그냥 products에 productsToDisplay 넘겨주는거 어때여?! 컴포넌트 이름은 변경할게요! |
||
<div ref={scrollRef} aria-hidden /> | ||
<Link to={`${PATH.SEARCH}/products?query=${searchQuery}`} className={showMoreButton}> | ||
더보기 | ||
</Link> | ||
</> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import SearchNotFound from './SearchNotFound'; | ||
|
||
const meta: Meta<typeof SearchNotFound> = { | ||
title: 'search/SearchNotFound', | ||
component: SearchNotFound, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { container } from './searchNotFound.css'; | ||
|
||
import SearchNotFoundImage from '@/assets/search-notfound.png'; | ||
import { Text } from '@/components/Common'; | ||
|
||
|
||
const SearchNotFound = () => { | ||
return ( | ||
<> | ||
<div className={container}> | ||
<img src={SearchNotFoundImage} width={335} alt="검색 결과 없음" /> | ||
<Text color="sub" size="headline" weight="semiBold"> | ||
검색 결과가 없어요 | ||
</Text> | ||
<div style={{ height: '6px' }} /> | ||
<Text color="disabled" size="caption4"> | ||
다른 키워드로 검색해보세요! | ||
</Text> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default SearchNotFound; |
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.
전 요 방법 좋아보입니다~