diff --git a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts index 439062a..54983cc 100644 --- a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts +++ b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts @@ -6,7 +6,6 @@ import { MessageService } from 'primeng/api'; import { MessagingService } from 'src/app/services/messaging.service'; import { DeviceType, getTypeDevice } from 'src/app/utils'; import { AuthService } from 'src/app/services/auth.service'; -import { ResponseError } from 'src/app/interface/data'; @Component({ selector: 'app-guest-card', @@ -36,6 +35,8 @@ export class GuestCardComponent implements OnInit { this.negativeBalance = !Array.isArray(this.authService.userInfo?.walletBalances); this.showBack = getTypeDevice() === DeviceType.android; + this.authService.getLastPurchase(); + this.requestPermission(); } diff --git a/angular/src/app/services/auth.service.ts b/angular/src/app/services/auth.service.ts index 29b53b7..e77e0a8 100644 --- a/angular/src/app/services/auth.service.ts +++ b/angular/src/app/services/auth.service.ts @@ -87,7 +87,7 @@ export class AuthService { }); } else if (value && value.customer_info) { this.userInfo = value.customer_info; - + this.cookiesService.setCookie('phone-number', this.userInfo!.phone?.slice(2)); } }, @@ -244,12 +244,14 @@ export class AuthService { return this.userInfo && lvlPeriods[this.userInfo?.customer_level] || lvlPeriods[0]; } - getLastPurchase(userInfo: UserInfo) { - this.wpJsonService.getLastPurchase(environment.systemId, this.token!).subscribe({ - next: (res) => { - this.purchaseData.lastPurchase = res[userInfo.id][0]; - }, - }); + getLastPurchase() { + if(this.userInfo) { + this.wpJsonService.getLastPurchase(environment.systemId, this.token!).subscribe({ + next: (res) => { + this.purchaseData.lastPurchase = res[this.userInfo!.id][0]; + }, + }); + } } getBalanceAmount(loyaltyPrograms: UserInfoWalletBalance[]) {