Commit 31aa7603 authored by Matija Obreza's avatar Matija Obreza
Browse files

Introducing AccessionRefCard

- Renders AccessionCard when reference exists
parent 6080aa00
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import Accession from 'model/accession/Accession';
import Card, { CardContent, CardActions } from 'ui/common/Card';
import DOI from 'ui/common/DOI';
import SciName from 'ui/genesys/SciName';
import { AccessionRef } from 'model/accession/AccessionRef';
import AccessionCard from './AccessionCard';
const styles = (theme) => ({
firstRow: {
marginBottom: '1em',
},
accessionRef: {
background: 'white', // '#c9e2cb',
},
});
const AccessionRefCard = ({ accessionRef, classes, index }:
{ accessionRef: AccessionRef, classes: any, index?: number} & React.ClassAttributes<any>) => {
const accession: Accession = accessionRef.accession;
if (accession) {
return <AccessionCard accession={ accession } index={ index } />;
}
return (
<Card className={ classes.accessionRef }>
<CardContent>
<div className={ classes.firstRow }>
<b>
{ index !== undefined && `${index + 1}. ` }
{ accessionRef.acceNumb }
{ ` • ` }
<SciName taxa={ accessionRef.genus } />
</b>
</div>
<div>
{ accessionRef.instCode }
{ ` • ` }
{ ` DOI: ` }
{ accessionRef.doi && <DOI noPrefix value={ accessionRef.doi } /> || 'N/A' }
</div>
</CardContent>
{ false &&
<CardActions>
Actions
</CardActions>
}
</Card>
);
};
export default withStyles(styles)(AccessionRefCard);
......@@ -36,7 +36,7 @@ import CropChips from 'crop/ui/c/CropChips';
import Card, { CardHeader, CardContent, CardActions } from 'ui/common/Card';
import McpdDate from 'ui/common/time/McpdDate';
import PagedLoader from 'ui/common/PagedLoader';
import AccessionCard from 'accessions/ui/c/AccessionCard';
import AccessionRefCard from 'accessions/ui/c/AccessionRefCard';
const styles = (theme) => ({
root: {
......@@ -236,11 +236,12 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
}
const renderAccession = (accessionRef: AccessionRef, index: number) => (
<Grid key={ accessionRef.accession.uuid } item xs={ 12 } className="pt-5 pb-5 pr-10 pl-10">
<AccessionCard index={ index } accession={ accessionRef.accession }/>
<Grid key={ `aref-${index}` } item xs={ 12 } className="pt-5 pb-5 pr-10 pl-10">
<AccessionRefCard index={ index } accessionRef={ accessionRef }/>
</Grid>
);
console.log(`AccessionRefs`, accessionRefs);
const license = dataset.rights && AVAILABLE_LICENSES.find((e) => e.code === dataset.rights);
const oneDay = 24 * 60 * 60 * 1000;
const oneDayPassed = dataset && (fixDate(dataset.lastModifiedDate).getTime() <= (new Date()).getTime() - oneDay);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment