From 97d079e4b64aa02a51e5ab877a73f7f23c7c6296 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 22 Jan 2024 14:51:31 +0700
Subject: Add watermark on product image

---
 src-migrate/modules/product-card/components/ProductCard.tsx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'src-migrate/modules/product-card/components/ProductCard.tsx')

diff --git a/src-migrate/modules/product-card/components/ProductCard.tsx b/src-migrate/modules/product-card/components/ProductCard.tsx
index 0a97b344..34f6d6b1 100644
--- a/src-migrate/modules/product-card/components/ProductCard.tsx
+++ b/src-migrate/modules/product-card/components/ProductCard.tsx
@@ -1,7 +1,7 @@
 import style from '../styles/product-card.module.css'
 
 import Link from 'next/link'
-import React from 'react'
+import React, { useMemo } from 'react'
 import Image from '~/components/ui/image'
 import clsxm from '~/libs/clsxm'
 import formatCurrency from '~/libs/formatCurrency'
@@ -20,6 +20,11 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => {
     manufacture: createSlug('/shop/brands/', product.manufacture.name, product.manufacture.id.toString()),
   }
 
+  const image = useMemo(() => {
+    if (product.image) return product.image + '?watermark=true'
+    return '/images/noimage.jpeg'
+  }, [product.image])
+
   return (
     <div className={clsxm(style['wrapper'], {
       [style['wrapper-v']]: layout === 'vertical',
@@ -32,7 +37,7 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => {
       })}>
         <Link href={URL.product}>
           <Image
-            src={product.image || '/images/noimage.jpeg'}
+            src={image}
             alt={product.name}
             width={128}
             height={128}
-- 
cgit v1.2.3

