Skip to content

Commit

Permalink
Merge pull request #88 from aodn/features/add-metadata-identifer#5659
Browse files Browse the repository at this point in the history
🎨 add metadata identifier
  • Loading branch information
utas-raymondng authored Jul 16, 2024
2 parents 23394e5 + a627840 commit 0cb6504
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState } from "react";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { useDetailPageContext } from "../../context/detail-page-context";
import NavigatablePanel from "../components/NavigatablePanel";
import ContactBlock from "../components/ContactBlock";
Expand All @@ -7,14 +7,18 @@ import { convertDateFormat } from "../../../../utils/DateFormatUtils";

const MetadataInformationPanel = () => {
const context = useDetailPageContext();
const metadataId = useMemo(
() => context.collection?.id,
[context.collection?.id]
);
const metadataContact = useMemo(
() =>
context.collection
?.getContacts()
?.filter((contact) => contact.roles.includes("metadata")),
[context.collection]
);
const generateMedatataDateText = () => {
const generateMedatataDateText = useCallback(() => {
let dateText = "";
const temporals = context.collection?.getTemporal();
if (!temporals) {
Expand All @@ -32,9 +36,9 @@ const MetadataInformationPanel = () => {
dateText = dateText + `Revision: ${convertDateFormat(temporal.revision)}`;
}
return dateText;
};
}, [context.collection]);

const dates = useMemo(generateMedatataDateText, [context.collection]);
const dates = useMemo(generateMedatataDateText, [generateMedatataDateText]);

const [isLoading, setIsLoading] = useState(true);

Expand All @@ -59,7 +63,12 @@ const MetadataInformationPanel = () => {
},
{
title: "Metadata Identifier",
component: <div>metadata identifier</div>,
component: (
<PlainTextBlock
title="Metadata Identifier"
texts={metadataId ? [metadataId] : []}
/>
),
},
{
title: "Full Metadata Link",
Expand All @@ -75,7 +84,7 @@ const MetadataInformationPanel = () => {
),
},
],
[dates, metadataContact]
[dates, metadataContact, metadataId]
);
return <NavigatablePanel childrenList={blocks} isLoading={isLoading} />;
};
Expand Down

0 comments on commit 0cb6504

Please sign in to comment.