diff options
| author | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-29 15:41:49 +0700 |
|---|---|---|
| committer | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-29 15:41:49 +0700 |
| commit | 502fac23304b29ced974ec0c8f30ae204eda88cd (patch) | |
| tree | bfe2632dbbac69e7adcd7270091d131ff4c2518b | |
| parent | 5ddbc2e832c80ff053abbedf54cd6689aa94ae1f (diff) | |
no message
| -rw-r--r-- | src/pages/shop/checkout.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/pages/shop/checkout.js b/src/pages/shop/checkout.js index 8522d27b..3eea9e74 100644 --- a/src/pages/shop/checkout.js +++ b/src/pages/shop/checkout.js @@ -1,4 +1,4 @@ -import { DocumentDuplicateIcon, ExclamationCircleIcon } from "@heroicons/react/24/solid"; +import { ExclamationCircleIcon } from "@heroicons/react/24/solid"; import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import Alert from "../../components/Alert"; @@ -30,15 +30,16 @@ export default function Checkout() { { name: 'MANDIRI', number: '155-0067-6869-75' }, ]; - const copyToClipboard = (text) => { - navigator.clipboard.writeText(text); - }; - const changePayment = (index) => { let payment = payments[index]; if (selectedPayment == payment.name) { - copyToClipboard(payment.number); - toast.success('Nomor bank berhasil disalin', { position: 'bottom-center', duration: 1500 }); + navigator.clipboard.writeText(text) + .then(() => { + toast.success('Nomor bank berhasil disalin', { position: 'bottom-center', duration: 1500 }); + }) + .catch((e) => { + toast.error(e, { position: 'bottom-center', duration: 10000 }); + }); } else { toast.success('Metode pembayaran berhasil diubah, tekan sekali lagi untuk salin nomor bank', { position: 'bottom-center', duration: 3000 }); } |
