-
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.
Showing
8 changed files
with
38 additions
and
41 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
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 was deleted.
Oops, something went wrong.
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
35 changes: 22 additions & 13 deletions
35
src/components/features/StorePage/ProductList/ProductFilter/index.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 |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import { Divider, Flex, Text } from "@chakra-ui/react"; | ||
import { useGetProductCategories } from "@api/categoryApi"; | ||
import ProductGroupView from "@components/features/StorePage/ProductList/ProductFilter/ProductGroupView"; | ||
import { ProductFilterItem } from "@components/features/StorePage/ProductList/ProductFilter/type"; | ||
import productGroup from "@constants/productGroup"; | ||
import useFilters, { UseFilters } from "@hooks/useFilters"; | ||
import { encodeCategory } from "@utils/categoryParser"; | ||
|
||
type ProductFilterProps = { | ||
items?: ProductFilterItem[]; | ||
filterState?: UseFilters; | ||
}; | ||
|
||
const ProductFilter = ({ items = [], filterState = useFilters() }: ProductFilterProps) => ( | ||
<Flex direction="column" w="250px" h="100%" pt="10"> | ||
<Text w="full" py="5" fontSize="xl" fontWeight="bold"> | ||
필터 | ||
</Text> | ||
<Divider /> | ||
{productGroup.map(group => ( | ||
<ProductGroupView key={group.group} group={group} items={items} filterState={filterState} /> | ||
))} | ||
</Flex> | ||
); | ||
const ProductFilter = ({ filterState = useFilters() }: ProductFilterProps) => { | ||
const { data: productCategories } = useGetProductCategories(); | ||
|
||
return ( | ||
<Flex direction="column" w="250px" h="100%" pt="10"> | ||
<Text w="full" py="5" fontSize="xl" fontWeight="bold"> | ||
필터 | ||
</Text> | ||
<Divider /> | ||
{productGroup.map(group => ( | ||
<ProductGroupView | ||
key={group.group} | ||
group={group} | ||
items={(productCategories || []).map(encodeCategory)} | ||
filterState={filterState} | ||
/> | ||
))} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default ProductFilter; |
6 changes: 3 additions & 3 deletions
6
src/components/features/StorePage/ProductList/ProductsView.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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { useGetProducts } from "@api/productApi"; | ||
import GridView, { GridViewProps } from "@components/ItemView/GridView"; | ||
import ProductCard from "@components/features/StorePage/ProductCard"; | ||
import mockProducts from "@mocks/mockItem/mockProducts"; | ||
import { Product } from "@type/index"; | ||
|
||
type ProductsViewProps = { | ||
filters: string[]; | ||
} & Omit<GridViewProps<Product>, "items" | "ItemComponent">; | ||
|
||
const ProductsView = ({ filters, ...props }: ProductsViewProps) => { | ||
const filteredProducts = mockProducts.filter(() => filters.length === 0); | ||
const { data: products } = useGetProducts(filters[0] ? Number(filters[0]) : 0); | ||
|
||
return <GridView items={filteredProducts} ItemComponent={ProductCard} {...props} />; | ||
return <GridView items={products || []} ItemComponent={ProductCard} {...props} />; | ||
}; | ||
|
||
export default ProductsView; |
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