fix: cart

This commit is contained in:
2026-04-15 13:37:46 +02:00
parent be0687f4a9
commit b13293572c
2 changed files with 21 additions and 60 deletions

View File

@@ -1,6 +1,8 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { computed, ref } from 'vue'
import { useFetchJson } from '@/composable/useFetchJson'
import type { ApiResponse } from '@/types'
import { useRoute } from 'vue-router'
export interface Cart {
id: number
@@ -137,15 +139,6 @@ export const useCartStore = defineStore('cart', () => {
return fetchAddresses()
}
function initMockData() {
items.value = [
{ id: 1, productId: 101, name: 'Premium Widget Pro', product_number: 'NC209/7000', image: '/img/product-1.jpg', price: 129.99, quantity: 2 },
{ id: 2, productId: 102, name: 'Ultra Gadget X', product_number: 'NC234/6453', image: '/img/product-2.jpg', price: 89.50, quantity: 1 },
{ id: 3, productId: 103, name: 'Mega Tool Set', product_number: 'NC324/9030', image: '/img/product-3.jpg', price: 249.00, quantity: 3 }
]
}
async function addNewCart(name: string) {
try {
error.value = null
@@ -212,22 +205,6 @@ export const useCartStore = defineStore('cart', () => {
})
return {
items,
selectedAddressId,
selectedDeliveryMethodId,
shippingCost,
vatRate,
deliveryMethods,
productsTotal,
vatAmount,
orderTotal,
itemCount,
deleteProduct,
updateQuantity,
removeItem,
clearCart,
setSelectedAddress,
setDeliveryMethod,
addresses,
addressLoading,
addressError,
@@ -243,6 +220,7 @@ export const useCartStore = defineStore('cart', () => {
deleteAddress,
setAddressPage,
setAddressSearchQuery,
getAddressTemplate
getAddressTemplate,
initCart
}
})