acc_invoices: роль admin и переключатель роли CFO/accountant/employee; Keycloak: фирменный стиль KH Build
All checks were successful
ci / test (push) Successful in 55s
ci / deploy (push) Successful in 3m13s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 14:36:45 +03:00
parent d79ebfda10
commit b878aa72bb
9 changed files with 126 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
import * as Ariakit from "@ariakit/react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { ApiError, api, getToken, type Detail, type Line, type Lookups, type Me, type Row } from "./api.js";
import { ApiError, api, getActing, getToken, setActing, type Detail, type Line, type Lookups, type Me, type Row } from "./api.js";
import { FormDialog } from "./FormDialog.js";
import { Login } from "./Login.js";
import { finishLogin, logout, relogin } from "./oidc.js";
@@ -105,7 +105,15 @@ function Main({ me, onLogout }: { me: Me; onLogout: () => void }) {
</Ariakit.TabList>
<input className="search" type="search" placeholder="Поиск: вендор, номер, проект, сумма" value={q} onChange={(e) => setQ(e.target.value)} aria-label="Поиск" />
<span className="spacer" />
<span className="who" title={me.roles.join(", ") || "сотрудник"}>{me.name}</span>
<span className="who" title={"роли: " + (me.real_roles.join(", ") || "сотрудник")}>{me.name}</span>
{me.can_switch && (
<select className="role-switch" aria-label="Роль для отладки и тестирования" title="Роль (отладка и тестирование)" value={me.acting_role}
onChange={(e) => { setActing(e.target.value); location.reload(); }}>
<option value="cfo">CFO</option>
<option value="accountant">accountant</option>
<option value="employee">employee</option>
</select>
)}
<button className="btn" onClick={onLogout}>Выйти</button>
<button className="btn primary" disabled={!lookups} onClick={() => openForm(null, [])}>Create</button>
</Ariakit.Toolbar>