diff --git a/src/modules/records/components/RecordDescription/index.js b/src/modules/records/components/RecordDescription/index.js deleted file mode 100644 index 3db4ef92..00000000 --- a/src/modules/records/components/RecordDescription/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import { getField, getFieldValue } from '../../utilities'; -import PropTypes from 'prop-types'; -import React from 'react'; - -const RecordDescription = ({ record }) => { - const descField = getField(record.fields, 'abstract') || getField(record.fields, 'description'); - const [description] = getFieldValue(descField); - - if (!description) { - return null; - } - - return

; -}; - -RecordDescription.propTypes = { - record: PropTypes.object -}; - -export default RecordDescription; diff --git a/src/modules/records/components/RecordFull/index.js b/src/modules/records/components/RecordFull/index.js index 15a5c725..81f8dc0c 100644 --- a/src/modules/records/components/RecordFull/index.js +++ b/src/modules/records/components/RecordFull/index.js @@ -10,7 +10,6 @@ import { FullRecordPlaceholder, Metadata, RecommendedResource, - RecordDescription, RecordFullFormats, ViewMARC, Zotero @@ -31,25 +30,25 @@ let prejudiceInstance = prejudice.createVariableStorageDriverInstance(); const FullRecord = () => { const [activeAction, setActiveAction] = useState(''); - const params = useParams(); + const { recordUid } = useParams(); const navigate = useNavigate(); - const record = useSelector((state) => { - return state.records.record; + const { record } = useSelector((state) => { + return state.records; }); - const datastores = useSelector((state) => { + const { active: datastoreUid, datastores } = useSelector((state) => { return state.datastores; }); - const list = useSelector((state) => { - return state.lists[datastores.active]; + const { [datastoreUid]: list } = useSelector((state) => { + return state.lists; }); - const { recordUid } = params; - const datastoreUid = datastores.active; - const datastore = findWhere(datastores.datastores, { + const datastore = findWhere(datastores, { uid: datastoreUid }); + const { name: datastoreName, slug: datastoreSlug } = datastore; + useEffect(() => { requestRecord({ datastoreUid, recordUid }); prejudiceInstance = prejudice.createVariableStorageDriverInstance(); @@ -67,23 +66,23 @@ const FullRecord = () => { // Treat as an aleph id navigate(`/onlinejournals/record/${record.uid}`); } else if (record.alt_ids.includes(recordUid)) { - navigate(`/${datastore.slug}/record/${record.uid}`); + navigate(`/${datastoreSlug}/record/${record.uid}`); } else { requestRecord({ datastoreUid, recordUid }); } } - const activeDatastore = findWhere(datastores.datastores, { - uid: datastores.active + const { name: activeDatastore } = findWhere(datastores, { + uid: datastoreUid }); setDocumentTitle([ [].concat(record.names).join().slice(0, 120), 'Record', - activeDatastore.name + activeDatastore ]); } - }, [record, recordUid, datastores, navigate, datastore.slug, datastoreUid]); + }, [record, recordUid, datastores, navigate, datastoreSlug]); if (!record) { return ( @@ -91,8 +90,8 @@ const FullRecord = () => { { if (recordUidValue !== recordUid) { return (

- +
); } - const inDatastore = ['catalog', 'onlinejournals'].includes(datastore.slug); + const [description] = getFieldValue(getField(record.fields, 'abstract') || getField(record.fields, 'description')); + + const inDatastore = ['catalog', 'onlinejournals'].includes(datastoreSlug); return (
- +
- +

@@ -148,17 +149,17 @@ const FullRecord = () => { ); } return ( - + ); })} - +

- +
- - + {description &&

} +

Record info:

- + {inDatastore && (

The University of Michigan Library aims to describe its collections in a way that respects the people and communities who create, use, and are represented in them. We encourage you to @@ -178,10 +179,10 @@ const FullRecord = () => { Available at:

- +
- {datastoreUid === 'mirlyn' && } + {datastoreUid === 'mirlyn' && }

Actions @@ -190,26 +191,27 @@ const FullRecord = () => { Select what to do with this record.

-
{inDatastore && (() => { - const indexingDate = findWhere(record.fields, { uid: 'indexing_date' }); - if (!indexingDate) { + const { name: indexingName, value: indexingValue } = findWhere(record.fields, { uid: 'indexing_date' }); + if (!indexingValue) { return null; } return (

- {indexingDate.name}: {indexingDate.value} + {indexingName || 'Date Last Indexed'}: {indexingValue}

); })()} - {datastoreUid === 'mirlyn' && } + {datastoreUid === 'mirlyn' && }
); }; diff --git a/src/modules/records/components/ViewMARC/index.js b/src/modules/records/components/ViewMARC/index.js index 815d3320..ad24a22e 100644 --- a/src/modules/records/components/ViewMARC/index.js +++ b/src/modules/records/components/ViewMARC/index.js @@ -3,9 +3,9 @@ import React, { useState } from 'react'; import MARCTable from '../MARCTable'; import PropTypes from 'prop-types'; -const ViewMARC = ({ record }) => { +const ViewMARC = ({ fields }) => { const [view, setView] = useState(false); - const [marc] = getFieldValue(getField(record.fields, 'marc_record')); + const [marc] = getFieldValue(getField(fields, 'marc_record')); if (marc) { if (view) { @@ -30,7 +30,7 @@ const ViewMARC = ({ record }) => { }; ViewMARC.propTypes = { - record: PropTypes.object.isRequired + fields: PropTypes.array.isRequired }; export default ViewMARC; diff --git a/src/modules/records/index.js b/src/modules/records/index.js index 32f9aa60..b0696f32 100644 --- a/src/modules/records/index.js +++ b/src/modules/records/index.js @@ -18,7 +18,6 @@ import Metadata from './components/Metadata'; import Pagination from './components/Pagination'; import RecommendedResource from './components/RecommendedResource'; import Record from './components/Record'; -import RecordDescription from './components/RecordDescription'; import RecordFull from './components/RecordFull'; import RecordFullFormats from './components/RecordFullFormats'; import RecordList from './components/RecordList'; @@ -43,7 +42,6 @@ export { Pagination, RecommendedResource, Record, - RecordDescription, RecordFull, RecordFullFormats, RecordList,