Newer
Older

Nico Vermaas
committed
import React, { useState, useEffect, useContext } from "react";
import { Table, Container, Alert } from "react-bootstrap";
import { BasketContext } from "../../contexts/BasketContext";
import { GlobalContext } from "../../contexts/GlobalContext";

Nico Vermaas
committed
import { QueryContext } from "../../contexts/QueryContext";
import AddToBasket from "./AddToBasketCheckBox";
import APIButton from "./APIButton"
import EmptyBasketButton from "./EmptyBasketButton"

Nico Vermaas
committed
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
import { renderRowApertif, renderHeaderApertif } from "../services/layout/ApertifResultsLayout"
import { renderRowAstronVO, renderHeaderAstronVO } from "../services/layout/AstronVOLayout"
function renderRow(item) {
switch(item.archive) {
case 'apertif':
return <div>
<Table className="mt-3" size="sm" responsive>
<thead>
<tr className="bg-light">
{renderHeaderApertif()}
</tr>
</thead>
<tbody>
{renderRowApertif((item.record))}
</tbody>
</Table>
</div>
case 'astron_vo':
return <div>
<Table className="mt-3" size="sm" responsive>
<thead>
<tr className="bg-light">
{renderHeaderAstronVO()}
</tr>
</thead>
<tbody>
{renderRowAstronVO((item.record))}
</tbody>
</Table>
</div>
default:
return JSON.stringify(item)
}
}
export default function MyBasketPage() {
const { api_host, isAuthenticated } = useContext(GlobalContext);
const basketContext = useContext(BasketContext);

Nico Vermaas
committed
const { preview } = useContext(QueryContext);

Nico Vermaas
committed

Nico Vermaas
committed
// work on a local copy of datasets, to be able (un)(re)select items before saving
const [items, setItems] = useState(basketContext.datasets);
if (!items) {

Nico Vermaas
committed
//if (items.length === basketContext.datasets.length) {
// basketContext.changed(false)
//}
// parse the items and build a line to display
let my_list = items.map((item, index) => {
let id = `${index}`

Nico Vermaas
committed
return <><tr>
<AddToBasket id={id} item={item} label=""/>

Nico Vermaas
committed
<td>{renderRow(item)}</td>
</tr></>
})
return (
<>
<Container fluid>

Nico Vermaas
committed
<h3>Data Checkout <EmptyBasketButton/> <APIButton/></h3>
<Table className="mt-3" responsive>
<thead>
<tr className="bg-light">
<th>Basket</th>