"use client";

import { Alert } from "@heroui/react";

/**
 * Error state when product or category query fails.
 * Optional message and retry handler; uses Hero UI Alert.
 */
export function ShopErrorState({
  message = "Something went wrong. Please try again.",
  onRetry,
}: {
  message?: string;
  onRetry?: () => void;
}) {
  return (
    <Alert status="danger" className="w-full">
      <Alert.Indicator />
      <Alert.Content>
        <Alert.Title>Error</Alert.Title>
        <Alert.Description>{message}</Alert.Description>
        {onRetry && (
          <button
            type="button"
            onClick={onRetry}
            className="mt-2 font-medium underline focus:outline-none focus:ring-2 focus:ring-offset-2 rounded"
          >
            Try again
          </button>
        )}
      </Alert.Content>
    </Alert>
  );
}
