From 2d30aea4e9d225298594ee92f474a38225b91206 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 28 Oct 2024 12:07:09 +0700 Subject: update informasi product varian --- .../components/Product/ProductDesktopVariant.jsx | 84 ++++++++++++++++------ .../components/Product/ProductMobileVariant.jsx | 12 +++- src/pages/api/shop/search.js | 2 +- 3 files changed, 73 insertions(+), 25 deletions(-) diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 4ecd15c8..a4cc62dd 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -4,8 +4,11 @@ import { Info } from 'lucide-react'; import { useRouter } from 'next/router'; import { useCallback, useEffect, useRef, useState } from 'react'; import { toast } from 'react-hot-toast'; +import { MessageCircleIcon, Share2Icon } from 'lucide-react'; +import AddToWishlist from '../../../../../src-migrate/modules/product-detail/components/AddToWishlist'; +import { RWebShare } from 'react-web-share'; import LazyLoad from 'react-lazy-load'; - +import { Button } from '@chakra-ui/react'; import { useProductCartContext } from '@/contexts/ProductCartContext'; import odooApi from '@/core/api/odooApi'; import Image from '@/core/components/elements/Image/Image'; @@ -18,11 +21,11 @@ import currencyFormat from '@/core/utils/currencyFormat'; import { createSlug } from '@/core/utils/slug'; import whatsappUrl from '@/core/utils/whatsappUrl'; import { getAuth } from '~/libs/auth'; - +import SimilarBottom from '~/modules/product-detail/components/SimilarBottom'; import productSimilarApi from '../../api/productSimilarApi'; import ProductCard from '../ProductCard'; import ProductSimilar from '../ProductSimilar'; - +const SELF_HOST = process.env.NEXT_PUBLIC_SELF_HOST; const ProductDesktopVariant = ({ product, wishlist, @@ -33,6 +36,7 @@ const ProductDesktopVariant = ({ let auth = useAuth(); const { slug } = router.query; const { srsltid } = router.query; + const [askAdminUrl, setAskAdminUrl, isApproval] = useState(); const [lowestPrice, setLowestPrice] = useState(null); const [addCartAlert, setAddCartAlert] = useState(false); @@ -40,6 +44,20 @@ const ProductDesktopVariant = ({ const { setRefreshCart } = useProductCartContext(); + useEffect(() => { + const createdAskUrl = whatsappUrl({ + template: 'product', + payload: { + manufacture: product.manufacture.name, + productName: product.name, + url: process.env.NEXT_PUBLIC_SELF_HOST + router.asPath, + }, + fallbackUrl: router.asPath, + }); + + setAskAdminUrl(createdAskUrl); + }, [router.asPath, product.manufacture.name, product.name, setAskAdminUrl]); + const getLowestPrice = useCallback(() => { const lowest = product.price; /* const lowest = prices.reduce((lowest, price) => { @@ -190,7 +208,7 @@ const ProductDesktopVariant = ({ /> -
+

{product?.name}

@@ -289,9 +307,40 @@ const ProductDesktopVariant = ({
+
+
+ + + + + + + +
-
+

Informasi Produk

@@ -388,24 +437,11 @@ const ProductDesktopVariant = ({ Beli
-
- -
Produk Serupa
-
+
{productSimilarInBrand && productSimilarInBrand?.map((product) => (
@@ -422,8 +458,11 @@ const ProductDesktopVariant = ({ Kamu Mungkin Juga Suka
- + + {/* + + */}
- + + {/* + + */}
diff --git a/src/lib/product/components/Product/ProductMobileVariant.jsx b/src/lib/product/components/Product/ProductMobileVariant.jsx index 4018ac15..790dbbe0 100644 --- a/src/lib/product/components/Product/ProductMobileVariant.jsx +++ b/src/lib/product/components/Product/ProductMobileVariant.jsx @@ -17,7 +17,7 @@ import { gtagAddToCart } from '@/core/utils/googleTag'; import { createSlug } from '@/core/utils/slug'; import whatsappUrl from '@/core/utils/whatsappUrl'; import { getAuth } from '~/libs/auth'; - +import SimilarBottom from '~/modules/product-detail/components/SimilarBottom'; import ProductSimilar from '../ProductSimilar'; const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { @@ -411,8 +411,11 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => {

Kamu Mungkin Juga Suka

- + + {/* + + */}
{ Kamu Mungkin Juga Suka
- + + {/* + + */} diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index bc1c014b..ace281f7 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -88,7 +88,7 @@ export default async function handler(req, res) { 'price_tier1_v2_f:[1 TO *]', ]; - if(fq){ + if (fq && source != 'similar') { filterQueries.push(fq); } const fq_ = filterQueries.join(' AND '); -- cgit v1.2.3