summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-06-05 16:50:38 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-06-05 16:50:38 +0700
commit755b61a8a7a082cc13f7ecb4a79807f90e60b3d6 (patch)
tree9ca4fc8b49c9784c433c2fdc54f59934f2239b3b /src/lib
parentf9f1fdf83c2b6ed5c1d85d7418d45aeed9b05c77 (diff)
<iman> add feature SNI-TKDN
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/product/components/ProductCard.jsx103
-rw-r--r--src/lib/transaction/components/Transaction.jsx4
-rw-r--r--src/lib/variant/components/VariantCard.jsx4
3 files changed, 36 insertions, 75 deletions
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx
index 8dde4dbe..48a30b51 100644
--- a/src/lib/product/components/ProductCard.jsx
+++ b/src/lib/product/components/ProductCard.jsx
@@ -1,7 +1,7 @@
import clsx from 'clsx';
import ImageNext from 'next/image';
import { useRouter } from 'next/router';
-import { useMemo, useEffect, useState } from 'react';
+import { useMemo} from 'react';
import Image from '@/core/components/elements/Image/Image';
import Link from '@/core/components/elements/Link/Link';
@@ -15,46 +15,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
const router = useRouter();
const utmSource = useUtmSource();
- const [isSni, setIsSni] = useState(false);
- const [isTkdn, setTkdn] = useState(false);
-
- useEffect(() => {
- // Lakukan pemanggilan API untuk memeriksa isSni
- const fetchSniData = async () => {
- try {
- const response = await fetch('URL_API_SNI');
- const data = await response.json();
- if (data && data.sni) {
- setIsSni(true);
- } else {
- setIsSni(false);
- }
- } catch (error) {
- console.error('Error fetching SNI data:', error);
- setIsSni(false);
- }
- };
-
- // Lakukan pemanggilan API untuk memeriksa isTkdn
- const fetchTkdnData = async () => {
- try {
- const response = await fetch('URL_API_TKDN');
- const data = await response.json();
- if (data && data.tkdn) {
- setTkdn(true);
- } else {
- setTkdn(false);
- }
- } catch (error) {
- console.error('Error fetching TKDN data:', error);
- setTkdn(false);
- }
- };
- fetchSniData();
- fetchTkdnData();
- return () => {
- };
- }, []);
+
const callForPriceWhatsapp = whatsappUrl('product', {
name: product.name,
@@ -90,7 +51,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
/>
<div className="absolute top-0 right-0 flex mt-3">
<div className="gambarB ">
- {!isSni && (
+ {product.isSni && (
<ImageNext
src="/images/sni-logo.png"
alt="SNI Logo"
@@ -101,7 +62,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
)}
</div>
<div className="gambarC ">
- {!isTkdn && (
+ {product.isTkdn && (
<ImageNext
src="/images/TKDN.png"
alt="TKDN"
@@ -241,35 +202,35 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
<div className='w-4/12'>
<Link href={URL.product} className='relative'>
<div className="relative">
- <Image
- src={image}
- alt={product?.name}
- className="gambarA w-full object-contain object-center h-36 sm:h-48"
- />
- <div className="absolute top-0 right-0 flex mt-3">
- <div className="gambarB ">
- {!isSni && (
- <ImageNext
- src="/images/sni-logo.png"
- alt="SNI Logo"
- className="w-4 h-5 object-contain object-top sm:h-6"
- width={50}
- height={50}
- />
- )}
- </div>
- <div className="gambarC ">
- {!isTkdn && (
- <ImageNext
- src="/images/TKDN.png"
- alt="TKDN"
- className="w-11 h-6 object-contain object-top ml-1 sm:h-6"
- width={50}
- height={50}
- />
- )}
+ <Image
+ src={image}
+ alt={product?.name}
+ className="gambarA w-full object-contain object-center h-36 sm:h-48"
+ />
+ <div className="absolute top-0 right-0 flex mt-3">
+ <div className="gambarB ">
+ {product.isSni && (
+ <ImageNext
+ src="/images/sni-logo.png"
+ alt="SNI Logo"
+ className="w-4 h-5 object-contain object-top sm:h-6"
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
+ <div className="gambarC ">
+ {product.isTkdn && (
+ <ImageNext
+ src="/images/TKDN.png"
+ alt="TKDN"
+ className="w-11 h-6 object-contain object-top ml-1 sm:h-6"
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
</div>
- </div>
</div>
{product.variantTotal > 1 && (
<div className='absolute badge-gray bottom-1.5 left-1.5'>
diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index fb5fd0dd..f3e2afb9 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -658,7 +658,7 @@ const Transaction = ({ id }) => {
/>
<div className="absolute top-0 right-4 flex mt-3">
<div className="gambarB ">
- {!isSni && (
+ {product.isSni && (
<ImageNext
src="/images/sni-logo.png"
alt="SNI Logo"
@@ -669,7 +669,7 @@ const Transaction = ({ id }) => {
)}
</div>
<div className="gambarC ">
- {!isTkdn && (
+ {product.isTkdn && (
<ImageNext
src="/images/TKDN.png"
alt="TKDN"
diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx
index 87e5d68e..f5ae4478 100644
--- a/src/lib/variant/components/VariantCard.jsx
+++ b/src/lib/variant/components/VariantCard.jsx
@@ -78,7 +78,7 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => {
/>
<div className="absolute top-0 right-4 flex mt-3">
<div className="gambarB ">
- {!isSni && (
+ {product.isSni && (
<ImageNext
src="/images/sni-logo.png"
alt="SNI Logo"
@@ -89,7 +89,7 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => {
)}
</div>
<div className="gambarC ">
- {!isTkdn && (
+ {product.isTkdn && (
<ImageNext
src="/images/TKDN.png"
alt="TKDN"