"use client";

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

/**
 * Error state for cart using HeroUI Alert.
 * Shown when cart query or mutations fail.
 */
export function CartErrorState({
  message = "Something went wrong loading your cart.",
  onRetry,
}: {
  message?: string;
  onRetry?: () => void;
}) {
  return (
    <Alert status="danger" className="w-full">
      <Alert.Indicator />
      <Alert.Content>
        <Alert.Title>Cart error</Alert.Title>
        <Alert.Description>{message}</Alert.Description>
        {onRetry && (
          <Button
            size="sm"
            variant="danger"
            className="mt-2"
            onPress={onRetry}
          >
            Try again
          </Button>
        )}
      </Alert.Content>
    </Alert>
  );
}
