Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

1000 B
Raw Blame
import type { StatusTone } from "@editor/ui";
import type { FileRunEventStatus } from "@processor/api/fileRunEvents";

/** How a closed failure was settled. Must stay in sync with the server's terminal statuses. */

interface FailureOutcome {
  labelKey: string;
  defaultLabel: string;
  tone: StatusTone;
}

const OUTCOMES: Partial<Record<FileRunEventStatus, FailureOutcome>> = {
  RESOLVED: {
    labelKey: "portal.failures.outcome.resolved",
    defaultLabel: "Resolved",
    tone: "success",
  },
  DISMISSED: {
    labelKey: "portal.failures.outcome.dismissed",
    defaultLabel: "Dismissed",
    tone: "neutral",
  },
  FILE_REMOVED: {
    labelKey: "portal.failures.outcome.fileRemoved",
    defaultLabel: "File deleted",
    tone: "neutral",
  },
};

const STILL_OPEN: FailureOutcome = {
  labelKey: "portal.failures.outcome.open",
  defaultLabel: "Open",
  tone: "info",
};

export function outcomeOf(status: FileRunEventStatus): FailureOutcome {
  return OUTCOMES[status] ?? STILL_OPEN;
}