GitLab will be in maintenance on October the 8th from 18:00 CET until 23:59 CET.

Skip to content
Snippets Groups Projects
Select Git revision
  • 862ca8f1b16120e83fa97a6cb16471c97889989c
  • main default protected
  • 65_async_query
  • 169_codemeta
  • issue/152_cleaning_up
  • adex-main protected
  • sdc380-aladin-cone-search
  • sdc-222_multi_archive_query_review
  • 69_add_diracIAM
  • dev-nico
  • dev-dirac
  • acceptance
  • dev-zooniverse
13 results

MyBasketPage.js

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    MyBasketPage.js 1.57 KiB
    import React, { useEffect, useContext } from "react";
    import { Table, Container, Alert } from "react-bootstrap";
    
    import { BasketContext } from "../../contexts/BasketContext";
    import { GlobalContext } from "../../contexts/GlobalContext";
    import AddToBasket from "./AddToBasketCheckBox";
    import APIButton from "./APIButton"
    import EmptyBasketButton from "./EmptyBasketButton"
    
    export default function MyBasketPage() {
        const { api_host, isAuthenticated } = useContext(GlobalContext);
        const basketContext = useContext(BasketContext);
    
        let items = basketContext.datasets
        if (!items) {
            return null
        }
    
        // parse the items and build a line to display
        let my_list = items.map((item, index) => {
            let id = `${index}`
            let archive = item.archive
            let item_as_string = JSON.stringify(item)
    
            return <tr>
                <td>
                    <AddToBasket id={id} item={item} label=""/>
                </td>
                <td>{archive}</td>
                <td>{item_as_string}</td>
            </tr>
        })
    
        return (
            <>
            <Container fluid>
                &nbsp;
                <h3>Data Checkout &nbsp;&nbsp; <EmptyBasketButton/> <APIButton/></h3>
    
                <Table className="mt-3" responsive>
                    <thead>
    
                    <tr className="bg-light">
                        <th>Basket</th>
                        <th>Source</th>
                        <th>Item</th>
                    </tr>
    
                    </thead>
                    <tbody>
                    {my_list}
                    </tbody>
    
                </Table>
    
            </Container>
            </>
        );
    }