final commit before execution

This commit is contained in:
2025-02-07 11:51:43 +02:00
parent fa272c636c
commit 58e7ed2f06
14 changed files with 473 additions and 196 deletions

View File

@@ -23,65 +23,64 @@ export default function CartItems() {
removeItemFromCart(productId)
}
if (cartItems && cartItems.length < 1) {
if (cartItems && cartItems.length > 0) {
return (
<div className='flex h-72 flex-col items-center justify-center'>
<h2 className='mb-5 mt-10 text-3xl font-bold'>Cart is Empty</h2>
<Link
href={'/catalog'}
className='rounded-md bg-orange-500 px-6 py-2 text-white'
>
Shop
</Link>
</div>
)
}
return (
<>
{cartItems?.map((item: CartItem, i: number) => (
<div className='my-4 flex items-center' key={i}>
<div className='col'>
{item.title}
<Image
src={(item?.image || '').replace('.jpg', '-thumb.jpg')}
alt=''
width={96}
height={96}
className='rounded-md border'
style={{
width: '96px',
height: '96px',
objectFit: 'cover'
}}
/>
</div>
<div className='flex-none'>
<div className='flex w-16 flex-none items-center justify-center'>
<Button
variant={'outline'}
className='rounded-0 h-[3rem] w-[3rem] text-2xl leading-none text-brand-violet'
onClick={() => onDecreaseQuantity(item.id)}
>
<Minus />
</Button>
<div className='mx-4 text-xl font-bold leading-none text-brand-violet'>
{item.quantity}
<>
{cartItems?.map((item: CartItem, i: number) => (
<div className='my-4 flex items-center' key={i}>
<div className='col'>
{item.title}
<Image
src={(item?.image || '').replace('.jpg', '-thumb.jpg')}
alt=''
width={96}
height={96}
className='rounded-md border'
style={{
width: '96px',
height: '96px',
objectFit: 'cover'
}}
/>
</div>
<div className='flex-none'>
<div className='flex w-16 flex-none items-center justify-center'>
<Button
variant={'outline'}
className='rounded-0 h-[3rem] w-[3rem] text-2xl leading-none text-brand-violet'
onClick={() => onDecreaseQuantity(item.id)}
>
<Minus />
</Button>
<div className='mx-4 text-xl font-bold leading-none text-brand-violet'>
{item.quantity}
</div>
<Button
variant={'outline'}
className='rounded-0 h-[3rem] w-[3rem] text-2xl leading-none text-brand-violet'
onClick={() => onIncreaseQuantity(item.id)}
>
<Plus />
</Button>
</div>
<Button
variant={'outline'}
className='rounded-0 h-[3rem] w-[3rem] text-2xl leading-none text-brand-violet'
onClick={() => onIncreaseQuantity(item.id)}
>
<Plus />
</Button>
</div>
<div className='col text-right text-lg font-bold'>
{(item.price * item.quantity).toFixed(2)} грн
</div>
</div>
<div className='col text-right text-lg font-bold'>
{(item.price * item.quantity).toFixed(2)} грн
</div>
</div>
))}
</>
))}
</>
)
}
return (
<div className='flex h-72 flex-col items-center justify-center'>
<h2 className='mb-5 mt-10 text-3xl font-bold'>Cart is Empty</h2>
<Link
href={'/catalog'}
className='rounded-md bg-orange-500 px-6 py-2 text-white'
>
Продовжити покупки
</Link>
</div>
)
}