diff --git a/app/pages/cart.vue b/app/pages/cart.vue index c0b3692..36ff4bd 100644 --- a/app/pages/cart.vue +++ b/app/pages/cart.vue @@ -6,13 +6,22 @@ import { useCounterpartyProfile } from '~/composables/useCounterpartyProfile'; const { isComplete: isCounterpartyComplete, loading: counterpartyLoading } = useCounterpartyProfile(); const submitMutation = useMutation(SubmitCalculationOrderDocument, { throws: 'never' }); -const cart = useClientCart(); +const { + items: cartItems, + totalPositions, + totalItems, + totalVolume, + incrementQuantity, + decrementQuantity, + removeProduct, + clearCart, +} = useClientCart(); const sending = ref(false); const success = ref(''); const errorMessage = ref(''); function lineVolume(productId: string) { - const item = cart.items.value.find((entry) => entry.productId === productId); + const item = cartItems.value.find((entry) => entry.productId === productId); if (!item) { return 0; } @@ -23,19 +32,19 @@ function lineVolume(productId: string) { function increment(productId: string) { success.value = ''; errorMessage.value = ''; - cart.incrementQuantity(productId); + incrementQuantity(productId); } function decrement(productId: string) { success.value = ''; errorMessage.value = ''; - cart.decrementQuantity(productId); + decrementQuantity(productId); } function removeFromCart(productId: string) { success.value = ''; errorMessage.value = ''; - cart.removeProduct(productId); + removeProduct(productId); } async function submitCart() { @@ -47,7 +56,7 @@ async function submitCart() { return; } - if (cart.items.value.length < 1) { + if (cartItems.value.length < 1) { errorMessage.value = 'Добавьте хотя бы одну позицию в корзину.'; return; } @@ -55,7 +64,7 @@ async function submitCart() { sending.value = true; const createdCodes: string[] = []; - for (const item of cart.items.value) { + for (const item of cartItems.value) { const result = await submitMutation.mutate({ input: { productName: item.productName, @@ -79,7 +88,7 @@ async function submitCart() { } sending.value = false; - cart.clearCart(); + clearCart(); success.value = `Отправлено заявок: ${createdCodes.length}. Статус: уточнение цены.`; } @@ -100,13 +109,13 @@ async function submitCart() {

Список позиций

-
+
Корзина пока пустая. Добавьте товар из каталога.
@@ -138,7 +138,7 @@ function addProductToCart(product: ClientProductsQuery['clientProducts'][number]

{{ product.name }}

SKU: {{ product.sku }}

- В корзине: {{ cart.getQuantity(product.id) }} + В корзине: {{ getQuantity(product.id) }}