Skip to content

Commit

Permalink
Fix case with no coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Feb 10, 2023
1 parent 599b122 commit 6a67083
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/components/ItemView/Datasets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,24 @@ const Datasets = (props) => {
}

const datasets = children.map((v, e) => {
const tc = v.resourceTemporalExtentDetails[0];
const { start, end } = tc || {};
const tc_start = start?.date
? new Date(Date.parse(start.date)).getFullYear()
: '';
const tc_end = end?.date
? new Date(Date.parse(end.date)).getFullYear()
: '';

let date;
if (tc_start === tc_end) {
date = tc_start;

if (v.resourceTemporalExtentDetails) {
const tc = v.resourceTemporalExtentDetails[0];
const { start, end } = tc || {};
const tc_start = start?.date
? new Date(Date.parse(start.date)).getFullYear()
: '';
const tc_end = end?.date
? new Date(Date.parse(end.date)).getFullYear()
: '';
if (tc_start === tc_end) {
date = tc_start;
} else {
date = tc_start + '-' + tc_end;
}
} else {
date = tc_start + '-' + tc_end;
date = '';
}

return Object.assign({ temporalDateRange: date, ...v }, e);
Expand All @@ -314,9 +318,7 @@ const Datasets = (props) => {

const panes = (groupedDatasets || []).map((item, i) => ({
menuItem: (
<Menu.Item key="location">
<span>{item.date}</span>
</Menu.Item>
<Menu.Item>{item.date ? <span>{item.date}</span> : 'No date'}</Menu.Item>
),
render: () => (
<Tab.Pane>
Expand Down

0 comments on commit 6a67083

Please sign in to comment.