From d402970949b78b0091a8ae49f9f2018da1991170 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Tue, 29 Apr 2025 10:00:08 +0700 Subject: bug fix flash sale --- src/lib/flashSale/api/flashSaleApi.js | 5 +++-- src/lib/flashSale/components/FlashSaleNonDisplay.jsx | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/flashSale/api/flashSaleApi.js b/src/lib/flashSale/api/flashSaleApi.js index 115b07dc..410b720c 100644 --- a/src/lib/flashSale/api/flashSaleApi.js +++ b/src/lib/flashSale/api/flashSaleApi.js @@ -1,8 +1,9 @@ import odooApi from '@/core/api/odooApi' -const flashSaleApi = async () => { - const flashSale = await odooApi('GET', '/api/v1/flashsale/header') +const flashSaleApi = async ({isShow = true}) => { + const flashSale = await odooApi('GET', '/api/v1/flashsale/header?is_show_program='+isShow) return flashSale } export default flashSaleApi + \ No newline at end of file diff --git a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx index 4b420fac..dc2b9fb5 100644 --- a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx +++ b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx @@ -13,7 +13,7 @@ const FlashSaleNonDisplay = () => { const router = useRouter(); useEffect(() => { const loadFlashSales = async () => { - const dataFlashSales = await flashSaleApi(); + const dataFlashSales = await flashSaleApi({isShow: false}); setFlashSales(dataFlashSales); setIsLoading(false); }; -- cgit v1.2.3 From f13517139cd9f69488ae44582d90990eab472aa4 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Tue, 29 Apr 2025 11:27:29 +0700 Subject: bug fixing flash sale header --- src/pages/api/flashsale-header.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/flashsale-header.js b/src/pages/api/flashsale-header.js index 578801ae..916a9cd2 100644 --- a/src/pages/api/flashsale-header.js +++ b/src/pages/api/flashsale-header.js @@ -35,7 +35,7 @@ export default async function handler(req, res) { } return res.status(200).json({ data }); } else { - const flashSale = await odooApi('GET', `/api/v1/flashsale/header`); + const flashSale = await odooApi('GET', `/api/v1/flashsale/header?is_show_program=true`); if (flashSale.length === 0) { return res.status(200).json({ data: [] }); } else { -- cgit v1.2.3 From 480e89a0d2ccd274b956b4c4fb7ff520765c6606 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 29 Apr 2025 14:53:53 +0700 Subject: fix bug flashsale --- src/lib/flashSale/components/FlashSaleNonDisplay.jsx | 10 +++++----- src/lib/product/components/ProductSearch.jsx | 7 ++----- src/pages/api/shop/search.js | 1 + 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx index dc2b9fb5..adcc7ba0 100644 --- a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx +++ b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx @@ -19,8 +19,8 @@ const FlashSaleNonDisplay = () => { }; loadFlashSales(); }, []); - const handleSubmit = () => { - router.push(`/shop/search?penawaran=${flashSales[0]?.pricelistId}`); + const handleSubmit = (flashSale) => { + router.push(`/shop/search?penawaran=${flashSale?.pricelistId}`); }; if (isLoading) { return ; @@ -33,10 +33,10 @@ const FlashSaleNonDisplay = () => {
- Penawaran Terbatas + {flashSale.name}
handleSubmit(flashSale)} className='!text-red-500 font-semibold cursor-pointer' > Lihat Semua @@ -56,7 +56,7 @@ const FlashSaleProduct = ({ flashSaleId }) => { useEffect(() => { const loadProducts = async () => { const dataProducts = await productSearchApi({ - query: `fq=-flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=25&orderBy=flashsale-discount-desc&source=similar`, + query: `fq=flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=25&orderBy=flashsale-discount-desc&source=similar`, operation: 'AND', }); setProducts(dataProducts.response); diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index e2e1f859..eb86485d 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -84,10 +84,7 @@ const ProductSearch = ({ if (router.asPath.includes('penawaran')) { query = { ...query, - fq: [ - `-flashsale_id_i:${router.query.penawaran}`, - `flashsale_price_f:[1 TO *]`, - ], + fq:`flashsale_id_i:${router.query.penawaran} AND flashsale_price_f:[1 TO *]`, orderBy: 'flashsale-discount-desc', }; setFinalQuery(query); @@ -152,7 +149,7 @@ const ProductSearch = ({ }, [dataCategoriesProduct, dataLob]); useEffect(() => { - if (prefixUrl.includes('category') || prefixUrl.includes('lob')) { + if (prefixUrl.includes('category') || prefixUrl.includes('lob') || router.asPath.includes('penawaran')) { setQueryFinal({ ...finalQuery, q, limit, orderBy }); } else { setQueryFinal({ ...query, q, limit, orderBy }); diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 63ec7ca0..a1eecc52 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -19,6 +19,7 @@ export default async function handler(req, res) { source = '', } = req.query; + let { stock = '' } = req.query; let paramOrderBy = ''; switch (orderBy) { -- cgit v1.2.3 From 628a04a0310b846caf749d752edf248fdff32532 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 6 May 2025 08:51:52 +0700 Subject: push --- package.json | 2 + .../product-detail/components/ProductDetail.tsx | 47 +++++++++++++++++++++- src/utils/solrMapping.js | 1 + 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e7fcc1b..b0f1e3d4 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,10 @@ "react-multi-select-component": "^4.3.4", "react-query": "^3.39.3", "react-select": "^5.8.0", + "react-slick": "^0.30.3", "react-web-share": "^2.0.2", "redis": "^4.7.0", + "slick-carousel": "^1.8.1", "snakecase-keys": "^5.5.0", "swiper": "^8.4.4", "tw-merge": "^0.0.1-alpha.3", diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 4667e086..c26dafde 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -2,7 +2,7 @@ import style from '../styles/product-detail.module.css'; import Link from 'next/link'; import { useRouter } from 'next/router'; -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; import { Button } from '@chakra-ui/react'; import { MessageCircleIcon, Share2Icon } from 'lucide-react'; @@ -73,6 +73,19 @@ const ProductDetail = ({ product }: Props) => { // setSelectedVariant(product?.variants[0]) }, []); + + + // Gabungkan semua gambar produk (utama + tambahan) + const allImages = product.image_carousel ? [...product.image_carousel] : []; + + + if (product.image) { + allImages.unshift(product.image); // Tambahkan gambar utama di awal array + } + console.log(product); + + const [mainImage, setMainImage] = useState(allImages[0] || ''); + return ( <>
@@ -82,7 +95,37 @@ const ProductDetail = ({ product }: Props) => {
- + + + {/* Carousel horizontal */} + {allImages.length > 0 && ( +
+
+ {allImages.map((img, index) => ( +
setMainImage(img)} + > + {`Thumbnail { + e.target.src = '/path/to/fallback-image.jpg'; // Fallback jika gambar error + }} + /> +
+ ))} +
+
+ )} +
diff --git a/src/utils/solrMapping.js b/src/utils/solrMapping.js index ecd62be2..33f0cbaf 100644 --- a/src/utils/solrMapping.js +++ b/src/utils/solrMapping.js @@ -43,6 +43,7 @@ export const productMappingSolr = (products, pricelist) => { let productMapped = { id: product.product_id_i || '', image: product.image_s || '', + imageCarousel: product.image_carousel_ss || '', imageMobile: product.image_mobile_s || '', code: product.default_code_s || '', description: product.description_t || '', -- cgit v1.2.3 From 38666d79091b0cc95045a8d7e824e772d8b8cc12 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 6 May 2025 09:22:54 +0700 Subject: add type data image_carousel --- src-migrate/types/product.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src-migrate/types/product.ts b/src-migrate/types/product.ts index 85ea702a..14ba718f 100644 --- a/src-migrate/types/product.ts +++ b/src-migrate/types/product.ts @@ -4,6 +4,7 @@ export interface IProduct { id: number; image: string; image_mobile: string; + image_carousel: string[]; code: string; display_name: string; name: string; -- cgit v1.2.3 From 9e90f51952deee673c19f11c4498229e81ce29f2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 6 May 2025 09:31:44 +0700 Subject: fix bug --- src-migrate/modules/product-detail/components/ProductDetail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index c26dafde..685c107d 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -117,7 +117,7 @@ const ProductDetail = ({ product }: Props) => { className="w-full h-full object-cover rounded-sm" loading="lazy" onError={(e) => { - e.target.src = '/path/to/fallback-image.jpg'; // Fallback jika gambar error + (e.target as HTMLImageElement).src = '/path/to/fallback-image.jpg'; }} />
-- cgit v1.2.3 From 5c8a5df24a9758f3b3a6366d326f61c2c6a13c42 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Tue, 6 May 2025 14:43:58 +0700 Subject: bugfix addres validation on checkout --- src/lib/checkout/components/Checkout.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index c9bff3c1..1ad2782d 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -1127,7 +1127,7 @@ const Checkout = () => { )} - + { )} - + ( ); const SectionValidation = ({ address }) => - address?.stateId == 0 || address?.rajaongkirCityId == 0 && ( + (address?.stateId === 0 || address?.rajaongkirCityId === 0) && (
Mohon untuk memperbarui alamat Anda dengan mengklik tombol di bawah ini.{' '} -- cgit v1.2.3