CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/billing/invoice-history.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Virtuoso } from "react-virtuoso";
7
import { Panel } from "@cocalc/frontend/antd-bootstrap";
8
import { Icon, Loading } from "@cocalc/frontend/components";
9
import { Invoice } from "./invoice";
10
import { InvoicesMap, InvoiceMap } from "./types";
11
12
interface Props {
13
invoices?: InvoicesMap;
14
}
15
16
export default function InvoiceHistory({ invoices }: Props) {
17
return (
18
<Panel
19
header={
20
<span>
21
<Icon name="list-alt" /> Invoices and receipts
22
</span>
23
}
24
>
25
{invoices == null ? (
26
<Loading />
27
) : (
28
<div className={"smc-vfill"} style={{ height: "300px" }}>
29
<Virtuoso
30
totalCount={invoices.get("data").size}
31
itemContent={(index) => {
32
const invoice = invoices?.getIn(["data", index]);
33
if (invoice == null) {
34
// shouldn't happen
35
return <div style={{ height: "1px" }}></div>;
36
}
37
// LHS and RHS agree on type tooltip yet it errors without "as"
38
return (
39
<Invoice
40
key={invoice.get("id")}
41
invoice={invoice as InvoiceMap}
42
/>
43
);
44
}}
45
/>
46
</div>
47
)}
48
</Panel>
49
);
50
}
51
52