All files / src/components ErrorBanner.tsx

100% Statements 19/19
100% Branches 3/3
100% Functions 1/1
100% Lines 19/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27    1x 12x 12x 12x 12x       12x 12x 12x 12x 12x 12x 12x 12x 12x 10x   10x 2x 12x   12x  
import type { ReactNode } from "react";
 
export function ErrorBanner({
  message,
  onRetry,
  children,
}: {
  message: string;
  onRetry?: () => void;
  children?: ReactNode;
}) {
  return (
    <div className="banner banner--error" role="alert">
      <div>
        <strong>Не удалось загрузить данные</strong>
        <p>{message}</p>
        {children}
      </div>
      {onRetry ? (
        <button type="button" className="button" onClick={onRetry}>
          Повторить
        </button>
      ) : null}
    </div>
  );
}