From 81abbbabd11df17b5fe795e725f5841273fbf125 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 24 Apr 2025 14:31:48 +0700 Subject: Make Popup Banner show in product detail for non auth user --- src-migrate/modules/popup-information/index.tsx | 34 +++++++++++++++++----- .../product-detail/components/ProductDetail.tsx | 3 ++ 2 files changed, 29 insertions(+), 8 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/popup-information/index.tsx b/src-migrate/modules/popup-information/index.tsx index d50711cc..5c3bc8fa 100644 --- a/src-migrate/modules/popup-information/index.tsx +++ b/src-migrate/modules/popup-information/index.tsx @@ -10,11 +10,21 @@ import dynamic from 'next/dynamic'; const PagePopupInformation = () => { const router = useRouter(); const isHomePage = router.pathname === '/'; + // Updated to match your URL structure with /shop/product/ + const isProductDetail = router.pathname.includes('/shop/product/'); const auth = getAuth(); const [active, setActive] = useState(false); const [data, setData] = useState(null); const [loading, setLoading] = useState(true); + const [hasClosedPopup, setHasClosedPopup] = useState(false); + useEffect(() => { + // Check if user has closed the popup in this session + const popupClosed = sessionStorage.getItem('popupClosed'); + if (popupClosed) { + setHasClosedPopup(true); + } + }, []); useEffect(() => { const getData = async () => { @@ -26,25 +36,33 @@ const PagePopupInformation = () => { setLoading(false); }; - if (isHomePage && !auth) { + // Show popup if user is on homepage OR product detail page AND not authenticated AND hasn't closed popup + if ((isHomePage || isProductDetail) && !auth && !hasClosedPopup) { setActive(true); getData(); } - }, [isHomePage, auth]); + }, [isHomePage, isProductDetail, auth, hasClosedPopup]); + + const handleClose = () => { + setActive(false); + // Set session storage to remember user closed the popup + sessionStorage.setItem('popupClosed', 'true'); + }; + return (
{data && !loading && ( setActive(false)} + close={handleClose} mode='desktop' > -
setActive(false)} - > - +
+ {data[0]?.name} {
+
-- cgit v1.2.3 From d9dd7fd69d2f895f8e503f8d6becd4be3af18b15 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 24 Apr 2025 15:16:10 +0700 Subject: Remove session storage --- src-migrate/modules/popup-information/index.tsx | 29 ++++++------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/popup-information/index.tsx b/src-migrate/modules/popup-information/index.tsx index 5c3bc8fa..68e0805b 100644 --- a/src-migrate/modules/popup-information/index.tsx +++ b/src-migrate/modules/popup-information/index.tsx @@ -10,21 +10,11 @@ import dynamic from 'next/dynamic'; const PagePopupInformation = () => { const router = useRouter(); const isHomePage = router.pathname === '/'; - // Updated to match your URL structure with /shop/product/ const isProductDetail = router.pathname.includes('/shop/product/'); const auth = getAuth(); const [active, setActive] = useState(false); const [data, setData] = useState(null); const [loading, setLoading] = useState(true); - const [hasClosedPopup, setHasClosedPopup] = useState(false); - - useEffect(() => { - // Check if user has closed the popup in this session - const popupClosed = sessionStorage.getItem('popupClosed'); - if (popupClosed) { - setHasClosedPopup(true); - } - }, []); useEffect(() => { const getData = async () => { @@ -36,29 +26,24 @@ const PagePopupInformation = () => { setLoading(false); }; - // Show popup if user is on homepage OR product detail page AND not authenticated AND hasn't closed popup - if ((isHomePage || isProductDetail) && !auth && !hasClosedPopup) { + if ((isHomePage || isProductDetail) && !auth) { setActive(true); getData(); } - }, [isHomePage, isProductDetail, auth, hasClosedPopup]); - - const handleClose = () => { - setActive(false); - // Set session storage to remember user closed the popup - sessionStorage.setItem('popupClosed', 'true'); - }; - + }, [isHomePage, isProductDetail, auth]); return (
{data && !loading && ( setActive(false)} mode='desktop' > -
+
setActive(false)} + > Date: Wed, 7 May 2025 09:20:55 +0700 Subject: voucher category --- src-migrate/modules/promo/components/Voucher.tsx | 1 + src-migrate/types/voucher.ts | 1 + 2 files changed, 2 insertions(+) (limited to 'src-migrate') diff --git a/src-migrate/modules/promo/components/Voucher.tsx b/src-migrate/modules/promo/components/Voucher.tsx index 034d13e9..0c225c74 100644 --- a/src-migrate/modules/promo/components/Voucher.tsx +++ b/src-migrate/modules/promo/components/Voucher.tsx @@ -18,6 +18,7 @@ interface Voucher { name: string; description: string; code: string; + voucher_category: []; } const VoucherComponent = () => { diff --git a/src-migrate/types/voucher.ts b/src-migrate/types/voucher.ts index 3e90f449..d3140372 100644 --- a/src-migrate/types/voucher.ts +++ b/src-migrate/types/voucher.ts @@ -3,6 +3,7 @@ export interface IVoucher { image: string; name: string; code: string; + voucher_category: []; description: string | false; remaining_time: string; } -- cgit v1.2.3 From 4ca48d5b2b8da512447d04bb7e6540ea2b76294b Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 7 May 2025 09:53:12 +0700 Subject: merge --- src-migrate/modules/popup-information/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/popup-information/index.tsx b/src-migrate/modules/popup-information/index.tsx index 68e0805b..cae50abf 100644 --- a/src-migrate/modules/popup-information/index.tsx +++ b/src-migrate/modules/popup-information/index.tsx @@ -10,7 +10,6 @@ import dynamic from 'next/dynamic'; const PagePopupInformation = () => { const router = useRouter(); const isHomePage = router.pathname === '/'; - const isProductDetail = router.pathname.includes('/shop/product/'); const auth = getAuth(); const [active, setActive] = useState(false); const [data, setData] = useState(null); @@ -26,11 +25,11 @@ const PagePopupInformation = () => { setLoading(false); }; - if ((isHomePage || isProductDetail) && !auth) { + if (isHomePage && !auth) { setActive(true); getData(); } - }, [isHomePage, isProductDetail, auth]); + }, [isHomePage, auth]); return (
{data && !loading && ( -- cgit v1.2.3 From 29db3ca16589f1c6bad42545b56b1cb3a6039f4c Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 7 May 2025 11:47:08 +0700 Subject: remove unused function --- src-migrate/types/product.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src-migrate') diff --git a/src-migrate/types/product.ts b/src-migrate/types/product.ts index 14ba718f..e2121dab 100644 --- a/src-migrate/types/product.ts +++ b/src-migrate/types/product.ts @@ -35,7 +35,21 @@ export interface IProduct { name: string; logo: string; }; - voucher_pasti_hemat : any; + voucher_pasti_hemat: any; + available_voucher?: IVoucher[]; +} + +export interface IVoucher { + id: number; + name: string; + code: string; + description: string; + image: string; + canApply: boolean; + discountVoucher: number; + termsConditions: string; + remaining_time: string; + apply_type: 'all' | 'shipping' | 'brand'; } export interface IProductDetail extends IProduct { -- cgit v1.2.3 From 11ea9426239b88181e5074a8e7246f8955346180 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 7 May 2025 11:51:15 +0700 Subject: Remove unused code --- src-migrate/types/product.ts | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/types/product.ts b/src-migrate/types/product.ts index e2121dab..746cdd4a 100644 --- a/src-migrate/types/product.ts +++ b/src-migrate/types/product.ts @@ -36,20 +36,6 @@ export interface IProduct { logo: string; }; voucher_pasti_hemat: any; - available_voucher?: IVoucher[]; -} - -export interface IVoucher { - id: number; - name: string; - code: string; - description: string; - image: string; - canApply: boolean; - discountVoucher: number; - termsConditions: string; - remaining_time: string; - apply_type: 'all' | 'shipping' | 'brand'; } export interface IProductDetail extends IProduct { -- cgit v1.2.3 From 89a0e7f37d7537c2d0d3715817453279443d518b Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 7 May 2025 15:06:32 +0700 Subject: Fix conflict --- .../product-detail/components/ProductDetail.tsx | 30 +++++++++------------- 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index bd2c895f..0660b9c0 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -23,8 +23,6 @@ import PriceAction from './PriceAction'; import SimilarBottom from './SimilarBottom'; import SimilarSide from './SimilarSide'; -import PagePopupInformation from '~/modules/popup-information'; - import { gtagProductDetail } from '@/core/utils/googleTag'; type Props = { @@ -75,12 +73,9 @@ 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 } @@ -95,21 +90,20 @@ const ProductDetail = ({ product }: Props) => {
-
- - + + {/* Carousel horizontal */} {allImages.length > 0 && ( -
-
+
+
{allImages.map((img, index) => ( -
setMainImage(img)} @@ -117,10 +111,11 @@ const ProductDetail = ({ product }: Props) => { {`Thumbnail { - (e.target as HTMLImageElement).src = '/path/to/fallback-image.jpg'; + (e.target as HTMLImageElement).src = + '/path/to/fallback-image.jpg'; }} />
@@ -128,7 +123,6 @@ const ProductDetail = ({ product }: Props) => {
)} -
-- cgit v1.2.3