From 120804d474b12743fb7e6fe9a5a3b024e52707d7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 8 Jul 2024 15:16:34 +0700
Subject: <iman> update button salin voucher

---
 src-migrate/modules/promo/components/Voucher.tsx | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

(limited to 'src-migrate/modules/promo/components/Voucher.tsx')

diff --git a/src-migrate/modules/promo/components/Voucher.tsx b/src-migrate/modules/promo/components/Voucher.tsx
index b5a25aa9..9e28a583 100644
--- a/src-migrate/modules/promo/components/Voucher.tsx
+++ b/src-migrate/modules/promo/components/Voucher.tsx
@@ -28,8 +28,7 @@ const Voucher = () => {
   
   const vouchers = useMemo(() => voucherQuery.data || [], [voucherQuery.data]);
 
-  const copyText = (text: string, event: React.MouseEvent<HTMLButtonElement>) => {
-    event.preventDefault();
+  const copyText = (text: string) => {
     if (navigator.clipboard && navigator.clipboard.writeText) {
       navigator.clipboard.writeText(text)
         .then(() => {
@@ -53,6 +52,17 @@ const Voucher = () => {
   const fallbackCopyTextToClipboard = (text: string) => {
     const textArea = document.createElement("textarea");
     textArea.value = text;
+    // Tambahkan style untuk menyembunyikan textArea secara visual
+    textArea.style.position = 'fixed';
+    textArea.style.top = '0';
+    textArea.style.left = '0';
+    textArea.style.width = '2em';
+    textArea.style.height = '2em';
+    textArea.style.padding = '0';
+    textArea.style.border = 'none';
+    textArea.style.outline = 'none';
+    textArea.style.boxShadow = 'none';
+    textArea.style.background = 'transparent';
     document.body.appendChild(textArea);
     textArea.focus();
     textArea.select();
@@ -101,7 +111,7 @@ const Voucher = () => {
                         <div className={style['voucher-code-desc']}>Kode Promo</div>
                         <div className={style['voucher-code']}>{voucher.code}</div>
                       </div>
-                      <button className={style['voucher-copy']} onClick={(event) => copyText(voucher.code, event)}>Salin</button>
+                      <button className={style['voucher-copy']} onClick={() => copyText(voucher.code)}>Salin</button>
                     </div>
                   </div>
                 </div>
-- 
cgit v1.2.3

