From 76ae652565250e2e96426c99c4a126dc8122d244 Mon Sep 17 00:00:00 2001 From: abilpraju-aot <abil.raju@aot-technologies.com> Date: Mon, 6 Jan 2025 17:15:34 +0530 Subject: [PATCH 1/4] updated styling of custom info --- .../CustomComponents/CustomInfo.tsx | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx b/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx index 80e1d4c63..e7b6b920d 100644 --- a/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx +++ b/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx @@ -1,4 +1,4 @@ -import React ,{ FC } from "react"; +import React, { FC } from "react"; import { useTranslation } from "react-i18next"; import { InfoIcon } from "../SvgIcons/index"; @@ -14,16 +14,23 @@ export const CustomInfo: FC<CustomInfoProps> = ( { content , className , }) => { - const { t } = useTranslation(); - return ( - <div className={`info-panel ${className}`}> - <div className="d-flex align-items-center"> - <InfoIcon /> - <div className="field-label ms-2">{t(heading)}</div> - </div> - <div className="info-content"> - {t(content)} - </div> + const { t } = useTranslation(); + + // Replace `\n` with <br /> tags + const formattedContent = content.split("\n").map((line, index) => ( + <React.Fragment key={index}> + {t(line)} + <br /> + </React.Fragment> + )); + + return ( + <div className={`info-panel ${className}`}> + <div className="d-flex align-items-center"> + <InfoIcon /> + <div className="field-label ms-2">{t(heading)}</div> </div> - ) + <div className="info-content">{formattedContent}</div> {/* Render formatted content */} + </div> + ); }; \ No newline at end of file From 03896bc4a57a0c71a38306f7b965c65fa45618ea Mon Sep 17 00:00:00 2001 From: abilpraju-aot <abil.raju@aot-technologies.com> Date: Mon, 6 Jan 2025 17:27:16 +0530 Subject: [PATCH 2/4] updated sonar fix --- .../src/components/CustomComponents/CustomInfo.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx b/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx index e7b6b920d..e5e232b43 100644 --- a/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx +++ b/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx @@ -17,8 +17,9 @@ export const CustomInfo: FC<CustomInfoProps> = ( { const { t } = useTranslation(); // Replace `\n` with <br /> tags - const formattedContent = content.split("\n").map((line, index) => ( - <React.Fragment key={index}> + // Create a unique key for each line using a random identifier (e.g., Date.now combined with a line) + const formattedContent = content.split("\n").map((line) => ( + <React.Fragment key={`${line}-${Date.now()}`}> {t(line)} <br /> </React.Fragment> From cb913953f2be9786085b6e084e86d215c3c742f7 Mon Sep 17 00:00:00 2001 From: abilpraju-aot <abil.raju@aot-technologies.com> Date: Mon, 6 Jan 2025 17:32:54 +0530 Subject: [PATCH 3/4] updated sonar fix --- .../src/components/CustomComponents/CustomInfo.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx b/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx index e5e232b43..3387fd2e7 100644 --- a/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx +++ b/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx @@ -16,15 +16,15 @@ export const CustomInfo: FC<CustomInfoProps> = ( { }) => { const { t } = useTranslation(); - // Replace `\n` with <br /> tags - // Create a unique key for each line using a random identifier (e.g., Date.now combined with a line) - const formattedContent = content.split("\n").map((line) => ( - <React.Fragment key={`${line}-${Date.now()}`}> + // Replace `\n` with <br /> tags and use the index as the key + const formattedContent = content.split("\n").map((line, index) => ( + <React.Fragment key={`line-${index}`}> {t(line)} <br /> </React.Fragment> )); + return ( <div className={`info-panel ${className}`}> <div className="d-flex align-items-center"> From 403b71c6c18c9ed7df0e9b888cb21c2325940aa2 Mon Sep 17 00:00:00 2001 From: abilpraju-aot <abil.raju@aot-technologies.com> Date: Mon, 6 Jan 2025 17:38:49 +0530 Subject: [PATCH 4/4] sonarfix --- .../src/components/CustomComponents/CustomInfo.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx b/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx index 3387fd2e7..7e6702aba 100644 --- a/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx +++ b/forms-flow-components/src/components/CustomComponents/CustomInfo.tsx @@ -16,9 +16,9 @@ export const CustomInfo: FC<CustomInfoProps> = ( { }) => { const { t } = useTranslation(); - // Replace `\n` with <br /> tags and use the index as the key - const formattedContent = content.split("\n").map((line, index) => ( - <React.Fragment key={`line-${index}`}> + // Replace `\n` with <br /> tags and use the line itself as a key + const formattedContent = content.split("\n").map((line) => ( + <React.Fragment key={line.trim().replace(/\s+/g, "-")}> {t(line)} <br /> </React.Fragment>