"use client"; import React from "react"; import Image from "next/image"; import { Sparkles } from "lucide-react"; import { cn } from "../lib/utils"; interface SafeImageProps extends Omit, 'src'> { src?: string; alt?: string; className?: string; imgClassName?: string; fallbackText?: string; } export default function SafeImage({ src, alt = "تصویر مکمل کنینا", className, imgClassName, fallbackText = "در حال بروزرسانی تصویر..." }: SafeImageProps) { const [error, setError] = React.useState(false); const [loading, setLoading] = React.useState(true); if (!src || error) { return (
{alt} {fallbackText}
); } return (
{loading && (
)} {alt} setLoading(false)} onError={() => setError(true)} />
); }