From b9bf5416c460c14b5fe56321f0c3009ccb561cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Mar=C3=ADn=20S=C3=A1nchez?= <46426271+fermarinsanchez@users.noreply.github.com> Date: Fri, 24 May 2024 12:35:08 +0200 Subject: [PATCH] refactor(components): unified user name positions to `[surname, ]` Ticket: issue/Transversal-196 Reviewed-by: @MIGUELez11 Refs: #158 --- packages/components/src/helpers/getUserFullName.js | 8 +++----- .../src/informative/UserDisplayItem/UserDisplayItem.js | 5 ++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/components/src/helpers/getUserFullName.js b/packages/components/src/helpers/getUserFullName.js index 3b02dea2a..8a9bec421 100644 --- a/packages/components/src/helpers/getUserFullName.js +++ b/packages/components/src/helpers/getUserFullName.js @@ -1,9 +1,7 @@ function getUserFullName(user) { - return ( - (user.name ? user.name : '') + - (user.surnames ? ` ${user.surnames}` : '') + - (user.secondSurname ? ` ${user.secondSurname}` : '') - ); + return `${user.secondSurname ? `${user.secondSurname} ` : ''}${ + user.surnames ? user.surnames : '' + }${user.secondSurname || user.surnames ? ', ' : ''}${user.name}`; } export { getUserFullName }; diff --git a/packages/components/src/informative/UserDisplayItem/UserDisplayItem.js b/packages/components/src/informative/UserDisplayItem/UserDisplayItem.js index c7cfcab49..622c7bee5 100644 --- a/packages/components/src/informative/UserDisplayItem/UserDisplayItem.js +++ b/packages/components/src/informative/UserDisplayItem/UserDisplayItem.js @@ -84,7 +84,10 @@ const UserDisplayItem = (properties) => { const role = useMemo(() => (!isEmpty(center) ? `${rol} ยท ${center}` : rol), [rol, center]); const fullName = useMemo( - () => (['rol', 'inline'].includes(variant) ? `${surnames || ''} ${name}` : name), + () => + ['rol', 'inline'].includes(variant) + ? `${surnames || ''}${!surnames ? '' : ', '}${name}` + : name, [name, surnames, variant], );