'use client'; import Link from 'next/link'; import {Button, Empty} from 'antd'; import {DeleteOutlined} from '@ant-design/icons'; import {useAppDispatch, useAppSelector} from '@/store/hooks'; import {removeFromCart, selectCartItems, selectCartTotal} from '@/store/cartSlice'; import {useLanguage} from '@/app/context/LanguageContext'; import {commerceCopy} from '@/data/commerce'; import QuantityControl from './QuantityControl'; export default function CartPage() { const dispatch = useAppDispatch(); const items = useAppSelector(selectCartItems); const total = useAppSelector(selectCartTotal); const {t, locale} = useLanguage(); const copy = commerceCopy[locale]; const money = (value: number) => `${value.toLocaleString(locale === 'fa' ? 'fa-IR' : 'en-US')} ${copy.currency}`; return (
{copy.continueShopping}

{t.cart.title}

{copy.cartDescription}

{items.length === 0 ? (
{copy.continueShopping}
) : (
{items.map(item => { const product = t.machines.find(machine => machine.id === item.id) ?? item; return (
{product.name}
{product.name}

{copy.unitPrice}: {money(item.priceNumeric)}

{copy.lineTotal}: {money(item.qty * item.priceNumeric)}

); })}
)}
); }