diff options
Diffstat (limited to 'src-migrate/modules')
| -rw-r--r-- | src-migrate/modules/popup-information/index.tsx | 11 | ||||
| -rw-r--r-- | src-migrate/modules/product-detail/components/ProductDetail.tsx | 3 | ||||
| -rw-r--r-- | src-migrate/modules/promo/components/Voucher.tsx | 1 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src-migrate/modules/popup-information/index.tsx b/src-migrate/modules/popup-information/index.tsx index d50711cc..68e0805b 100644 --- a/src-migrate/modules/popup-information/index.tsx +++ b/src-migrate/modules/popup-information/index.tsx @@ -10,12 +10,12 @@ 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<boolean>(false); const [data, setData] = useState<any>(null); const [loading, setLoading] = useState(true); - useEffect(() => { const getData = async () => { const res = await fetch(`/api/hero-banner?type=popup-banner`); @@ -26,11 +26,11 @@ const PagePopupInformation = () => { setLoading(false); }; - if (isHomePage && !auth) { + if ((isHomePage || isProductDetail) && !auth) { setActive(true); getData(); } - }, [isHomePage, auth]); + }, [isHomePage, isProductDetail, auth]); return ( <div className='group'> {data && !loading && ( @@ -44,7 +44,10 @@ const PagePopupInformation = () => { className='w-[350px] md:w-[530px]' onClick={() => setActive(false)} > - <Link href={data[0].url === false ? '/' :data[0].url} aria-label='popup'> + <Link + href={data[0].url === false ? '/' : data[0].url} + aria-label='popup' + > <Image src={data[0]?.image} alt={data[0]?.name} diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 685c107d..bd2c895f 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -23,6 +23,8 @@ 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 = { @@ -93,6 +95,7 @@ const ProductDetail = ({ product }: Props) => { <Breadcrumb id={product.id} name={product.name} /> </div> <div className='md:w-9/12 md:flex md:flex-col md:pr-4 md:pt-6'> + <PagePopupInformation /> <div className='md:flex md:flex-wrap'> <div className='md:w-4/12'> <ProductImage product={{ ...product, image: mainImage }} /> 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 = () => { |
