peppa/packages/core/src/ui-mode.ts
Асель 05dfb08b67 Merge main into task/pep-98: PEP-119 texts through the dictionary
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 19:56:56 +05:00

26 lines
1.2 KiB
TypeScript

// PEP-119: what a person sees. «Продакт» (the default for everyone) shows the result and what
// is needed from them; «Инженер» shows everything — terminals, code, checks, spend. The choice
// is the user's own and is remembered.
import type { Db } from "@peppa/db";
import { m as tr } from "@peppa/shared/i18n";
import { getSetting, setSetting } from "./settings.ts";
export const UI_MODES = ["product", "engineer"] as const;
export type UiMode = (typeof UI_MODES)[number];
export const UI_MODE_NAMES: Record<UiMode, string> = { product: tr("Продакт"), engineer: tr("Инженер") };
const key = (userId: number) => `ui.mode:${userId}`;
export async function getUiMode(db: Db, userId: number): Promise<UiMode> {
return (await getSetting<string>(db, key(userId))) === "engineer" ? "engineer" : "product";
}
export async function setUiMode(db: Db, userId: number, mode: string): Promise<UiMode> {
const m: UiMode = mode === "engineer" ? "engineer" : "product";
await setSetting(db, key(userId), m);
return m;
}
/** Project tabs a product manager sees; the rest belong to «Инженер». */
export const PRODUCT_PROJECT_TABS = ["board", "epics", "bugs"] as const;