One clean commit on top of main (the branch history had an intermediate commit with conflict markers). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
25 lines
1.1 KiB
TypeScript
25 lines
1.1 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 { 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: "Продакт", engineer: "Инженер" };
|
|
|
|
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;
|