From a88df37ff17c9985ef6332aa7b81ffb68dd485c6 Mon Sep 17 00:00:00 2001 From: gchi25 Date: Thu, 15 Aug 2024 09:10:49 -0400 Subject: [PATCH 1/3] PXBF-1674-add-search-title-json-data: add search title in json data --- .../src/Controller/LifeEventController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php b/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php index e352b7550..9053039d2 100644 --- a/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php +++ b/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php @@ -176,6 +176,12 @@ public function getData($id) { $this->mode = $this->request->get('mode') ?? "published"; } + // Get life event node by its ID. + $life_event_node = $this->getLifeEventById($id, $this->mode); + + // Get search title of life event. + $life_event_search_title = $life_event_node->get('field_b_search_title')->value; + // Get life event form node and node ID of given life event. $life_event_form_node = $this->getLifeEventFormById($id, $this->mode); if (empty($life_event_form_node)) { @@ -196,6 +202,7 @@ public function getData($id) { "timeEstimate" => $life_event_form_node->get('field_b_time_estimate')->value ?? "", "titlePrefix" => $life_event_form_node->get('field_b_title_prefix')->value ?? "", "title" => $life_event_form_node->get('title')->value ?? "", + "searchTitle" => $life_event_search_title ?? "", "summary" => $life_event_form_node->get('field_b_summary')->value ?? "", ]; From 185bb7aa27f9f0b378f4fedc92b16087c35e4f9e Mon Sep 17 00:00:00 2001 From: gchi25 Date: Mon, 19 Aug 2024 11:54:39 -0400 Subject: [PATCH 2/3] PXBF-1674-add-search-title-json-data: add searchTitle in relevant benefits --- .../src/Controller/LifeEventController.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php b/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php index 9053039d2..a68409bae 100644 --- a/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php +++ b/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php @@ -176,12 +176,6 @@ public function getData($id) { $this->mode = $this->request->get('mode') ?? "published"; } - // Get life event node by its ID. - $life_event_node = $this->getLifeEventById($id, $this->mode); - - // Get search title of life event. - $life_event_search_title = $life_event_node->get('field_b_search_title')->value; - // Get life event form node and node ID of given life event. $life_event_form_node = $this->getLifeEventFormById($id, $this->mode); if (empty($life_event_form_node)) { @@ -202,7 +196,6 @@ public function getData($id) { "timeEstimate" => $life_event_form_node->get('field_b_time_estimate')->value ?? "", "titlePrefix" => $life_event_form_node->get('field_b_title_prefix')->value ?? "", "title" => $life_event_form_node->get('title')->value ?? "", - "searchTitle" => $life_event_search_title ?? "", "summary" => $life_event_form_node->get('field_b_summary')->value ?? "", ]; @@ -212,8 +205,17 @@ public function getData($id) { // Build Relevant Benefits. $life_event_form_relevant_benefits = []; foreach ($relevant_benefits as $relevant_benefit) { + + // Get life event node by its ID. + $id = current($relevant_benefit->get('field_b_life_event_form')->referencedEntities())->get('field_b_id')->value; + $life_event_node = $this->getLifeEventById($id, $this->mode); + + // Get search title of life event. + $life_event_search_title = $life_event_node->get('field_b_search_title')->value; + $life_event_form_relevant_benefit = [ "title" => current($relevant_benefit->get('field_b_life_event_form')->referencedEntities())->get('title')->value ?? "", + "searchTitle" => $life_event_search_title ?? "", "body" => $relevant_benefit->get('field_b_body')->value ?? "", "link" => $relevant_benefit->get('field_b_link')->value ?? "", "cta" => $relevant_benefit->get('field_b_cta')->value ?? "", From 371a25e9a8cbcdbc423364ca4c38efa6bd033434 Mon Sep 17 00:00:00 2001 From: scottqueen-bixal Date: Tue, 20 Aug 2024 10:43:17 -0400 Subject: [PATCH 3/3] PXBF-1674-add-search-title-json-data: incldue search title conditional in title prop --- .../src/shared/components/RelativeBenefitList/index.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/benefit-finder/src/shared/components/RelativeBenefitList/index.jsx b/benefit-finder/src/shared/components/RelativeBenefitList/index.jsx index 9d85177a9..21db22416 100644 --- a/benefit-finder/src/shared/components/RelativeBenefitList/index.jsx +++ b/benefit-finder/src/shared/components/RelativeBenefitList/index.jsx @@ -13,13 +13,14 @@ const RelativeBenefitList = ({ data, carrotType }) => {
    {data && data.map((item, i) => { - const { title, link, cta, body, lifeEventId } = item.lifeEvent + const { title, searchTitle, link, cta, body, lifeEventId } = + item.lifeEvent const trimedLifeEventId = lifeEventId.replace('es_', '') return (