/** * SweetAlert2 helper for consistent alerts across the app. * Use in client components only (e.g. "use client" pages). */ import Swal from "sweetalert2" const defaultOptions = { confirmButtonColor: "#2563eb" as const, // blue-600 cancelButtonColor: "#64748b" as const, // slate-500 customClass: { popup: "rounded-2xl shadow-xl", title: "text-slate-900 dark:text-white", htmlContainer: "text-slate-600 dark:text-slate-400", confirmButton: "rounded-lg px-5 py-2 font-medium", cancelButton: "rounded-lg px-5 py-2 font-medium", }, } export const swal = { /** Success alert (single button) */ success: (title: string, text?: string) => Swal.fire({ ...defaultOptions, icon: "success", title, text, }), /** Error alert (single button) */ error: (title: string, text?: string) => Swal.fire({ ...defaultOptions, icon: "error", title, text, }), /** Warning alert (single button) */ warning: (title: string, text?: string) => Swal.fire({ ...defaultOptions, icon: "warning", title, text, }), /** Info alert (single button) */ info: (title: string, text?: string) => Swal.fire({ ...defaultOptions, icon: "info", title, text, }), /** * Confirm dialog (Cancel + Confirm). * Returns Promise<{ isConfirmed: boolean }>. */ confirm: (options: { title: string text?: string confirmButtonText?: string cancelButtonText?: string icon?: "warning" | "question" | "info" }) => Swal.fire({ ...defaultOptions, showCancelButton: true, icon: options.icon ?? "question", title: options.title, text: options.text, confirmButtonText: options.confirmButtonText ?? "Yes", cancelButtonText: options.cancelButtonText ?? "Cancel", }), /** Fire raw options (for custom use) */ fire: (options: Parameters[0]) => Swal.fire({ ...defaultOptions, ...options }), } export default swal