refactor(lib-checkout,lib-crm): replace SelectedCustomerFacade with CrmTabMetadataService

Remove the redundant SelectedCustomerFacade which was just a thin wrapper
around CrmTabMetadataService. Update all consumers to use CrmTabMetadataService
directly for better consistency and reduced indirection.

Changes:
- Remove SelectedCustomerFacade and its exports
- Update reward catalog components to use SelectedCustomerBonusCardsResource
- Replace local resource factories with global resources
- Update purchase options modal and customer details components
- Simplify reward action component logic and improve button state handling

Ref: #5202, #5263, #5358
This commit is contained in:
Nino
2025-09-30 18:14:54 +02:00
parent 37840b1565
commit c767c60d31
16 changed files with 129 additions and 184 deletions

View File

@@ -6,15 +6,15 @@ import {
PurchaseOptionsModalContext,
} from './purchase-options-modal.data';
import {
SelectedCustomerFacade,
CustomerFacade,
Customer,
CrmTabMetadataService,
} from '@isa/crm/data-access';
@Injectable({ providedIn: 'root' })
export class PurchaseOptionsModalService {
#uiModal = inject(UiModalService);
#selectedCustomerFacade = inject(SelectedCustomerFacade);
#crmTabMetadataService = inject(CrmTabMetadataService);
#customerFacade = inject(CustomerFacade);
async open(
@@ -38,7 +38,7 @@ export class PurchaseOptionsModalService {
}: {
tabId: number;
}): Promise<Customer | undefined> {
const customerId = this.#selectedCustomerFacade.get(tabId);
const customerId = this.#crmTabMetadataService.selectedCustomerId(tabId);
if (!customerId) {
return Promise.resolve(undefined);

View File

@@ -37,7 +37,7 @@ import { MessageModalComponent, MessageModalData } from '@modal/message';
import { GenderSettingsService } from '@shared/services/gender';
import { injectTab } from '@isa/core/tabs';
import { toSignal } from '@angular/core/rxjs-interop';
import { SelectedCustomerFacade } from '@isa/crm/data-access';
import { CrmTabMetadataService } from '@isa/crm/data-access';
export interface CustomerDetailsViewMainState {
isBusy: boolean;
@@ -70,7 +70,7 @@ export class CustomerDetailsViewMainComponent
private _onDestroy$ = new Subject<void>();
customerService = inject(CrmCustomerService);
selectCustomerFacade = inject(SelectedCustomerFacade);
crmTabMetadataService = inject(CrmTabMetadataService);
tab = injectTab();
fetching$ = combineLatest([
@@ -352,7 +352,10 @@ export class CustomerDetailsViewMainComponent
// #5262 Für die Auswahl des Kunden im "Prämienshop-Modus" (Getrennt vom regulären Checkout-Prozess)
async continueReward() {
if (this.isRewardTab()) {
this.selectCustomerFacade.set(this.processId, this.customer.id);
this.crmTabMetadataService.setSelectedCustomerId(
this.processId,
this.customer.id,
);
await this._router.navigate(['/', this.processId, 'reward']);
}
}