Files
ForbiddenStarsApp/frontend/src/domain/winReasons.ts
T

20 lines
710 B
TypeScript

import type { components } from "../api/schema";
export type WinReason = components["schemas"]["MatchFinish"]["win_reason"];
// Фиксированный порядок (сверху вниз).
export const WIN_REASONS: { code: WinReason; label: string }[] = [
{ code: "objectives", label: "По целям" },
{ code: "worlds", label: "По мирам" },
{ code: "plastic", label: "По пластику" },
{ code: "resources", label: "По ресурсам" },
];
const LABELS: Record<string, string> = Object.fromEntries(
WIN_REASONS.map((w) => [w.code, w.label]),
);
export function winReasonLabel(code: string | null | undefined): string {
return code ? LABELS[code] ?? code : "—";
}