Closed UO250825 closed 2 years ago
export default function ImgMediaCard({ product, handleAddToCart }: Props) { const [size, setSize] = React.useState( product.disponibility.find((s) => s.size.toString() === '')?.size, )
const [available, setAvailable] = React.useState(true)
product.disponibility.sort((n1, n2) => n1.size - n2.size)
const sizesList = product.disponibility.map((s) => (
))
const handleSizeChange = (event: SelectChangeEvent) => { setSize((event.target.value as unknown) as number) var currentSize = product.disponibility.find((s) => s.size === size)
if (currentSize === undefined) {
throw new TypeError('The value was promised to always be there!')
}
if (currentSize?.stock > 0) {
setAvailable(true)
} else {
setAvailable(false)
}
}
const [addable, setAddable] = React.useState(false)
const handleClick = () => { const addToCartProduct = { name: product.name, price: product.price, size: size as number, quantity: 0, image: product.image, _id: product._id, } handleAddToCart(addToCartProduct) setAddable(true) }
const handleClose = ( event?: React.SyntheticEvent | Event, reason?: string, ) => { if (reason === 'clickaway') { return } setAddable(false) }
const availabilityLabel = () => {
if (available) {
return
return (
) }
He estado intentando arreglar este problema, pero no consigo eliminar los warnings.
https://github.com/mui/material-ui/issues/18494
Example