The code you provided seems to be a functional component that represents a card with some information and pricing details. However, it doesn't include a dropdown menu as you requested. Here's an updated version of your code that includes a dropdown menu:
import { Constants } from "../../common";
import { useState } from "react";
import { useAppContext } from "../../Context";
import "./css.css";
export default function Card({
image,
discount,
sizes,
name,
lang,
popupImage,
ingredients,
discount_unit,
}) {
const [isOpen, setOpen] = useState(false);
const [selectedSize, setSelectedSize] = useState(sizes[0]);
const { state } = useAppContext();
const size = sizes[0];
const ingred = ingredients[0];
if (size.discount_price === "null") size.discount_price = null;
const handleSizeChange = (event) => {
setSelectedSize(event.target.value);
};
return (
<div className="item-card">
<div style={{}}>
<p
style={{
color: "black",
fontFamily: "Inter",
fontSize: "16px",
fontStyle: "normal",
fontWeight: 500,
lineHeight: "120%",
letterSpacing: "-0.32px",
}}
>
{name[lang]}
</p>
<p
style={{
color: "var(--passive)",
fontFamily: "Inter",
fontSize: "12px",
fontStyle: "normal",
fontWeight: 400,
lineHeight: "120%",
}}
>
{ingred?.name ? ingred.name[lang] : ""}
</p>
</div>
<div
style={{
gap: "50px",
paddingLeft: "16px",
display: "flex",
alignItems: "center",
borderLeft: "1px solid var(--stroke-color)",
justifyContent: "flex-end",
minWidth: "140px",
}}
>
<div>
<div
style={{
display: "flex",
justifyContent: "end",
color: "black",
fontFamily: "Inter",
fontSize: "18px",
fontStyle: "normal",
fontWeight: 500,
lineHeight: "120%",
letterSpacing: "-0.36px",
}}
>
<span>
{selectedSize.discount_price
? selectedSize.discount_price
: selectedSize.price}
{Constants.currency}
</span>
</div>
{selectedSize.discount_price && (
<div style={{ display: "flex" }}>
<span className="text p-h-semibold">
<span>
{selectedSize.price} {Constants.currency}
</span>
</span>
<div className="percentage">
<span className="text p-b-medium">
<span>
-{discount}
{discount_unit}
</span>
</span>
</div>
</div>
)}
<select value={selectedSize} onChange={handleSizeChange}>
{sizes.map((size) => (
<option key={size.id} value={size}>
{size.name}
</option>
))}
</select>
</div>
</div>
</div>
);
}
In this updated version, a dropdown menu is added right before the closing </div> tag. The value prop of the select element is set to the selectedSize state variable, and the onChange prop is set to the handleSizeChange function. The sizes.map function is used to generate the option elements dynamically based on the sizes array, and the selectedSize state variable is updated when the user selects a new option from the dropdown menu.