-
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.
Merge remote-tracking branch 'origin/feat/v2' into feat/issue-59
- Loading branch information
Showing
29 changed files
with
542 additions
and
118 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
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
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.