From 1454f96b512fc7382279223244abd86dc4f2813d Mon Sep 17 00:00:00 2001 From: "Chloe Lin [SSW]" Date: Thu, 4 Jan 2024 14:38:17 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20skill=20display=20issue=20?= =?UTF-8?q?(#582)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * comment filter * replace a tag with span when there is no marketing url --- src/components/skills-list/skills-list.js | 13 +++++-- src/helpers/CRMApi.js | 43 +++++++++++------------ 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/components/skills-list/skills-list.js b/src/components/skills-list/skills-list.js index dd52f272..be05ef0c 100644 --- a/src/components/skills-list/skills-list.js +++ b/src/components/skills-list/skills-list.js @@ -5,6 +5,14 @@ const SkillsList = ({ crmData }) => { const intermediateSkills = crmData?.skills?.intermediateSkills ?? []; const advancedSkills = crmData?.skills?.advancedSkills ?? []; + const SkillLink = ({ skill }) => { + return skill.marketingPageUrl ? ( + {skill.service} + ) : ( + {skill.service} + ); + }; + return ( <> {((advancedSkills && !!advancedSkills.length) || @@ -14,7 +22,7 @@ const SkillsList = ({ crmData }) => { {advancedSkills.map((skill, i, arr) => ( - {skill.service} + {(i !== arr.length - 1 || (i === arr.length - 1 && intermediateSkills.length > 0)) && ( | @@ -23,7 +31,7 @@ const SkillsList = ({ crmData }) => { ))} {intermediateSkills.map((skill, i, arr) => ( - {skill.service} + {i !== arr.length - 1 && ( | )} @@ -39,6 +47,7 @@ const SkillsList = ({ crmData }) => { SkillsList.propTypes = { crmData: PropTypes.object.isRequired, + skill: PropTypes.object.isRequired, }; export default SkillsList; diff --git a/src/helpers/CRMApi.js b/src/helpers/CRMApi.js index a5f1587e..da125ff1 100644 --- a/src/helpers/CRMApi.js +++ b/src/helpers/CRMApi.js @@ -61,28 +61,27 @@ const getUsersSkills = async () => { }); const usersSkillsReq = await axios.get(`${crmUrl}/ssw_userskills`); - const usersSkills = usersSkillsReq.data.value - .map((us) => { - const skill = skills.find((s) => s.ssw_skillid === us._ssw_skillid_value); - const marketingPage = - skill?.[ - '_ssw_marketingpage_value@OData.Community.Display.V1.FormattedValue' - ] ?? ''; - - const userSkill = { - userId: us._ssw_systemuserid_value, - experienceLevel: getExperienceLevel(us.ssw_level), - sortOrder: us.ssw_sortorder || null, - technology: skill?.ssw_name ?? '', - marketingPage, - marketingPageUrl: consultingPages[marketingPage], - published: - skill?.['statuscode@OData.Community.Display.V1.FormattedValue'] ?? '', - }; - - return userSkill; - }) - .filter((us) => us.published === 'Published'); + const usersSkills = usersSkillsReq.data.value.map((us) => { + const skill = skills.find((s) => s.ssw_skillid === us._ssw_skillid_value); + const marketingPage = + skill?.[ + '_ssw_marketingpage_value@OData.Community.Display.V1.FormattedValue' + ] ?? ''; + + const userSkill = { + userId: us._ssw_systemuserid_value, + experienceLevel: getExperienceLevel(us.ssw_level), + sortOrder: us.ssw_sortorder || null, + technology: skill?.ssw_name ?? '', + marketingPage, + marketingPageUrl: consultingPages[marketingPage], + published: + skill?.['statuscode@OData.Community.Display.V1.FormattedValue'] ?? '', + }; + + return userSkill; + }); + // .filter((us) => us.published === 'Published'); return usersSkills; };