feat(checkout): implement ngOnInit lifecycle hook to load cart data
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { ChangeDetectionStrategy, Component, computed, inject, signal, ViewChild } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, computed, inject, OnInit, signal, ViewChild } from '@angular/core';
|
||||||
import { FormBuilder, Validators } from '@angular/forms';
|
import { FormBuilder, Validators } from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { startWith } from 'rxjs';
|
import { startWith } from 'rxjs';
|
||||||
@@ -30,7 +30,7 @@ import { CheckoutForm, PaymentMethod, PaymentMethodOption, TransferAccount, Tran
|
|||||||
styleUrl: './checkout-page.component.scss',
|
styleUrl: './checkout-page.component.scss',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class CheckoutPageComponent {
|
export class CheckoutPageComponent implements OnInit {
|
||||||
private readonly formBuilder = inject(FormBuilder);
|
private readonly formBuilder = inject(FormBuilder);
|
||||||
private readonly cartService = inject(CartService);
|
private readonly cartService = inject(CartService);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
@@ -100,6 +100,10 @@ export class CheckoutPageComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.cartService.loadCart().subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
private mapCartItemToMock(item: CartItem): CartItemMock {
|
private mapCartItemToMock(item: CartItem): CartItemMock {
|
||||||
const fullName = item.product?.nombre ?? '';
|
const fullName = item.product?.nombre ?? '';
|
||||||
let product = fullName;
|
let product = fullName;
|
||||||
|
|||||||
Reference in New Issue
Block a user