diff --git a/src/modules/core/components/SearchHeader/index.js b/src/modules/core/components/SearchHeader/index.js index e193574f..9304cc5f 100644 --- a/src/modules/core/components/SearchHeader/index.js +++ b/src/modules/core/components/SearchHeader/index.js @@ -6,15 +6,15 @@ import React from 'react'; import { useSelector } from 'react-redux'; const SearchHeader = () => { - const isAuthenticated = useSelector((state) => { - return state.profile.status === 'Logged in'; + const { status } = useSelector((state) => { + return state.profile || {}; }); return ( diff --git a/src/modules/datastores/components/FlintAlerts/index.js b/src/modules/datastores/components/FlintAlerts/index.js index 5d52c17d..ba7b8b49 100644 --- a/src/modules/datastores/components/FlintAlerts/index.js +++ b/src/modules/datastores/components/FlintAlerts/index.js @@ -2,7 +2,7 @@ import { Alert, Anchor } from '../../../reusable'; import React, { useState } from 'react'; import PropTypes from 'prop-types'; -const FlintAlerts = ({ datastore, profile }) => { +const FlintAlerts = ({ datastore, institutions = [] }) => { const [dismiss, setDismiss] = useState([]); const handleDismissClick = () => { setDismiss((previousDismiss) => { @@ -16,7 +16,7 @@ const FlintAlerts = ({ datastore, profile }) => { website: (<>We noticed you are affiliated with U-M Flint. For the best results use the Thompson Library website.) }; - if (!Object.keys(messages).includes(datastore) || !profile.institutions?.includes('Flint') || dismiss.includes(datastore)) { + if (!Object.keys(messages).includes(datastore) || !institutions.includes('Flint') || dismiss.includes(datastore)) { return null; } @@ -37,7 +37,7 @@ const FlintAlerts = ({ datastore, profile }) => { FlintAlerts.propTypes = { datastore: PropTypes.string, - profile: PropTypes.object + institutions: PropTypes.array }; export default FlintAlerts; diff --git a/src/modules/lists/components/ActionsList/index.js b/src/modules/lists/components/ActionsList/index.js index bb116f41..2059e56b 100644 --- a/src/modules/lists/components/ActionsList/index.js +++ b/src/modules/lists/components/ActionsList/index.js @@ -50,8 +50,8 @@ const actions = [ const ActionsList = (props) => { const [alert, setAlert] = useState(null); - const profile = useSelector((state) => { - return state.profile; + const { email, status, text } = useSelector((state) => { + return state.profile || {}; }); return ( @@ -85,19 +85,19 @@ const ActionsList = (props) => { })} {props.active?.action === 'email' && ( - + )} {props.active?.action === 'text' && ( - + diff --git a/src/modules/pages/components/DatastorePage/index.js b/src/modules/pages/components/DatastorePage/index.js index 786627f3..69336999 100644 --- a/src/modules/pages/components/DatastorePage/index.js +++ b/src/modules/pages/components/DatastorePage/index.js @@ -37,8 +37,8 @@ const DatastorePage = () => { const institution = useSelector((state) => { return state.institution; }); - const profile = useSelector((state) => { - return state.profile; + const { institutions } = useSelector((state) => { + return state.profile || {}; }); const search = useSelector((state) => { return state.search; @@ -94,7 +94,7 @@ const DatastorePage = () => { <> - + { /> } + element={} /> { Pride.init({ failure: () => { renderPrideFailedToLoad(); - // Console.log('Pride failed to load.'); }, - success: () => { - setupSearches(); - setupAdvancedSearch(); - setupDefaultInstitution(); - setupDefaultAffiliation(); - setupBrowse(); + success: async () => { + await setupSearches(); + await setupAdvancedSearch(); + await setupDefaultInstitution(); + await setupDefaultAffiliation(); + await setupBrowse(); + await prejudice.initialize(); + await setupProfile(); renderApp(); - prejudice.initialize(); - setupProfile(); } }); }; diff --git a/src/modules/profile/components/AuthenticationRequired/index.js b/src/modules/profile/components/AuthenticationRequired/index.js index cf37656a..6d0f24ab 100644 --- a/src/modules/profile/components/AuthenticationRequired/index.js +++ b/src/modules/profile/components/AuthenticationRequired/index.js @@ -2,12 +2,12 @@ import Authentication from '../Authentication'; import PropTypes from 'prop-types'; import React from 'react'; -const AuthenticationRequired = ({ children, profile }) => { +const AuthenticationRequired = ({ children, status }) => { if (!children) { return null; } - if (profile?.status === 'Logged in') { + if (status === 'Logged in') { return children; } @@ -23,7 +23,7 @@ AuthenticationRequired.propTypes = { PropTypes.arrayOf(PropTypes.node), PropTypes.node ]), - profile: PropTypes.object + status: PropTypes.string }; export default AuthenticationRequired;