#4244 Kundenkarten-Ansicht wirf Fehler

This commit is contained in:
Lorenz Hilpert
2023-08-01 15:21:12 +02:00
parent 95d1ea3530
commit 8aafee672e
2 changed files with 13 additions and 4 deletions

View File

@@ -9,10 +9,13 @@
</a>
</div>
<h1 class="text-center text-2xl font-bold">Kundenkarte</h1>
<p class="text-center text-xl">
<p class="text-center text-xl" *ngIf="!(noDataFound$ | async)">
Alle Infos zu Ihrer Kundenkarte <br />
und allen Partnerkarten.
</p>
<p class="text-center text-xl" *ngIf="noDataFound$ | async">
Keine Kundenkarte gefunden.
</p>
<page-customer-kundenkarte
class="justify-self-center"
*ngFor="let karte of primaryKundenkarte$ | async"

View File

@@ -1,13 +1,14 @@
import { Component, ChangeDetectionStrategy, OnInit, OnDestroy } from '@angular/core';
import { CustomerSearchStore } from '../store';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { Subject, combineLatest } from 'rxjs';
import { map, share, switchMap } from 'rxjs/operators';
import { Subject, combineLatest, of } from 'rxjs';
import { catchError, map, share, switchMap } from 'rxjs/operators';
import { CrmCustomerService } from '@domain/crm';
import { KundenkarteComponent } from '../../components/kundenkarte';
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
import { IconComponent } from '@shared/components/icon';
import { CustomerSearchNavigation } from '../../navigations';
import { BonusCardInfoDTO } from '@swagger/crm';
@Component({
selector: 'page-customer-kundenkarte-main-view',
@@ -25,11 +26,16 @@ export class KundenkarteMainViewComponent implements OnInit, OnDestroy {
kundenkarte$ = this.customerId$.pipe(
switchMap((customerId) =>
this._customerService.getCustomerCard(customerId).pipe(map((response) => response.result?.filter((f) => f.isActive)))
this._customerService.getCustomerCard(customerId).pipe(
map((response) => response.result?.filter((f) => f.isActive)),
catchError(() => of<BonusCardInfoDTO[]>([]))
)
),
share()
);
noDataFound$ = this.kundenkarte$.pipe(map((kundenkarte) => kundenkarte?.length == 0));
primaryKundenkarte$ = this.kundenkarte$.pipe(map((kundenkarte) => kundenkarte?.filter((k) => k.isPrimary)));
partnerKundenkarte$ = this.kundenkarte$.pipe(map((kundenkarte) => kundenkarte?.filter((k) => !k.isPrimary)));