'use client';

import { forwardRef } from 'react';
import { Toast } from 'primereact/toast';
import type { ToastProps } from 'primereact/toast';

/** PrimeReact Toast with portal to document.body so z-index escapes dashboard layout (sidebar is fixed z-30). */
export const AppToast = forwardRef<Toast, ToastProps>(function AppToast(props, ref) {
  const appendTo = typeof document !== 'undefined' ? document.body : null;

  return <Toast ref={ref} {...props} appendTo={appendTo} baseZIndex={13000} />;
});

AppToast.displayName = 'AppToast';
