From 20e532bd68624bb078563c24ee310b3c46221923 Mon Sep 17 00:00:00 2001 From: "focp212@naver.com" Date: Thu, 23 Oct 2025 16:35:39 +0900 Subject: [PATCH] =?UTF-8?q?toast=20timer=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/transaction/billing/charge-page.tsx | 2 +- src/shared/lib/toast.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pages/transaction/billing/charge-page.tsx b/src/pages/transaction/billing/charge-page.tsx index c28c8c4..c66eec4 100644 --- a/src/pages/transaction/billing/charge-page.tsx +++ b/src/pages/transaction/billing/charge-page.tsx @@ -80,7 +80,7 @@ export const BillingChargePage = () => { billingCharge(params).then((rs) => { snackBar('결제 신청을 성공하였습니다.', function(){ navigate(PATHS.transaction.billing.list); - }); + }, 3000); }).catch((e: any) => { /* diff --git a/src/shared/lib/toast.ts b/src/shared/lib/toast.ts index 260837d..30369c8 100644 --- a/src/shared/lib/toast.ts +++ b/src/shared/lib/toast.ts @@ -1,21 +1,23 @@ import { toast } from "react-toastify"; -export const snackBar = (text: string, callback?: () => void) => { +export const snackBar = (text: string, callback?: () => void, timer?: number) => { toast.dismiss({ containerId: 'snackbar' }); toast(text, { containerId: 'snackbar' }); if(!!callback && typeof(callback) === 'function'){ + let time = timer || 3000; setTimeout(() => { callback(); - }, 3000); + }, time); } }; -export const notiBar = (text: string, callback?: () => void) => { +export const notiBar = (text: string, callback?: () => void, timer?: number) => { toast.dismiss({ containerId: 'notibar' }); toast(text, { containerId: 'notibar' }); if(!!callback && typeof(callback) === 'function'){ + let time = timer || 3000; setTimeout(() => { callback(); - }, 3000); + }, time); } }; \ No newline at end of file