acc_invoices UI: кнопки Drive и QuickBooks над строками инвойса и контракта (новая вкладка)
All checks were successful
ci / deploy (push) Successful in 3m15s
ci / test (push) Successful in 51s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 15:12:25 +03:00
parent 4544383e8a
commit 154d9be4ea
2 changed files with 16 additions and 2 deletions

View File

@@ -12,6 +12,12 @@ const qbUrl = (txn: string): string => txn.startsWith("bill:") ? `https://app.qb
const QB_ICON = (
<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><circle cx="12" cy="12" r="11" fill="#2ca01c" /><path d="M7 8.5h2.2a2.2 2.2 0 0 1 0 4.4H8.5v2.6M17 15.5h-2.2a2.2 2.2 0 0 1 0-4.4h.7V8.5" stroke="#fff" strokeWidth="1.8" fill="none" strokeLinecap="round" /></svg>
);
/** Ссылка, всегда в новой вкладке; без адреса - неактивная кнопка с подсказкой. */
function LinkBtn({ href, label, off }: { href?: string | null; label: string; off?: string }) {
return href
? <a className="btn small" href={href} target="_blank" rel="noopener noreferrer">{label} ↗</a>
: <button className="btn small" disabled title={off}>{label}</button>;
}
const hashFilter = (): string => new URLSearchParams(location.hash.slice(1)).get("f") ?? "to_pay";
export function App() {
@@ -193,8 +199,6 @@ function Main({ me, onLogout }: { me: Me; onLogout: () => void }) {
<div className="actions" role="toolbar" aria-label="Действия с инвойсом">
<strong>{inv.vendor_name} {inv.invoice_number}</strong>
<span className={`badge b-${inv.status}`}>{inv.status_label}</span>
{inv.invoice_url && <a className="btn small" href={inv.invoice_url} target="_blank" rel="noreferrer">Инвойс ↗</a>}
{inv.payment_url && <a className="btn small" href={inv.payment_url} target="_blank" rel="noreferrer">Платёж ↗</a>}
<span className="spacer" />
{inv.editable.length > 0 && <button className="btn small" onClick={() => openForm(inv, detail!.details)}>Редактировать</button>}
{inv.is_draft && !inv.cancelled && <button className="btn small primary" onClick={() => act("submit", undefined, "Отправлено в платёжный процесс")}>Отправить в процесс</button>}
@@ -223,6 +227,11 @@ function Main({ me, onLogout }: { me: Me; onLogout: () => void }) {
<div className="details">
<section className="panel" aria-label="Строки инвойса">
<div className="panel-links">
<LinkBtn href={inv?.invoice_url} label="Invoice на Google Drive" off="Файла инвойса на Drive нет" />
{inv?.payment_url && <LinkBtn href={inv.payment_url} label="Платёж на Google Drive" />}
{showQb && <LinkBtn href={inv?.qbo_txn_id ? qbUrl(inv.qbo_txn_id) : null} label="Invoice в QuickBooks" off="Проводки в QuickBooks нет" />}
</div>
<h2>Строки инвойса</h2>
{inv ? (
<table className="mini">
@@ -247,6 +256,10 @@ function Main({ me, onLogout }: { me: Me; onLogout: () => void }) {
</section>
<section className="panel" aria-label="Контракт">
<div className="panel-links">
<LinkBtn href={detail?.contract?.drive_file_id ? `https://drive.google.com/file/d/${detail.contract.drive_file_id}/view` : null} label="Контракт на Google Drive" off="Файла контракта на Drive нет" />
{showQb && <LinkBtn href={inv?.vendor_qbo_id ? `https://app.qbo.intuit.com/app/vendordetail?nameId=${inv.vendor_qbo_id}` : null} label="Вендор в QuickBooks" off="Вендор не сопоставлен с QuickBooks" />}
</div>
<Ariakit.TabList store={contractTab} className="tabs small" aria-label="Контракт">
<Ariakit.Tab id="inv" className="tab">Инвойсы контракта</Ariakit.Tab>
<Ariakit.Tab id="lines" className="tab">Строки контракта</Ariakit.Tab>

View File

@@ -105,3 +105,4 @@ body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 syst
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ok); color: #fff; padding: 8px 16px; border-radius: 8px; z-index: 20; max-width: 90vw; }
.toast.bad { background: var(--bad); }
@media (max-width: 800px) { .details { grid-template-columns: 1fr; } .app { grid-template-rows: auto minmax(160px, 1fr) auto auto auto; overflow: auto; } }
.panel-links { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }