import React from 'react';

interface ErrorActionButtonsProps {
  onRetry?: () => void;
  onHomeClick: () => void;
  showRetry?: boolean;
  homeLabel?: string;
}

/**
 * ErrorActionButtons
 *
 * Action buttons for error pages (Try Again, Go Home)
 * Provides consistent styling and behavior.
 * All navigation callbacks must be provided by the caller.
 */
export function ErrorActionButtons({
  onRetry,
  onHomeClick,
  showRetry = false,
  homeLabel = 'Drive home',
}: ErrorActionButtonsProps) {
  if (showRetry && onRetry) {
    return (
      <div className="flex items-center justify-center gap-3 pt-2">
        <button
          type="button"
          onClick={onRetry}
          className="inline-flex items-center justify-center rounded-md bg-primary-blue px-4 py-2 text-sm font-medium text-white hover:bg-primary-blue/80 transition-colors"
        >
          Try again
        </button>
        <button
          type="button"
          onClick={onHomeClick}
          className="inline-flex items-center justify-center rounded-md bg-iron-gray px-4 py-2 text-sm font-medium text-white hover:bg-iron-gray/80 transition-colors"
        >
          Go home
        </button>
      </div>
    );
  }

  return (
    <div className="pt-2">
      <button
        type="button"
        onClick={onHomeClick}
        className="inline-flex items-center justify-center rounded-md bg-primary-blue px-4 py-2 text-sm font-medium text-white hover:bg-primary-blue/80 transition-colors"
      >
        {homeLabel}
      </button>
    </div>
  );
}