feat: set selected variant on product load in product detail page
This commit is contained in:
@@ -140,6 +140,8 @@ export class ProductDetailPageComponent implements OnInit, OnDestroy {
|
||||
this.productSub = this.catalogService.getProducto(id).subscribe({
|
||||
next: (prod) => {
|
||||
this.product.set(prod);
|
||||
const matchingVariant = prod.variants_map.find((v) => v.variant_id === prod.variant?.id) || null;
|
||||
this.selectedVariant.set(matchingVariant);
|
||||
this.quantity.set(1);
|
||||
this.descriptionExpanded.set(false);
|
||||
this.descriptionHasOverflow.set(false);
|
||||
@@ -159,6 +161,8 @@ export class ProductDetailPageComponent implements OnInit, OnDestroy {
|
||||
this.productSub = this.catalogService.getProducto(productId, variantId).subscribe({
|
||||
next: (prod) => {
|
||||
this.product.set(prod);
|
||||
const matchingVariant = prod.variants_map.find((v) => v.variant_id === prod.variant?.id) || null;
|
||||
this.selectedVariant.set(matchingVariant);
|
||||
this.variantLoading.set(false);
|
||||
},
|
||||
error: (err: HttpErrorResponse) => {
|
||||
|
||||
Reference in New Issue
Block a user