import { useState } from 'react'; import Image, { ImageProps } from 'next/image'; import { Box, Skeleton } from '@mui/material'; interface OptimizedImageProps extends Omit { onLoadComplete?: () => void; } /** * OptimizedImage Component * * Wraps Next.js Image component with: * - Loading states with MUI Skeleton * - Blur placeholder support * - Loading completion events * - Automatic optimization */ export const OptimizedImage: React.FC = ({ src, alt, width, height, onLoadComplete, style, ...props }) => { const [isLoading, setIsLoading] = useState(true); const handleLoadingComplete = () => { setIsLoading(false); onLoadComplete?.(); }; // Generate a simple blur data URL for placeholder const blurDataURL = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgZmlsbD0iI2YwZjBmMCIvPjwvc3ZnPg=='; return ( {isLoading && ( )} {alt} ); };