summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/product/components/ProductCard.jsx4
-rw-r--r--src/lib/transaction/components/Transaction.jsx71
-rw-r--r--src/lib/variant/components/VariantCard.jsx72
3 files changed, 142 insertions, 5 deletions
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx
index 00edc29d..8dde4dbe 100644
--- a/src/lib/product/components/ProductCard.jsx
+++ b/src/lib/product/components/ProductCard.jsx
@@ -90,7 +90,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
/>
<div className="absolute top-0 right-0 flex mt-3">
<div className="gambarB ">
- {isSni && (
+ {!isSni && (
<ImageNext
src="/images/sni-logo.png"
alt="SNI Logo"
@@ -101,7 +101,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
)}
</div>
<div className="gambarC ">
- {isTkdn && (
+ {!isTkdn && (
<ImageNext
src="/images/TKDN.png"
alt="TKDN"
diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index b68bb4cd..fb5fd0dd 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -2,7 +2,8 @@ import Spinner from '@/core/components/elements/Spinner/Spinner';
import useTransaction from '../hooks/useTransaction';
import TransactionStatusBadge from './TransactionStatusBadge';
import Divider from '@/core/components/elements/Divider/Divider';
-import { useMemo, useRef, useState } from 'react';
+import { useEffect, useMemo, useRef, useState } from 'react';
+import ImageNext from 'next/image';
import {
downloadPurchaseOrder,
downloadQuotation,
@@ -49,6 +50,44 @@ const Transaction = ({ id }) => {
const [idAWB, setIdAWB] = useState(null);
const openUploadPo = () => setUploadPo(true);
const closeUploadPo = () => setUploadPo(false);
+ const [isSni, setIsSni] = useState(false);
+ const [isTkdn, setTkdn] = useState(false);
+
+ useEffect(() => {
+ 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);
+ }
+ };
+ 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 submitUploadPo = async () => {
const file = poFile.current.files[0];
const name = poNumber.current.value;
@@ -610,11 +649,39 @@ const Transaction = ({ id }) => {
)}
className='w-[20%] flex-shrink-0'
>
- <Image
+
+ <div className="relative">
+ <Image
src={product?.parent?.image}
alt={product?.name}
className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
/>
+ <div className="absolute top-0 right-4 flex mt-3">
+ <div className="gambarB ">
+ {!isSni && (
+ <ImageNext
+ src="/images/sni-logo.png"
+ alt="SNI Logo"
+ className="w-2 h-4 object-contain object-top sm:h-4"
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
+ <div className="gambarC ">
+ {!isTkdn && (
+ <ImageNext
+ src="/images/TKDN.png"
+ alt="TKDN"
+ className="w-5 h-4 object-contain object-top ml-1 sm:h-4"
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+
</Link>
<div className='px-2 text-left'>
<Link
diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx
index 9f1b5733..87e5d68e 100644
--- a/src/lib/variant/components/VariantCard.jsx
+++ b/src/lib/variant/components/VariantCard.jsx
@@ -7,9 +7,51 @@ import { createSlug } from '@/core/utils/slug'
import currencyFormat from '@/core/utils/currencyFormat'
import { updateItemCart } from '@/core/utils/cart'
import whatsappUrl from '@/core/utils/whatsappUrl'
+import ImageNext from 'next/image';
+import { useMemo, useEffect, useState } from 'react';
const VariantCard = ({ product, openOnClick = true, buyMore = false }) => {
const router = useRouter()
+ 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 addItemToCart = () => {
toast.success('Berhasil menambahkan ke keranjang', { duration: 1500 })
@@ -27,11 +69,39 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => {
const Card = () => (
<div className='flex gap-x-3'>
<div className='w-4/12 flex items-center gap-x-2'>
- <Image
+
+ <div className="relative">
+ <Image
src={product.parent.image}
alt={product.parent.name}
className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md'
/>
+ <div className="absolute top-0 right-4 flex mt-3">
+ <div className="gambarB ">
+ {!isSni && (
+ <ImageNext
+ src="/images/sni-logo.png"
+ alt="SNI Logo"
+ className="w-2 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-5 h-6 object-contain object-top ml-1 mr-1 sm:h-6"
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+
</div>
<div className='w-8/12 flex flex-col'>
<p className='product-card__title wrap-line-ellipsis-2'>{product.parent.name}</p>