diff --git a/src/layout/FormFields.component.js b/src/layout/FormFields.component.js index b3cc44f1..45f91315 100644 --- a/src/layout/FormFields.component.js +++ b/src/layout/FormFields.component.js @@ -17,7 +17,7 @@ import userSettingsKeyMapping from '../userSettingsMapping.js' import AvatarEditor from './AvatarEditor.component.js' import AppTheme from './theme.js' import { VerifyEmail } from './VerifyEmail.component.js' -import VerifyEmailWarning from './VerifyEmailWarning.js' +import { VerifyEmailWarning } from './VerifyEmailWarning.js' const styles = { header: { diff --git a/src/layout/VerifyEmailWarning.js b/src/layout/VerifyEmailWarning.js index 06af578f..cbe3ab09 100644 --- a/src/layout/VerifyEmailWarning.js +++ b/src/layout/VerifyEmailWarning.js @@ -1,15 +1,16 @@ -import { useDataQuery } from '@dhis2/app-runtime' import i18n from '@dhis2/d2-i18n' import { NoticeBox } from '@dhis2/ui' +import PropTypes from 'prop-types' import React from 'react' -const VerifyEmailWarning = ({ config }) => { - const enforceVerifiedEmail = config.system.settings.settings.enforceVerifiedEmail - const emailVerified = config.currentUser.emailVerified +export function VerifyEmailWarning({ config }) { + const enforceVerifiedEmail = + config?.system?.settings?.enforceVerifiedEmail || false + const emailVerified = config?.currentUser?.emailVerified || false if (enforceVerifiedEmail && !emailVerified) { return ( -
+
{i18n.t( 'Your email is not verified. Please verify your email to continue using the system.' @@ -22,4 +23,15 @@ const VerifyEmailWarning = ({ config }) => { return null } -export default VerifyEmailWarning +VerifyEmailWarning.propTypes = { + config: PropTypes.shape({ + currentUser: PropTypes.shape({ + emailVerified: PropTypes.bool, + }), + system: PropTypes.shape({ + settings: PropTypes.shape({ + enforceVerifiedEmail: PropTypes.bool, + }), + }), + }).isRequired, +}