import type { FlashMessages } from "@/lib/admin-feedback";

type AdminFlashProps = FlashMessages & {
  className?: string;
};

/**
 * Inline feedback banner for admin pages. Renders a success and/or error
 * message inside the page (replacing the removed toast system). Purely
 * presentational — no client state, no data access.
 */
export function AdminFlash({ success, error, className }: AdminFlashProps) {
  if (!success && !error) {
    return null;
  }

  return (
    <div className={className ? `space-y-2 ${className}` : "space-y-2"}>
      {success ? (
        <p
          role="status"
          aria-live="polite"
          className="rounded-nested border border-status-success/30 bg-status-success-soft px-4 py-3 text-sm font-medium text-status-success"
        >
          {success}
        </p>
      ) : null}
      {error ? (
        <p
          role="alert"
          className="rounded-nested border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm font-medium text-destructive"
        >
          {error}
        </p>
      ) : null}
    </div>
  );
}
