From 47103ff69231212357de8ce15d223724777ba7f5 Mon Sep 17 00:00:00 2001 From: Liah Kim Date: Mon, 14 Aug 2023 11:04:41 -0400 Subject: [PATCH] Update FAQ card to support answerV2 instead of answer J=BACK-2436 TEST=manual Created test site using jambo template and verified that FAQ answer was rendered properly --- cards/faq-accordion/component.js | 9 ++++++++- cards/multilang-faq-accordion/component.js | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cards/faq-accordion/component.js b/cards/faq-accordion/component.js index 1286f47a0..5e3e5fe59 100644 --- a/cards/faq-accordion/component.js +++ b/cards/faq-accordion/component.js @@ -13,11 +13,18 @@ class faq_accordionCardComponent extends BaseCard['faq-accordion'] { */ dataForRender(profile) { const linkTarget = AnswersExperience.runtimeConfig.get('linkTarget') || '_top'; + let profileAnswer = ''; + if (profile.answerV2 && profile.answerV2.html) { + profileAnswer = profile.answerV2.html; + } else if (profile.answerV2 && profile.answerV2.json) { + console.warn('JSON is not supported, please switch to HTML.') + } return { title: profile.question || profile.name, // The header text of the card // subtitle: '', // The sub-header text of the card - details: profile.answer ? ANSWERS.formatRichText(profile.answer, "answer", linkTarget) : null, // The text in the body of the card + details: profileAnswer ? profileAnswer : null, // The text in the body + // of the card // If the card's details are longer than a certain character count, you can truncate the // text. A toggle will be supplied that can show or hide the truncated text. // showMoreDetails: { diff --git a/cards/multilang-faq-accordion/component.js b/cards/multilang-faq-accordion/component.js index 791107337..2bd757a48 100644 --- a/cards/multilang-faq-accordion/component.js +++ b/cards/multilang-faq-accordion/component.js @@ -13,11 +13,18 @@ class multilang_faq_accordionCardComponent extends BaseCard['multilang-faq-accor */ dataForRender(profile) { const linkTarget = AnswersExperience.runtimeConfig.get('linkTarget') || '_top'; + let profileAnswer = ''; + if (profile.answerV2 && profile.answerV2.html) { + profileAnswer = profile.answerV2.html; + } else if (profile.answerV2 && profile.answerV2.json) { + console.warn('JSON is not supported, please switch to HTML.') + } return { title: profile.question || profile.name, // The header text of the card // subtitle: '', // The sub-header text of the card - details: profile.answer ? ANSWERS.formatRichText(profile.answer, "answer", linkTarget) : null, // The text in the body of the card + details: profileAnswer ? profileAnswer : null, // The text in the body + // of the card // If the card's details are longer than a certain character count, you can truncate the // text. A toggle will be supplied that can show or hide the truncated text. // showMoreDetails: {