import React from "react"; import { useCart } from "@/contexts/CartContext"; const CartList2: React.FC = () => { const { state, updateComment } = useCart(); const { items } = state; const handleComment = (id: string, comment: string) => { updateComment(id, comment); }; // Функция для форматирования цены const formatPrice = (price: number, currency: string = 'RUB') => { return `${price.toLocaleString('ru-RU')} ${currency === 'RUB' ? '₽' : currency}`; }; // Показываем только выбранные товары на втором этапе const selectedItems = items.filter(item => item.selected); return (
{selectedItems.length === 0 ? (

Не выбрано товаров для заказа

Вернитесь на предыдущий шаг и выберите товары

) : ( selectedItems.map((item, index) => (
{item.quantity}

{item.name}

{item.description}
e.preventDefault()}> handleComment(item.id, e.target.value)} />
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

{item.deliveryTime || 'Уточняется'}

{item.deliveryDate || ''}
{item.quantity} шт.

{formatPrice(item.price * item.quantity, item.currency)}

{formatPrice(item.price, item.currency)}/шт
)) )}
); }; export default CartList2;