Skip to content

Commit

Permalink
fix faq display on individual cards that use ids instead of names
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Dec 19, 2024
1 parent 08d98ad commit 4a9ad61
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ICardErrataEntry[]> = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/card/card.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ICardErrataEntry[]> = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/cards.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}));
Expand Down
10 changes: 7 additions & 3 deletions src/app/faq.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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] ??
[]
);
}
}

0 comments on commit 4a9ad61

Please sign in to comment.