Fix cart rendering crash from nested ref access
This commit is contained in:
@@ -6,7 +6,7 @@ import { useClientCart } from '~/composables/useClientCart';
|
||||
const { result, loading, error } = useQuery(ClientProductsDocument);
|
||||
const search = ref('');
|
||||
const stockFilter = ref<'ALL' | 'CUSTOM' | 'STANDARD'>('ALL');
|
||||
const cart = useClientCart();
|
||||
const { addProduct, getQuantity, totalItems } = useClientCart();
|
||||
|
||||
const coverPresets = [
|
||||
['#e9fbe5', '#acfcd5', '#7be9aa'],
|
||||
@@ -58,7 +58,7 @@ const filteredProducts = computed(() => {
|
||||
});
|
||||
|
||||
function addProductToCart(product: ClientProductsQuery['clientProducts'][number]) {
|
||||
cart.addProduct({
|
||||
addProduct({
|
||||
id: product.id,
|
||||
name: product.name,
|
||||
sku: product.sku,
|
||||
@@ -75,7 +75,7 @@ function addProductToCart(product: ClientProductsQuery['clientProducts'][number]
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<p class="text-sm text-base-content/75">Добавляй позиции и оформляй заявку в корзине.</p>
|
||||
<NuxtLink to="/cart" class="btn btn-outline btn-sm">
|
||||
Корзина: {{ cart.totalItems }}
|
||||
Корзина: {{ totalItems }}
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
@@ -138,7 +138,7 @@ function addProductToCart(product: ClientProductsQuery['clientProducts'][number]
|
||||
<h2 class="text-lg font-bold text-[#133826]">{{ product.name }}</h2>
|
||||
<p class="text-xs text-base-content/65">SKU: {{ product.sku }}</p>
|
||||
<div class="mt-3 flex items-center justify-between">
|
||||
<span class="badge badge-outline">В корзине: {{ cart.getQuantity(product.id) }}</span>
|
||||
<span class="badge badge-outline">В корзине: {{ getQuantity(product.id) }}</span>
|
||||
<button
|
||||
class="btn btn-circle btn-sm border-0 bg-[#139957] text-white hover:bg-[#0d854a]"
|
||||
@click="addProductToCart(product)"
|
||||
|
||||
Reference in New Issue
Block a user