From 4817dd1f76e9771541c90b65962c9e943db52fb5 Mon Sep 17 00:00:00 2001 From: ncoronel Date: Thu, 2 Jul 2026 09:39:06 -0300 Subject: [PATCH] feat: rename stock to cantidad_maxima in product variant interfaces and update related components for consistency --- src/app/core/services/catalog/catalog.interface.ts | 4 ++-- .../product-attribute-selector.component.ts | 2 +- .../product-detail-page.component.html | 2 +- .../product-detail-page.component.spec.ts | 14 +++++++------- .../product-detail-page.component.ts | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/app/core/services/catalog/catalog.interface.ts b/src/app/core/services/catalog/catalog.interface.ts index 2d98c11..bf65854 100644 --- a/src/app/core/services/catalog/catalog.interface.ts +++ b/src/app/core/services/catalog/catalog.interface.ts @@ -31,14 +31,14 @@ export interface ProductAttribute { export interface ProductVariant { id: number; - stock: number; + cantidad_maxima: number; definitions: Record; images: string[]; } export interface ProductVariantMap { variant_id: number; - stock: number; + cantidad_maxima: number; attributes: Record; } diff --git a/src/app/features/store/components/product-attribute-selector/product-attribute-selector.component.ts b/src/app/features/store/components/product-attribute-selector/product-attribute-selector.component.ts index 23425c2..7497908 100644 --- a/src/app/features/store/components/product-attribute-selector/product-attribute-selector.component.ts +++ b/src/app/features/store/components/product-attribute-selector/product-attribute-selector.component.ts @@ -46,7 +46,7 @@ export class ProductAttributeSelectorComponent { const optionNormalized = this.normalizeText(option.value || option.label); const isAvailable = variants.some(variant => { - if (variant.stock <= 0) return false; + if (variant.cantidad_maxima <= 0) return false; const variantAttrValue = this.getDefaultVariantAttributeValue(attribute, variant.attributes); if (!variantAttrValue || this.normalizeText(variantAttrValue) !== optionNormalized) { diff --git a/src/app/features/store/pages/product-detail-page/product-detail-page.component.html b/src/app/features/store/pages/product-detail-page/product-detail-page.component.html index cadc2f2..8091144 100644 --- a/src/app/features/store/pages/product-detail-page/product-detail-page.component.html +++ b/src/app/features/store/pages/product-detail-page/product-detail-page.component.html @@ -55,7 +55,7 @@
diff --git a/src/app/features/store/pages/product-detail-page/product-detail-page.component.spec.ts b/src/app/features/store/pages/product-detail-page/product-detail-page.component.spec.ts index 3c6b05a..b298128 100644 --- a/src/app/features/store/pages/product-detail-page/product-detail-page.component.spec.ts +++ b/src/app/features/store/pages/product-detail-page/product-detail-page.component.spec.ts @@ -132,7 +132,7 @@ describe('ProductDetailPageComponent', () => { images: ['https://example.com/product.png'], variant: { id: 123, - stock: 10, + cantidad_maxima: 10, images: ['https://example.com/variant1.png', 'https://example.com/variant2.png'], definitions: {} } @@ -234,7 +234,7 @@ describe('ProductDetailPageComponent', () => { ], variant: { id: 123, - stock: 10, + cantidad_maxima: 10, images: ['https://example.com/variant1.png'], definitions: { color: 'beige', @@ -279,7 +279,7 @@ describe('ProductDetailPageComponent', () => { const fixture = TestBed.createComponent(ProductDetailPageComponent); fixture.componentInstance['selectedVariant'].set({ variant_id: 1, - stock: 10, + cantidad_maxima: 10, attributes: {} }); fixture.detectChanges(); @@ -355,14 +355,14 @@ describe('ProductDetailPageComponent', () => { ...mockProduct, variant: { id: 123, - stock: 5, + cantidad_maxima: 5, images: [], definitions: {} }, variants_map: [ { variant_id: 123, - stock: 5, + cantidad_maxima: 5, attributes: {} } ] @@ -396,14 +396,14 @@ describe('ProductDetailPageComponent', () => { ...mockProduct, variant: { id: 123, - stock: 5, + cantidad_maxima: 5, images: [], definitions: {} }, variants_map: [ { variant_id: 123, - stock: 5, + cantidad_maxima: 5, attributes: {} } ] diff --git a/src/app/features/store/pages/product-detail-page/product-detail-page.component.ts b/src/app/features/store/pages/product-detail-page/product-detail-page.component.ts index 08eec66..db65834 100644 --- a/src/app/features/store/pages/product-detail-page/product-detail-page.component.ts +++ b/src/app/features/store/pages/product-detail-page/product-detail-page.component.ts @@ -170,7 +170,7 @@ export class ProductDetailPageComponent implements OnInit, OnDestroy { if (!currentProduct) return null; const updatedVariantsMap = currentProduct.variants_map.map((v) => { if (v.variant_id === variantId) { - return { ...v, stock: 0 }; + return { ...v, cantidad_maxima: 0 }; } return v; }); @@ -205,8 +205,8 @@ export class ProductDetailPageComponent implements OnInit, OnDestroy { } this.selectedVariant.set(variant); - if (variant && this.quantity() > variant.stock) { - this.quantity.set(Math.max(1, variant.stock)); + if (variant && this.quantity() > variant.cantidad_maxima) { + this.quantity.set(Math.max(1, variant.cantidad_maxima)); } const currentProduct = this.product();