summaryrefslogtreecommitdiff
path: root/src-migrate/modules/product-detail/components
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-06-05 15:24:42 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-06-05 15:24:42 +0700
commitf9f1fdf83c2b6ed5c1d85d7418d45aeed9b05c77 (patch)
tree40085a6767582a40f8a38d7c4fef6372a6a0da16 /src-migrate/modules/product-detail/components
parent87432c8627896711167813654dce2969ce45e643 (diff)
<iman> add feature SNI-TKDR
Diffstat (limited to 'src-migrate/modules/product-detail/components')
-rw-r--r--src-migrate/modules/product-detail/components/Image.tsx89
1 files changed, 79 insertions, 10 deletions
diff --git a/src-migrate/modules/product-detail/components/Image.tsx b/src-migrate/modules/product-detail/components/Image.tsx
index 3d7777f8..1b80efa8 100644
--- a/src-migrate/modules/product-detail/components/Image.tsx
+++ b/src-migrate/modules/product-detail/components/Image.tsx
@@ -1,5 +1,5 @@
import style from '../styles/image.module.css';
-
+import ImageNext from 'next/image';
import React, { useEffect, useMemo, useState } from 'react'
import { InfoIcon } from 'lucide-react'
import { Tooltip } from '@chakra-ui/react'
@@ -17,6 +17,47 @@ const Image = ({ product }: Props) => {
const [count, setCount] = useState(flashSale?.remaining_time || 0);
+ 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 () => {
+ };
+ }, []);
+
useEffect(() => {
let interval: NodeJS.Timeout;
@@ -42,15 +83,43 @@ const Image = ({ product }: Props) => {
return (
<div className={style['wrapper']}>
- <ImageUI
- src={image}
- alt={product.name}
- width={256}
- height={256}
- className={style['image']}
- loading='eager'
- priority
- />
+ {/* <div className="relative"> */}
+ <ImageUI
+ src={image}
+ alt={product.name}
+ width={256}
+ height={256}
+ className={style['image']}
+ loading='eager'
+ priority
+ />
+ <div className="absolute top-4 right-10 flex ">
+ <div className="gambarB ">
+ {!isSni && (
+ <ImageNext
+ src="/images/sni-logo.png"
+ alt="SNI Logo"
+ className="w-12 h-8 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-16 h-8 object-contain object-top ml-1 mr-1 sm:h-6"
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
+ </div>
+ {/* </div> */}
+
+
<div className={style['absolute-info']}>
<Tooltip