diff --git a/web/src/toast-error.ts b/web/src/toast-error.ts index 7efd62d..51b2d3f 100644 --- a/web/src/toast-error.ts +++ b/web/src/toast-error.ts @@ -1,33 +1,31 @@ import { Alpine } from "./alpine"; +import { showToast } from "./toast"; function showErrorToast(message: string): void { - // Use the global showToast from toast.ts - if (typeof (window as any).showToast !== "undefined") { - (window as any).showToast.error(message, 8000); + showToast(message, "error", 8000); - // Add retry button to the toast - setTimeout(() => { - const toastContainer = document.getElementById("toast-container"); - if (toastContainer && toastContainer.lastElementChild) { - const toast = toastContainer.lastElementChild as HTMLElement; - const retryBtn = document.createElement("button"); - retryBtn.className = - "ml-4 px-3 py-1 bg-white/20 hover:bg-white/30 rounded text-sm font-medium transition-colors"; - retryBtn.textContent = "Retry"; - retryBtn.onclick = function () { - window.location.reload(); - }; + // Add retry button to the toast + setTimeout(() => { + const toastContainer = document.getElementById("toast-container"); + if (toastContainer && toastContainer.lastElementChild) { + const toast = toastContainer.lastElementChild as HTMLElement; + const retryBtn = document.createElement("button"); + retryBtn.className = + "ml-4 px-3 py-1 bg-white/20 hover:bg-white/30 rounded text-sm font-medium transition-colors"; + retryBtn.textContent = "Retry"; + retryBtn.onclick = function () { + window.location.reload(); + }; - // Insert before the close button - const closeBtn = toast.querySelector(".toast-close"); - if (closeBtn && closeBtn.parentElement) { - closeBtn.parentElement.insertBefore(retryBtn, closeBtn); - } else { - toast.appendChild(retryBtn); - } + // Insert before the close button + const closeBtn = toast.querySelector(".toast-close"); + if (closeBtn && closeBtn.parentElement) { + closeBtn.parentElement.insertBefore(retryBtn, closeBtn); + } else { + toast.appendChild(retryBtn); } - }, 100); - } + } + }, 100); } export { showErrorToast };