SPB Git

Repository Public

logic.ts 714 B 13 lines typescript

1export const ACTIVITY_TABS = ["feed", "actions", "approvals"] as const;2export type ActivityTab = (typeof ACTIVITY_TABS)[number];3export function tabFromParam(raw: string | null): ActivityTab {4  return (ACTIVITY_TABS as readonly string[]).includes(raw ?? "") ? (raw as ActivityTab) : "feed";5}67/** Run time of an action in seconds: started → finished. Undefined until both are known. */8export function actionDurationSeconds(a: { started_at?: string | undefined; finished_at?: string | undefined }): number | undefined {9  if (!a.started_at || !a.finished_at) return undefined;10  const d = (Date.parse(a.finished_at) - Date.parse(a.started_at)) / 1000;11  return Number.isFinite(d) && d >= 0 ? d : undefined;12}13
Files main
Menu

Theme