diff --git a/src/components/Layout/UserWarnings/index.tsx b/src/components/Layout/UserWarnings/index.tsx index 42c0a3ccc..6128040bb 100644 --- a/src/components/Layout/UserWarnings/index.tsx +++ b/src/components/Layout/UserWarnings/index.tsx @@ -17,47 +17,45 @@ interface UserWarningsProps { const UserWarnings: React.FC = ({ onClick }) => { const intl = useIntl(); const { user } = useUser(); - if (!user) { + //check if a user has warnings + if (!user || !user.warnings || user.warnings.length === 0) { return null; } let res = null; - //check if a user has warnings - if (user.warnings.length > 0) { - user.warnings.forEach((warning) => { - let link = ''; - let warningText = ''; - let warningTitle = ''; - switch (warning) { - case 'userEmailRequired': - link = '/profile/settings/'; - warningTitle = 'Profile is incomplete'; - warningText = intl.formatMessage(messages.emailRequired); - } + user.warnings.forEach((warning) => { + let link = ''; + let warningText = ''; + let warningTitle = ''; + switch (warning) { + case 'userEmailRequired': + link = '/profile/settings/'; + warningTitle = 'Profile is incomplete'; + warningText = intl.formatMessage(messages.emailRequired); + } - res = ( - { - if (e.key === 'Enter' && onClick) { - onClick(); - } - }} - role="button" - tabIndex={0} - className="mx-2 mb-2 flex items-center rounded-lg bg-yellow-500 p-2 text-xs text-white ring-1 ring-gray-700 transition duration-300 hover:bg-yellow-400" - > - -
- {warningTitle} - {warningText} -
- - ); - }); - } + res = ( + { + if (e.key === 'Enter' && onClick) { + onClick(); + } + }} + role="button" + tabIndex={0} + className="mx-2 mb-2 flex items-center rounded-lg bg-yellow-500 p-2 text-xs text-white ring-1 ring-gray-700 transition duration-300 hover:bg-yellow-400" + > + +
+ {warningTitle} + {warningText} +
+ + ); + }); return res; };