-
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
92c3b11
refactor: 검색 api에서 태그 검색일때의 endpoint 추가
xodms0309 34a3314
feat: 태그 검색 기능 구현
xodms0309 95c3679
Merge remote-tracking branch 'origin/feat/v2' into feat/issue-60
xodms0309 6f9c62e
feat: 검색결과 없을 때 화면 구현
xodms0309 c5626f1
feat: 태그 검색 결과 리스트 컴포넌트 구현
xodms0309 902dda0
feat: Text 컴포넌트에서 외부 className을 받을 수 있게 수정
xodms0309 aa3bc0d
feat: 검색 페이지에서 태그 검색 결과일 경우 분기처리
xodms0309 8709619
feat: 더보기 버튼을 리스트 컴포넌트로 위치 이동
xodms0309 453b953
feat: 태그 검색을 일반 검색과 분리
xodms0309 c1f3f7d
feat: 상품 검색 더보기 페이지 구현
xodms0309 56bcc3b
feat: 태그 검색을 했을 때 input value 스타일 변경
xodms0309 d66ad0e
style: 사용 안하는 코드 import 제거
xodms0309 a3922e8
feat: ProductSearchResultList 스토리북 추가
xodms0309 e67a69a
fix: 검색이 되었을 때 resetQuery를 하도록 수정
xodms0309 f7199a5
style: fix lint error
xodms0309 fbc062e
feat: 태그 검색 페이지 분리
xodms0309 d0c4582
feat: 말풍선 아이콘 교체
xodms0309 fbdb3aa
feat: ProductItem 디자인 수정
xodms0309 185455e
Merge remote-tracking branch 'origin/feat/v2' into feat/issue-60
xodms0309 281395c
Merge remote-tracking branch 'origin/feat/v2' into feat/issue-60
xodms0309 ca2d24f
feat: ProductSearchResultList -> ProductSearchResultPreviewList로 이름 변경
xodms0309 e40319b
feat: 버튼 스타일 변경
xodms0309 5a08969
feat: ProductOverviewList로 교체
xodms0309 e423552
fix: 상품 상세 경로 수정
xodms0309 12546c7
refactor: 인자로 endpoint를 넘겨주게끔 변경
xodms0309 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,23 @@ import type { Product } from '@/types/product'; | |
|
||
interface ProductOverviewListProps { | ||
products: Product[]; | ||
isSearchPage?: boolean; | ||
} | ||
|
||
const ProductOverviewList = ({ products }: ProductOverviewListProps) => { | ||
const ProductOverviewList = ({ products, isSearchPage = false }: ProductOverviewListProps) => { | ||
return ( | ||
<ul className={container}> | ||
{products.map(({ id, image, name, price, averageRating }) => ( | ||
<li key={id}> | ||
<Link to={`${PATH.PRODUCT_LIST}/detail/${id}`}> | ||
<ProductOverviewItem image={image} name={name} price={price} rate={averageRating} /> | ||
</Link> | ||
{isSearchPage && ( | ||
<> | ||
<div style={{ height: '20px' }} /> | ||
<hr style={{ border: '0.5px solid #e6e6e6' }} /> | ||
</> | ||
)} | ||
Comment on lines
+22
to
+27
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. 짱 👍 |
||
</li> | ||
))} | ||
</ul> | ||
|
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
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 = {}; |
48 changes: 48 additions & 0 deletions
48
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,48 @@ | ||
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); | ||
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
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.
Oops, something went wrong.
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.
전 요 방법 좋아보입니다~