display work time in issue detail pane

This commit is contained in:
Oliver Bryan
2026-01-11 17:18:55 +00:00
parent 511a2d4bea
commit d44f378403
13 changed files with 177 additions and 30 deletions

View File

@@ -0,0 +1,30 @@
import { getCsrfToken, getServerURL } from "@/lib/utils";
import type { ServerQueryInput } from "..";
export async function getInactive({
issueId,
onSuccess,
onError,
}: {
issueId: number;
} & ServerQueryInput) {
const url = new URL(`${getServerURL()}/timer/get-inactive`);
url.searchParams.set("issueId", `${issueId}`);
const csrfToken = getCsrfToken();
const headers: HeadersInit = {};
if (csrfToken) headers["X-CSRF-Token"] = csrfToken;
const res = await fetch(url.toString(), {
headers,
credentials: "include",
});
if (!res.ok) {
const error = await res.text();
onError?.(error || `failed to get timers (${res.status})`);
} else {
const data = await res.json();
onSuccess?.(data, res);
}
}

View File

@@ -1,4 +1,5 @@
export { end } from "@/lib/server/timer/end";
export { get } from "@/lib/server/timer/get";
export { getInactive } from "@/lib/server/timer/getInactive";
export { list } from "@/lib/server/timer/list";
export { toggle } from "@/lib/server/timer/toggle";

View File

@@ -40,3 +40,13 @@ export function getServerURL() {
}
return serverURL;
}
export function formatTime(ms: number): string {
const totalSeconds = Math.floor(ms / 1000);
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60;
return `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}:${seconds
.toString()
.padStart(2, "0")}`;
}