feat: alt prices
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-10 15:10:47 +00:00
parent 7cba506d6b
commit 57cc619b8c

View File

@ -1,6 +1,7 @@
import { VmCostPlan } from "../api";
interface Price { currency: string, amount: number }
type Cost = Price & { interval_type?: string, other_price?: Array<Price> }
export default function CostLabel({ cost }: { cost: VmCostPlan }) {
export default function CostLabel({ cost, converted }: { cost: Cost, converted?: boolean }) {
function intervalName(n: string) {
switch (n) {
case "day":
@ -13,9 +14,15 @@ export default function CostLabel({ cost }: { cost: VmCostPlan }) {
}
return (
<>
{cost.amount.toFixed(2)} {cost.currency}/
{intervalName(cost.interval_type)}
</>
<div>
{converted && "~"}
{cost.currency !== "BTC" ? cost.amount.toFixed(2) : Math.floor(cost.amount * 1e8).toLocaleString()}
{" "}
{cost.currency === "BTC" ? "sats" : cost.currency}
{cost.interval_type && <>/{intervalName(cost.interval_type)}</>}
{cost.other_price && cost.other_price.map(a => <div key={a.currency} className="text-xs">
<CostLabel cost={a} converted={true} />
</div>)}
</div>
);
}