diff --git a/src/app/_shared/components/card-display/card-display.component.ts b/src/app/_shared/components/card-display/card-display.component.ts index 12f1013..d20a9a1 100644 --- a/src/app/_shared/components/card-display/card-display.component.ts +++ b/src/app/_shared/components/card-display/card-display.component.ts @@ -35,7 +35,7 @@ export class CardDisplayComponent { const cardData = this.cardData(); if (!cardData) return []; - return this.faqService.getCardFAQ(cardData.game, cardData.name); + return this.faqService.getCardFAQ(cardData.game, cardData); }); public errata: Signal = computed(() => { diff --git a/src/app/card/card.page.ts b/src/app/card/card.page.ts index dd5157d..1e3934f 100644 --- a/src/app/card/card.page.ts +++ b/src/app/card/card.page.ts @@ -67,7 +67,7 @@ export class CardPage implements OnInit, OnDestroy { const cardData = this.cardData(); if (!cardData) return []; - return this.faqService.getCardFAQ(cardData.game, cardData.name); + return this.faqService.getCardFAQ(cardData.game, cardData); }); public errata: Signal = computed(() => { diff --git a/src/app/cards.service.ts b/src/app/cards.service.ts index 6b55ab9..4a126b9 100644 --- a/src/app/cards.service.ts +++ b/src/app/cards.service.ts @@ -66,7 +66,7 @@ export class CardsService { private reformatCardsWithErrataAndFAQ(): ICard[] { return this.cards.map((card) => ({ ...card, - faq: this.faqService.getCardFAQ(card.game, card.name).length ?? 0, + faq: this.faqService.getCardFAQ(card.game, card).length ?? 0, errata: this.errataService.getCardErrata(card.game, card.name).length ?? 0, })); diff --git a/src/app/faq.service.ts b/src/app/faq.service.ts index ce75934..45b07df 100644 --- a/src/app/faq.service.ts +++ b/src/app/faq.service.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { inject, Injectable, signal, type WritableSignal } from '@angular/core'; import { sortBy } from 'lodash'; import { of } from 'rxjs'; -import type { ICardFAQ, ICardFAQEntry } from '../../interfaces'; +import type { ICard, ICardFAQ, ICardFAQEntry } from '../../interfaces'; import { environment } from '../environments/environment'; import { LocaleService } from './locale.service'; @@ -93,10 +93,14 @@ export class FAQService { return faq?.[productId]?.[locale]; } - public getCardFAQ(productId: string, card: string): ICardFAQEntry[] { + public getCardFAQ(productId: string, card: ICard): ICardFAQEntry[] { const faq = this.faqByProductLocaleCard(); const locale = this.localeService.currentLocale(); - return faq[productId]?.[locale]?.[card] ?? []; + return ( + faq[productId]?.[locale]?.[card.id] ?? + faq[productId]?.[locale]?.[card.name] ?? + [] + ); } }