mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 2043: #5335 Endpoint Unlock wurde erweitert
#5335 Endpoint Unlock wurde erweitert
This commit is contained in:
committed by
Lorenz Hilpert
parent
bf87df6273
commit
df1fe540d0
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
|
||||
|
||||
@@ -194,6 +194,7 @@ export class CrmSearchService {
|
||||
|
||||
const req$ = this.#loyaltyCardService
|
||||
.LoyaltyCardUnlockCard({
|
||||
customerId: parsed.customerId,
|
||||
cardCode: parsed.cardCode,
|
||||
})
|
||||
.pipe(catchResponseArgsErrorPipe());
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user