diff --git a/src/components/common/InputSearch/InputSearch.tsx b/src/components/common/InputSearch/InputSearch.tsx
index 9c02a239c..d05f7d7c6 100644
--- a/src/components/common/InputSearch/InputSearch.tsx
+++ b/src/components/common/InputSearch/InputSearch.tsx
@@ -6,11 +6,15 @@ import { Inputcommon } from '..';
interface Props {
onChange?: (value: string | number) => void,
onEnter?: (value: string | number) => void,
+ value: string | number
}
-const InputSearch = ({ onChange, onEnter }: Props) => {
+const InputSearch = ({ onChange, onEnter, value }: Props) => {
+
+
return (
}
onChange={onChange}
diff --git a/src/components/modules/home/HomeCollection/HomeCollection.tsx b/src/components/modules/home/HomeCollection/HomeCollection.tsx
index 4753f9ebe..fd1808e13 100644
--- a/src/components/modules/home/HomeCollection/HomeCollection.tsx
+++ b/src/components/modules/home/HomeCollection/HomeCollection.tsx
@@ -5,134 +5,26 @@ import image5 from '../../../../../public/assets/images/image5.png'
import image6 from '../../../../../public/assets/images/image6.png'
import image7 from '../../../../../public/assets/images/image7.png'
import image8 from '../../../../../public/assets/images/image8.png'
+import { CollectionsWithData } from 'src/utils/types.utils'
interface HomeCollectionProps {
- data: ProductCard[]
+ data: CollectionsWithData[]
}
-const dataTest = [
- {
- name: 'Tomato',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image5.src,
- },
- {
- name: 'Cucumber',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image6.src,
- },
- {
- name: 'Carrot',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image7.src,
- },
- {
- name: 'Salad',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image8.src,
- },
- {
- name: 'Tomato',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image5.src,
- },
- {
- name: 'Cucumber',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image6.src,
- },
- {
- name: 'Tomato',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image5.src,
- },
- {
- name: 'Cucumber',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image6.src,
- },
- {
- name: 'Carrot',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image7.src,
- },
- {
- name: 'Salad',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image8.src,
- },
- {
- name: 'Tomato',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image5.src,
- },
- {
- name: 'Cucumber',
- weight: '250g',
- category: 'VEGGIE',
- price: 'Rp 27.500',
- imageSrc: image6.src,
- },
-]
-const HomeCollection = ({data}: HomeCollectionProps) => {
+const HomeCollection = ({ data }: HomeCollectionProps) => {
return (
-
-
-
-
-
+ {data.map((collection) => {
+ return collection.items.length > 0 ? (
+
+ ) : null
+ })}
)
}
diff --git a/src/components/modules/product-list/ProductListFilter/ProductListFilter.tsx b/src/components/modules/product-list/ProductListFilter/ProductListFilter.tsx
index 558b9197a..672c03c87 100644
--- a/src/components/modules/product-list/ProductListFilter/ProductListFilter.tsx
+++ b/src/components/modules/product-list/ProductListFilter/ProductListFilter.tsx
@@ -66,7 +66,11 @@ const ProductListFilter = ({ facets, collections, products, total }: ProductList
const page = getPageFromQuery(router.query[QUERY_KEY.PAGE] as string)
query.input.skip = page * DEFAULT_PAGE_SIZE
-
+ const searchQuery = router.query[QUERY_KEY.SEARCH] as string
+ if (searchQuery) {
+ query.input.term = searchQuery
+ }
+
const sortQuery = router.query[QUERY_KEY.SORTBY] as string
if (sortQuery) {
query.input.sort = getProductSortParamFromQuery(sortQuery)
diff --git a/src/utils/constanst.utils.ts b/src/utils/constanst.utils.ts
index 8ad8657ed..954f77332 100644
--- a/src/utils/constanst.utils.ts
+++ b/src/utils/constanst.utils.ts
@@ -57,6 +57,7 @@ export const QUERY_KEY = {
SORTBY: 'sortby',
RECIPES: 'recipes',
PAGE: 'page',
+ SEARCH:"search"
}
export const PRODUCT_SORT_OPTION_VALUE = {
@@ -131,8 +132,11 @@ export const FACET = {
BEST_SELLERS: 'Best seller'
},
CATEGORY: {
- PARENT_NAME:"category",
- VEGGIE:"veggie"
+ PARENT_CODE:"category",
+ VEGGIE:"veggie",
+ FROZEN:"frozen",
+ SEAFOOD:"seafood",
+ COFFEE_BEAN:"coffee-bean"
}
}
diff --git a/src/utils/funtion.utils.ts b/src/utils/funtion.utils.ts
index 94521e072..b971bc8c3 100644
--- a/src/utils/funtion.utils.ts
+++ b/src/utils/funtion.utils.ts
@@ -88,6 +88,13 @@ export function getFacetIdByName(facets: Facet[], facetName: string, valueName:s
}
+export function getFacetIdByCode(facets: Facet[], parentCode: string, valueCode:string) {
+ const featuredFacet = facets.find((item: Facet) => item.code === parentCode)
+ const freshFacetValue = featuredFacet?.values.find((item: FacetValue) => item.code === valueCode)
+ return freshFacetValue?.id
+}
+
+
export function getAllFeaturedFacetId(facets: Facet[]) {
const featuredFacet = facets.find((item: Facet) => item.name === FACET.FEATURE.PARENT_NAME)
const rs = featuredFacet?.values.map((item: FacetValue) => item.id)
diff --git a/src/utils/types.utils.ts b/src/utils/types.utils.ts
index 78d813f2f..d5c0e066d 100644
--- a/src/utils/types.utils.ts
+++ b/src/utils/types.utils.ts
@@ -1,3 +1,5 @@
+import { ProductCard } from './../../framework/commerce/types/product';
+import { Collection } from './../../framework/commerce/types/collection';
export interface ProductProps {
category?: string
@@ -72,4 +74,7 @@ export type PromiseWithKey = {
keyResult?: string,
}
-export type SelectedOptions = Record
\ No newline at end of file
+export type SelectedOptions = Record
+export interface CollectionsWithData extends Collection {
+ items: ProductCard[]
+}