mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
fix(crm-loyalty-cards): Show always Points of first Card
This commit is contained in:
@@ -51,7 +51,7 @@ describe('CustomerCardPointsSummaryComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('formattedPoints computed signal', () => {
|
describe('formattedPoints computed signal', () => {
|
||||||
it('should display points from primary card', () => {
|
it('should display points from first card', () => {
|
||||||
fixture.componentRef.setInput('cards', mockCards);
|
fixture.componentRef.setInput('cards', mockCards);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ describe('CustomerCardPointsSummaryComponent', () => {
|
|||||||
expect(component.formattedPoints()).toBe('123.456');
|
expect(component.formattedPoints()).toBe('123.456');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display 0 when no primary card exists', () => {
|
it('should display points from first card regardless of isPrimary flag', () => {
|
||||||
const cardsWithoutPrimary: BonusCardInfo[] = [
|
const cardsWithoutPrimary: BonusCardInfo[] = [
|
||||||
{
|
{
|
||||||
code: 'CARD-1',
|
code: 'CARD-1',
|
||||||
@@ -93,7 +93,7 @@ describe('CustomerCardPointsSummaryComponent', () => {
|
|||||||
fixture.componentRef.setInput('cards', cardsWithoutPrimary);
|
fixture.componentRef.setInput('cards', cardsWithoutPrimary);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(component.formattedPoints()).toBe('0');
|
expect(component.formattedPoints()).toBe('1.500');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display 0 when cards array is empty', () => {
|
it('should display 0 when cards array is empty', () => {
|
||||||
@@ -122,14 +122,14 @@ describe('CustomerCardPointsSummaryComponent', () => {
|
|||||||
expect(component.formattedPoints()).toBe('0');
|
expect(component.formattedPoints()).toBe('0');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should only use primary card points, not sum of all cards', () => {
|
it('should only use first card points, not sum of all cards', () => {
|
||||||
const multipleCards: BonusCardInfo[] = [
|
const multipleCards: BonusCardInfo[] = [
|
||||||
{
|
{
|
||||||
code: 'CARD-1',
|
code: 'CARD-1',
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isPrimary: true,
|
isPrimary: false,
|
||||||
totalPoints: 1000,
|
totalPoints: 1000,
|
||||||
cardNumber: '1234-5678-9012-3456',
|
cardNumber: '1234-5678-9012-3456',
|
||||||
} as BonusCardInfo,
|
} as BonusCardInfo,
|
||||||
@@ -138,7 +138,7 @@ describe('CustomerCardPointsSummaryComponent', () => {
|
|||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isPrimary: false,
|
isPrimary: true,
|
||||||
totalPoints: 500,
|
totalPoints: 500,
|
||||||
cardNumber: '9876-5432-1098-7654',
|
cardNumber: '9876-5432-1098-7654',
|
||||||
} as BonusCardInfo,
|
} as BonusCardInfo,
|
||||||
@@ -147,7 +147,7 @@ describe('CustomerCardPointsSummaryComponent', () => {
|
|||||||
fixture.componentRef.setInput('cards', multipleCards);
|
fixture.componentRef.setInput('cards', multipleCards);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
// Should be 1000, not 1500
|
// Should be 1000 (first card), not 500 (primary) or 1500 (sum)
|
||||||
expect(component.formattedPoints()).toBe('1.000');
|
expect(component.formattedPoints()).toBe('1.000');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,12 +36,11 @@ export class CustomerCardPointsSummaryComponent {
|
|||||||
readonly navigateToPraemienshop = output<void>();
|
readonly navigateToPraemienshop = output<void>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Total points from primary card, formatted with thousands separator.
|
* Total points from first card, formatted with thousands separator.
|
||||||
*/
|
*/
|
||||||
readonly formattedPoints = computed(() => {
|
readonly formattedPoints = computed(() => {
|
||||||
const cards = this.cards();
|
const cards = this.cards();
|
||||||
const primaryCard = cards.find((c) => c.isPrimary);
|
const points = cards?.[0]?.totalPoints ?? 0;
|
||||||
const points = primaryCard?.totalPoints ?? 0;
|
|
||||||
|
|
||||||
// Format with German thousands separator (dot)
|
// Format with German thousands separator (dot)
|
||||||
return points.toLocaleString('de-DE');
|
return points.toLocaleString('de-DE');
|
||||||
|
|||||||
Reference in New Issue
Block a user