Files
web/packages/design-system/lib/components/Image/index.tsx
Christel Westerberg 6b08d5a113 Merged in fix/STAY-135 (pull request #3368)
Fix/STAY-135 & STAY-127

* fix: make quantity and delivery separate steps in mobile

* fix: update design for delivery step in ancillary flow

* fix: add error state for missing time

* fix: only allow points or cash payment for ancillaries

* fix: break out stepper to design system

* fix: update design of select quantity step in add ancillaries flow

* fix: add error states for quantity

* fix: handle insufficient points case

* fix: update stepper to include optional disabledMessage tooltip

* fix: handle validations

* fix: change name to camel case


Approved-by: Bianca Widstam
Approved-by: Chuma Mcphoy (We Ahead)
2025-12-18 13:31:43 +00:00

61 lines
1.3 KiB
TypeScript

'use client'
import NextImage, { ImageProps as NextImageProps } from 'next/image'
import ImageFallback from '../ImageFallback'
import { useState, type CSSProperties, type SyntheticEvent } from 'react'
import { imageLoader } from './imageLoader'
type FocalPoint = {
x: number
y: number
}
export type ImageProps = Omit<NextImageProps, 'src'> & {
focalPoint?: FocalPoint
dimensions?: { width: number; height: number }
src: NextImageProps['src'] | undefined
}
// Next/Image adds & instead of ? before the params
export default function Image({
focalPoint,
dimensions,
style,
src,
onError,
...props
}: ImageProps) {
const [imageError, setImageError] = useState(false)
const styles: CSSProperties = focalPoint
? {
objectFit: 'cover',
objectPosition: `${focalPoint.x}% ${focalPoint.y}%`,
...style,
}
: { ...style }
function handleError(error: SyntheticEvent<HTMLImageElement, Event>) {
if (onError) {
onError(error)
} else {
setImageError(true)
}
}
if (!src || imageError) {
return <ImageFallback />
}
return (
<NextImage
{...props}
src={src}
style={styles}
onError={handleError}
loader={imageLoader({ dimensions, focalPoint })}
/>
)
}