Skip to content
Snippets Groups Projects
ArchiveDetails.js 2.57 KiB
Newer Older
Zheng Meyer's avatar
Zheng Meyer committed
import React, { useContext } from "react";
import { useParams } from "react-router-dom";
import { GlobalContext } from "../../contexts/GlobalContext";
import {
  Container,
  Row,
  Col,
  Card,
  Table,
  Alert,
  Image,
} from "react-bootstrap";
Zheng Meyer's avatar
Zheng Meyer committed
import DataProductCategories from "./DataProductCategories";

export default function ArchiveDetails(props) {
  const { uri } = useParams();
  console.log(uri);
  const { archives } = useContext(GlobalContext);
Zheng Meyer's avatar
Zheng Meyer committed
  if (!archives) return null;

  const archive = archives.find((archive) => archive.uri === uri);
  if (!archive) return <Alert variant="danger">No Archive found!</Alert>;
  console.log(archive);

  return (
Zheng Meyer's avatar
Zheng Meyer committed
      <Container fluid>
        <Row>
          <h2 className="ml-3">Archive - {archive.name}</h2>
        </Row>

        <Row>
Zheng Meyer's avatar
Zheng Meyer committed
            <Card className="card-description">
              <Card.Body>
Hugh Dickinson's avatar
Hugh Dickinson committed
                <Table bordered hover fluid="true" size="sm">
Zheng Meyer's avatar
Zheng Meyer committed
                  <tbody>
                    <tr>
                      <td className="key">Instrument</td>
                      <td className="value">{archive.instrument}</td>
                    </tr>
                    <tr>
                      <td className="key">Description</td>
                      <td className="value">{archive.short_description}</td>
                    </tr>
                  </tbody>
                </Table>
                  <Image
                    className="mx-auto d-block"
                    src={archive.thumbnail}
                    alt=""
                    rounded
                    fluid
                  />
                  <Card.Title className="text-center h4 pt-3">
                    {archive.short_description}
                  </Card.Title>
                  <Card.Text className="text-justify m-3">
                    {archive.long_description}
                  </Card.Text>
Zheng Meyer's avatar
Zheng Meyer committed
              </Card.Body>
            </Card>
          </Col>
Hugh Dickinson's avatar
Hugh Dickinson committed
          <Col fluid="true">
Zheng Meyer's avatar
Zheng Meyer committed
            <Row>
              <Col>
                <Card className="card-description">
                  <Card.Body>
                    <Card.Title>Data Retrieval</Card.Title>
                    <Card.Text>{archive.retrieval_description}</Card.Text>
                  </Card.Body>
                </Card>
              </Col>
            </Row>
Zheng Meyer's avatar
Zheng Meyer committed
              <Col>
                <DataProductCategories archive={archive} />
              </Col>
            </Row>
          </Col>
        </Row>
      </Container>
Zheng Meyer's avatar
Zheng Meyer committed
  );
}