import { Alert, Button } from "@tailor-platform/app-shell";

interface ErrorFallbackProps {
  title?: string;
  message?: string;
  onReset?: () => void;
}

export const ErrorFallback = ({
  title = "Something went wrong",
  message = "An error occurred while loading this content.",
  onReset,
}: ErrorFallbackProps) => {
  return (
    <Alert.Root
      variant="error"
      action={
        onReset && (
          <Button variant="outline" size="sm" onClick={onReset}>
            Try again
          </Button>
        )
      }
    >
      <Alert.Title>{title}</Alert.Title>
      <Alert.Description>{message}</Alert.Description>
    </Alert.Root>
  );
};
