Merged PR 2043: #5335 Endpoint Unlock wurde erweitert

#5335 Endpoint Unlock wurde erweitert
This commit is contained in:
Nino Righi
2025-11-21 14:30:01 +00:00
committed by Lorenz Hilpert
parent bf87df6273
commit df1fe540d0
11 changed files with 70 additions and 412 deletions

View File

@@ -37,6 +37,11 @@ export class CustomerBonusCardsResource {
readonly #customerId = signal<number | undefined>(undefined);
/**
* Current customer ID being loaded.
*/
readonly customerId = computed(() => this.#customerId());
/**
* Resource that loads bonus cards based on current parameters.
*

View File

@@ -1,6 +1,7 @@
import { z } from 'zod';
export const UnlockCardSchema = z.object({
customerId: z.number().describe('Unique customer identifier'),
cardCode: z.string().describe('Unique card code identifier'),
});

View File

@@ -194,6 +194,7 @@ export class CrmSearchService {
const req$ = this.#loyaltyCardService
.LoyaltyCardUnlockCard({
customerId: parsed.customerId,
cardCode: parsed.cardCode,
})
.pipe(catchResponseArgsErrorPipe());

View File

@@ -34,8 +34,6 @@ export class AddCustomerCardComponent implements OnDestroy {
#textDialog = injectTextInputDialog();
#feedbackDialog = injectFeedbackDialog();
readonly customerId = input.required<number>();
async addCardDialog() {
this.#logger.debug('Opening add card dialog');
const dialogRef = this.#textDialog({
@@ -77,8 +75,15 @@ export class AddCustomerCardComponent implements OnDestroy {
async addCard(cardCode: string) {
this.#logger.info('Adding customer card', () => ({ cardCode }));
const customerId = this.#bonusCardsResource.customerId();
if (!customerId) {
this.#logger.warn('Cannot add card: customerId not available');
return;
}
await this.#customerCardsFacade.addCard({
customerId: this.customerId(),
customerId,
loyaltyCardValues: {
cardCode,
},

View File

@@ -39,6 +39,8 @@ export class LockCustomerCardComponent implements OnDestroy {
readonly isActive = input.required<boolean>();
readonly cardCode = input.required<string>();
readonly #customerId = this.#bonusCardsResource.customerId;
loading = signal(false);
async lockCard() {
@@ -69,11 +71,19 @@ export class LockCustomerCardComponent implements OnDestroy {
}
async unlockCard() {
const customerId = this.#customerId();
const cardCode = this.cardCode();
if (!customerId) {
this.#logger.warn('Cannot unlock card: customerId not available');
return;
}
try {
this.loading.set(true);
await this.#customerCardsFacade.unlockCard({
cardCode,
customerId,
});
this.#feedbackDialog({
data: {

View File

@@ -30,6 +30,6 @@
<!-- Cards carousel -->
<crm-customer-cards-carousel [cards]="cardList" class="w-full" />
<crm-add-customer-card [customerId]="customerId()" />
<crm-add-customer-card />
}
</div>