summaryrefslogtreecommitdiff
path: root/src/lib/product
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-04-11 09:47:25 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-04-11 09:47:25 +0700
commit92c2a229d9c9b510d71b928978872a8b107e9d5a (patch)
tree8d8161a49a0bdc46d4c28d3f2682bb485314a41d /src/lib/product
parent62bebc1d33fd090d7666e18e7a0326ef7ef36897 (diff)
Documentation and refactor code
Diffstat (limited to 'src/lib/product')
-rw-r--r--src/lib/product/api/productSearchApi.js4
-rw-r--r--src/lib/product/components/Product/ProductMobile.jsx8
-rw-r--r--src/lib/product/components/ProductFilter.jsx22
-rw-r--r--src/lib/product/components/ProductSearch.jsx14
-rw-r--r--src/lib/product/components/ProductSlider.jsx10
5 files changed, 22 insertions, 36 deletions
diff --git a/src/lib/product/api/productSearchApi.js b/src/lib/product/api/productSearchApi.js
index f626e8cc..71fb72e6 100644
--- a/src/lib/product/api/productSearchApi.js
+++ b/src/lib/product/api/productSearchApi.js
@@ -2,7 +2,9 @@ import _ from 'lodash-contrib'
import axios from 'axios'
const productSearchApi = async ({ query }) => {
- const dataProductSearch = await axios(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?${query}&operation=OR`)
+ const dataProductSearch = await axios(
+ `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?${query}&operation=OR`
+ )
return dataProductSearch.data
}
diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx
index 19b4c4b2..1194419e 100644
--- a/src/lib/product/components/Product/ProductMobile.jsx
+++ b/src/lib/product/components/Product/ProductMobile.jsx
@@ -130,9 +130,11 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
</div>
<h1 className='leading-6 font-medium mb-3'>{activeVariant?.name}</h1>
- {product.variants.length > 1 && activeVariant.price.priceDiscount > 0 && !selectedVariant && (
- <div className='text-gray_r-12/80 text-caption-2 mt-2 mb-1'>Harga mulai dari: </div>
- )}
+ {product.variants.length > 1 &&
+ activeVariant.price.priceDiscount > 0 &&
+ !selectedVariant && (
+ <div className='text-gray_r-12/80 text-caption-2 mt-2 mb-1'>Harga mulai dari: </div>
+ )}
{activeVariant?.price?.discountPercentage > 0 && (
<div className='flex gap-x-1 items-center'>
diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx
index be1edd18..34357526 100644
--- a/src/lib/product/components/ProductFilter.jsx
+++ b/src/lib/product/components/ProductFilter.jsx
@@ -35,11 +35,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr
}
return (
- <BottomPopup
- active={active}
- close={close}
- title='Filter Produk'
- >
+ <BottomPopup active={active} close={close} title='Filter Produk'>
<div className='flex flex-col gap-y-4'>
{!defaultBrand && (
<div>
@@ -52,10 +48,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr
>
<option value=''>Pilih Brand...</option>
{brands.map((brand, index) => (
- <option
- value={brand}
- key={index}
- >
+ <option value={brand} key={index}>
{brand}
</option>
))}
@@ -72,10 +65,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr
>
<option value=''>Pilih Kategori...</option>
{categories.map((category, index) => (
- <option
- value={category}
- key={index}
- >
+ <option value={category} key={index}>
{category}
</option>
))}
@@ -117,11 +107,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr
/>
</div>
</div>
- <button
- type='button'
- className='btn-solid-red w-full mt-2'
- onClick={handleSubmit}
- >
+ <button type='button' className='btn-solid-red w-full mt-2' onClick={handleSubmit}>
Terapkan Filter
</button>
</div>
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx
index 0010a88a..81e7948b 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -26,13 +26,15 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
)
const productStart = productSearch.data?.responseHeader.params.start
const productRows = productSearch.data?.responseHeader.params.rows
- const productFound = productSearch.data?.response.numFound
-
- const brands = productSearch.data?.facetCounts?.facetFields?.manufactureName?.filter((value, index) => {
- if (index % 2 === 0) {
- return true
+ const productFound = productSearch.data?.response.numFound
+
+ const brands = productSearch.data?.facetCounts?.facetFields?.manufactureName?.filter(
+ (value, index) => {
+ if (index % 2 === 0) {
+ return true
+ }
}
- })
+ )
const categories = productSearch.data?.facetCounts?.facetFields?.categoryName?.filter(
(value, index) => {
if (index % 2 === 0) {
diff --git a/src/lib/product/components/ProductSlider.jsx b/src/lib/product/components/ProductSlider.jsx
index ed7db486..c8bd3a82 100644
--- a/src/lib/product/components/ProductSlider.jsx
+++ b/src/lib/product/components/ProductSlider.jsx
@@ -44,18 +44,12 @@ const ProductSlider = ({ products, simpleTitle = false, bannerMode = false }) =>
>
{bannerMode && (
<SwiperSlide>
- <Link
- href={products.banner.url}
- className='w-full h-full block'
- ></Link>
+ <Link href={products.banner.url} className='w-full h-full block'></Link>
</SwiperSlide>
)}
{products?.products?.map((product, index) => (
<SwiperSlide key={index}>
- <ProductCard
- product={product}
- simpleTitle={simpleTitle}
- />
+ <ProductCard product={product} simpleTitle={simpleTitle} />
</SwiperSlide>
))}
</Swiper>