import React from "react"; interface CartItemProps { name: string; description: string; delivery: string; deliveryDate: string; price: string; pricePerItem: string; count: number; comment: string; selected: boolean; favorite: boolean; onSelect: () => void; onFavorite: () => void; onComment: (comment: string) => void; onCountChange?: (count: number) => void; onRemove?: () => void; isSummaryStep?: boolean; itemNumber?: number; } const CartItem: React.FC = ({ name, description, delivery, deliveryDate, price, pricePerItem, count, comment, selected, favorite, onSelect, onFavorite, onComment, onCountChange, onRemove, isSummaryStep = false, itemNumber, }) => { // --- Фикс для input: можно стереть, при blur пустое = 1 --- const [inputValue, setInputValue] = React.useState(count.toString()); React.useEffect(() => { setInputValue(count.toString()); }, [count]); return (
{isSummaryStep ? (
{itemNumber}
) : (
{selected && ( )}
)}

{name}

{description}
e.preventDefault()}> onComment(e.target.value)} disabled={isSummaryStep} />
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

{delivery}

{deliveryDate}
{isSummaryStep ? (
{count} шт.
) : ( <>
onCountChange && onCountChange(count - 1)} style={{ cursor: 'pointer' }} aria-label="Уменьшить количество" tabIndex={0} onKeyDown={e => (e.key === 'Enter' || e.key === ' ') && onCountChange && onCountChange(count - 1)} role="button" >
{ const val = e.target.value; setInputValue(val); if (val === "") { // Не обновляем count, пока не будет blur return; } const valueNum = Math.max(1, parseInt(val, 10) || 1); onCountChange && onCountChange(valueNum); }} onBlur={() => { if (inputValue === "") { setInputValue("1"); onCountChange && onCountChange(1); } }} className="text-block-26 w-full text-center outline-none" aria-label="Количество" style={{ width: 40 }} />
onCountChange && onCountChange(count + 1)} style={{ cursor: 'pointer' }} aria-label="Увеличить количество" tabIndex={0} onKeyDown={e => (e.key === 'Enter' || e.key === ' ') && onCountChange && onCountChange(count + 1)} role="button" >
)}

{price}

{pricePerItem}
{!isSummaryStep && (
(e.key === 'Enter' || e.key === ' ') && onRemove && onRemove()} style={{ display: 'inline-flex', cursor: 'pointer', transition: 'color 0.2s' }} onMouseEnter={e => { const path = e.currentTarget.querySelector('path'); if (path) path.setAttribute('fill', '#ec1c24'); }} onMouseLeave={e => { const path = e.currentTarget.querySelector('path'); if (path) path.setAttribute('fill', '#D0D0D0'); }} >
)}
); }; export default CartItem;