From 30ff9b12024c9da4ff5033cf48b379cd4732f428 Mon Sep 17 00:00:00 2001 From: Tom <20648924+moT01@users.noreply.github.com> Date: Thu, 4 Feb 2021 02:00:48 -0600 Subject: [PATCH] fix: show username on cert if name is private (#40897) Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> --- api-server/server/boot/certificate.js | 12 +++++++++++- client/src/client-only-routes/ShowCertification.js | 12 +++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/api-server/server/boot/certificate.js b/api-server/server/boot/certificate.js index e268168cdc..67f680a5ed 100644 --- a/api-server/server/boot/certificate.js +++ b/api-server/server/boot/certificate.js @@ -423,7 +423,7 @@ function createShowCert(app) { ] }); } - const { isLocked, showCerts } = user.profileUI; + const { isLocked, showCerts, showName } = user.profileUI; if (!user.name) { return res.json({ @@ -512,6 +512,16 @@ function createShowCert(app) { } const { username, name } = user; + + if (!showName) { + return res.json({ + certTitle, + username, + date: completedDate, + completionTime + }); + } + return res.json({ certTitle, username, diff --git a/client/src/client-only-routes/ShowCertification.js b/client/src/client-only-routes/ShowCertification.js index 505c713319..c95d5004e4 100644 --- a/client/src/client-only-routes/ShowCertification.js +++ b/client/src/client-only-routes/ShowCertification.js @@ -75,6 +75,9 @@ const propTypes = { ) }) ), + profileUI: PropTypes.shape({ + showName: PropTypes.bool + }), username: PropTypes.string }), userFetchState: PropTypes.shape({ @@ -230,13 +233,16 @@ const ShowCertification = props => { const { date, - name: userFullName, + name: userFullName = null, username, certTitle, completionTime } = cert; + const { user } = props; + const displayName = userFullName ?? username; + const certDate = new Date(date); const certYear = certDate.getFullYear(); const certMonth = certDate.getMonth(); @@ -328,7 +334,7 @@ const ShowCertification = props => {