Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/usage/UsageSummary.tsx
2499 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { FC } from "react";
8
import { useCurrentOrg } from "../data/organizations/orgs-query";
9
import { Subheading } from "../components/typography/headings";
10
import { Link } from "react-router-dom";
11
import { useOrgBillingMode } from "../data/billing-mode/org-billing-mode-query";
12
import { useIsOwner } from "../data/organizations/members-query";
13
14
type Props = {
15
creditsUsed?: number;
16
};
17
export const UsageSummaryData: FC<Props> = ({ creditsUsed }) => {
18
const currentOrg = useCurrentOrg();
19
const isOwner = useIsOwner();
20
const { data: billingMode } = useOrgBillingMode();
21
22
return (
23
<div className="flex flex-row">
24
<div className="mt-8 p-3 flex flex-col">
25
<Subheading>Credits Consumed</Subheading>
26
<div className="flex text-lg text-gray-600 font-semibold">
27
<span className="dark:text-gray-400">
28
{creditsUsed !== undefined ? creditsUsed.toLocaleString() : "-"}
29
</span>
30
</div>
31
{currentOrg.data && isOwner && billingMode?.mode === "usage-based" && (
32
<div className="flex text-xs text-gray-600">
33
<span className="dark:text-gray-500 text-gray-400">
34
<Link to="/billing" className="gp-link">
35
View Billing →
36
</Link>
37
</span>
38
</div>
39
)}
40
</div>
41
</div>
42
);
43
};
44
45