feat: Add prop-types dependency, implement currency context, and enhance pricing display in components
- Added `prop-types` for better prop validation in components. - Introduced `CurrencyProvider` to manage currency context and preload exchange rates. - Updated pricing logic in various components to support new price structure and display currency. - Refactored BOMSummary, MotorStep, and PowerSupplyStep to utilize new pricing methods and improve user experience. - Enhanced export utilities to format prices correctly in markdown and Excel outputs. - Updated hardware and component data structures to include detailed pricing information.
This commit is contained in:
40
website/src/components/ui/ImageWithFallback.jsx
Normal file
40
website/src/components/ui/ImageWithFallback.jsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
/**
|
||||
* Image component with error handling fallback
|
||||
*/
|
||||
export default function ImageWithFallback({
|
||||
src,
|
||||
alt,
|
||||
className = '',
|
||||
containerClassName = '',
|
||||
onError
|
||||
}) {
|
||||
const handleError = (e) => {
|
||||
e.target.style.display = 'none';
|
||||
if (onError) {
|
||||
onError(e);
|
||||
}
|
||||
};
|
||||
|
||||
if (!src) return null;
|
||||
|
||||
return (
|
||||
<div className={containerClassName}>
|
||||
<img
|
||||
src={src}
|
||||
alt={alt}
|
||||
className={className}
|
||||
onError={handleError}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
ImageWithFallback.propTypes = {
|
||||
src: PropTypes.string,
|
||||
alt: PropTypes.string.isRequired,
|
||||
className: PropTypes.string,
|
||||
containerClassName: PropTypes.string,
|
||||
onError: PropTypes.func,
|
||||
};
|
||||
Reference in New Issue
Block a user