diff --git a/components/dashboard/src/components/UsageView.tsx b/components/dashboard/src/components/UsageView.tsx
index d27567f54a4813..f866d51e4d7ffc 100644
--- a/components/dashboard/src/components/UsageView.tsx
+++ b/components/dashboard/src/components/UsageView.tsx
@@ -82,15 +82,20 @@ function UsageView({ attributionId, billingMode }: UsageViewProps) {
return "Prebuild";
};
+ const isRunning = (usage: Usage) => {
+ if (usage.kind !== "workspaceinstance") {
+ return false;
+ }
+ const metaData = usage.metadata as WorkspaceInstanceUsageData;
+ return metaData.endTime === "" || metaData.endTime === undefined;
+ };
+
const getMinutes = (usage: Usage) => {
if (usage.kind !== "workspaceinstance") {
return "";
}
const metaData = usage.metadata as WorkspaceInstanceUsageData;
- if (!metaData.endTime) {
- return "running";
- }
- const end = new Date(metaData.endTime).getTime();
+ const end = metaData.endTime ? new Date(metaData.endTime).getTime() : Date.now();
const start = new Date(metaData.startTime).getTime();
const lengthOfUsage = Math.floor(end - start);
const inMinutes = (lengthOfUsage / (1000 * 60)).toFixed(1);
@@ -139,7 +144,12 @@ function UsageView({ attributionId, billingMode }: UsageViewProps) {
return (
<>
-
{errorMessage}
} {!errorMessage && ( @@ -163,29 +173,31 @@ function UsageView({ attributionId, billingMode }: UsageViewProps) {- Have you started any - - {" "} - workspaces - {" "} - in{" "} - {new Date(startDateOfBillMonth).toLocaleString("default", { - month: "long", - })}{" "} - {new Date(startDateOfBillMonth).getFullYear()} or checked your other teams? -
-+ Have you started any + + {" "} + workspaces + {" "} + in{" "} + {new Date(startDateOfBillMonth).toLocaleString("default", { + month: "long", + })}{" "} + {new Date(startDateOfBillMonth).getFullYear()} or checked your other teams? +
+