Unify order items layout across cart and orders

This commit is contained in:
Ruslan Bakiev
2026-04-04 14:49:34 +07:00
parent 685f84c428
commit ad1f6b8a35
7 changed files with 299 additions and 84 deletions

View File

@@ -60,15 +60,6 @@ onMounted(() => {
void fetchCart(true);
});
function lineVolume(productId: string) {
const item = cartItems.value.find((entry) => entry.productId === productId);
if (!item) {
return 0;
}
return Number(item.quantity) * Number(item.parameters.width) * Number(item.parameters.thickness);
}
function increment(productId: string) {
success.value = '';
errorMessage.value = '';
@@ -197,30 +188,22 @@ async function submitCart() {
Корзина пока пустая. Добавьте товар из каталога.
</div>
<ul v-else class="space-y-3">
<li
v-for="item in cartItems"
:key="item.productId"
class="surface-card flex flex-col gap-3 rounded-3xl px-4 py-4 md:flex-row md:items-center md:justify-between md:px-5 md:py-5"
>
<div>
<p class="font-semibold text-[#123824]">{{ item.productName }}</p>
<p class="text-xs opacity-70">SKU: {{ item.sku }}</p>
<p class="text-sm opacity-80">
Объем: {{ lineVolume(item.productId) }}
</p>
</div>
<div class="flex items-center gap-2">
<button class="btn btn-square btn-sm" @click="decrement(item.productId)">-</button>
<span class="min-w-8 text-center font-semibold">{{ item.quantity }}</span>
<button class="btn btn-square btn-sm" @click="increment(item.productId)">+</button>
<button class="btn btn-ghost btn-sm text-error" @click="removeFromCart(item.productId)">
Удалить
</button>
</div>
</li>
</ul>
<OrdersOrderItemsTable
v-else
mode="cart"
:items="cartItems.map((item) => ({
id: item.productId,
productName: item.productName,
sku: item.sku,
quantity: item.quantity,
parameters: item.parameters,
unitPrice: null,
lineTotal: null,
}))"
@increment="increment"
@decrement="decrement"
@remove="removeFromCart"
/>
<div class="divider my-1" />