Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

1.1 KB
Raw Blame
import type { ToastType } from '@/components/Toast/Toast';
import { logger } from '@/utils/logger';

// Global declaration is in Toast.tsx

export const showToast = (
  type: ToastType,
  title: string,
  message?: string,
  duration?: number,
  detail?: string,
): string | undefined => {
  if (typeof window !== 'undefined' && window.showToast) {
    return window.showToast(type, title, message, duration, detail);
  }

  // Fallback to console if toast system not ready
  logger.info(`[toast:${type}] ${title}${message ? `: ${message}` : ''}`);
  return undefined;
};

// Convenience functions - only export what's used
export const showSuccess = (title: string, message?: string, duration?: number) =>
  showToast('success', title, message, duration);
export const showError = (title: string, message?: string, duration?: number) =>
  showToast('error', title, message, duration);
export const showErrorWithDetail = (title: string, detail?: string, duration?: number) =>
  showToast('error', title, undefined, duration, detail);
export const showWarning = (title: string, message?: string, duration?: number) =>
  showToast('warning', title, message, duration);