From 502fac23304b29ced974ec0c8f30ae204eda88cd Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 29 Dec 2022 15:41:49 +0700 Subject: no message --- src/pages/shop/checkout.js | 15 ++++++++------- 1 file 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 }); } -- cgit v1.2.3