Path: blob/master/src/packages/frontend/compute/current-cost.tsx
1503 views
import { STATE_INFO } from "@cocalc/util/db-schema/compute-servers";1import { Tooltip } from "antd";2import { currency, round4 } from "@cocalc/util/misc";34export default function CurrentCost({ state, cost_per_hour }) {5const { color, stable } = STATE_INFO[state ?? "off"] ?? {};6let cost;7if (cost_per_hour == null) {8cost = ""; // no info9} else if (stable) {10if (state == "deprovisioned") {11cost = "";12} else {13const cost_per_month = `${currency(cost_per_hour * 730)}`;14cost = (15<Tooltip16title={() => (17<>18Cost per hour (USD): ${round4(cost_per_hour)}19<br /> Cost per month (USD): {cost_per_month}20</>21)}22placement="right"23>24<span style={{ textWrap: "nowrap" }}>25{currency(cost_per_hour)}/hour26</span>27</Tooltip>28);29}30}3132return <span style={{ color, textWrap: "nowrap" }}>{cost}</span>;33}343536