diff --git a/src/components/cost.tsx b/src/components/cost.tsx index b726dae..ffb631b 100644 --- a/src/components/cost.tsx +++ b/src/components/cost.tsx @@ -1,6 +1,7 @@ -import { VmCostPlan } from "../api"; +interface Price { currency: string, amount: number } +type Cost = Price & { interval_type?: string, other_price?: Array } -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)} - +
+ {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 =>
+ +
)} +
); }