Card.tsx 2.16 KB
Newer Older
1 2 3 4 5 6 7 8
import * as React from 'react';
import { translate } from 'react-i18next';

import Dataset from 'model/catalog/Dataset';

import Card, { CardHeader, CardContent } from 'ui/common/Card';
import { Link } from 'react-router-dom';

Matija Obreza's avatar
Matija Obreza committed
9
import Markdown from 'ui/common/markdown';
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
import { PartnerLink } from 'ui/catalog/Links';
import { Properties, PropertiesItem } from 'ui/common/Properties';
import CropChips from 'crop/ui/c/CropChips';
import McpdDate from 'ui/common/time/McpdDate';

interface IDatasetCardProps extends React.ClassAttributes<any> {
  className?: string;
  dataset: Dataset;
  t: any;
}

class DatasetCard extends React.Component<IDatasetCardProps, any> {

  public render() {
    const { dataset, className, t } = this.props;

    if (!dataset) {
      return null;
    }

    return (
      <Card className={ className } square>
        <CardHeader
          title={
            (
              <Link to={ '/datasets/' + dataset.uuid }>
                <Markdown basic source={ dataset.title }/>
              </Link>
            )
          }
        />
        <CardContent>
          <Markdown className="pb-20" firstParagraph source={ dataset.description }/>
          <Properties>
            <PropertiesItem title={ t('partners.common.modelName') }>
              <PartnerLink to={ dataset.owner }/>
            </PropertiesItem>
            { dataset.crops && dataset.crops.length > 0 &&
            <PropertiesItem title={ t('crop.common.modelName') }>
              <CropChips crops={ dataset.crops }/>
            </PropertiesItem>
            }
            <PropertiesItem title={ t('datasets.public.c.card.evaluationPeriod') }>
              <McpdDate value={ dataset.startDate }/> &mdash; <McpdDate value={ dataset.endDate }/>
            </PropertiesItem>
            <PropertiesItem title={ t('datasets.public.common.accessionsNumber') }>
              { dataset.accessionCount }
            </PropertiesItem>
            <PropertiesItem title={ t('datasets.public.common.traitsNumber') }>
              { dataset.descriptorCount }
            </PropertiesItem>
          </Properties>
        </CardContent>
      </Card>
    );
  }
}

export default translate()(DatasetCard);