feat(checkout): implement ngOnInit lifecycle hook to load cart data
This commit is contained in:
parent
a642ae84d5
commit
8ceef31785
|
|
@ -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 { Router } from '@angular/router';
|
||||
import { startWith } from 'rxjs';
|
||||
|
|
@ -30,7 +30,7 @@ import { CheckoutForm, PaymentMethod, PaymentMethodOption, TransferAccount, Tran
|
|||
styleUrl: './checkout-page.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class CheckoutPageComponent {
|
||||
export class CheckoutPageComponent implements OnInit {
|
||||
private readonly formBuilder = inject(FormBuilder);
|
||||
private readonly cartService = inject(CartService);
|
||||
private readonly router = inject(Router);
|
||||
|
|
@ -100,6 +100,10 @@ export class CheckoutPageComponent {
|
|||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.cartService.loadCart().subscribe();
|
||||
}
|
||||
|
||||
private mapCartItemToMock(item: CartItem): CartItemMock {
|
||||
const fullName = item.product?.nombre ?? '';
|
||||
let product = fullName;
|
||||
|
|
|
|||
Loading…
Reference in New Issue