summaryrefslogtreecommitdiff
path: root/src-migrate/modules
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-07-08 15:16:34 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-07-08 15:16:34 +0700
commit120804d474b12743fb7e6fe9a5a3b024e52707d7 (patch)
tree730ffe5ba87be01105ac4ba866efbe4b2ec71014 /src-migrate/modules
parent6a9e4aaaf73677b3b0650e93560c6738781f76c2 (diff)
<iman> update button salin voucher
Diffstat (limited to 'src-migrate/modules')
-rw-r--r--src-migrate/modules/promo/components/Voucher.tsx16
1 files changed, 13 insertions, 3 deletions
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>