@colveor/admin 0.0.0-stage → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/LICENSE.md +106 -0
  2. package/TAILWINDADMIN-LICENSE +21 -0
  3. package/dist/account/data.d.ts +1 -0
  4. package/dist/account/data.js +44 -0
  5. package/dist/account/profile.d.ts +6 -0
  6. package/dist/account/profile.js +118 -0
  7. package/dist/account/sessions.d.ts +1 -0
  8. package/dist/account/sessions.js +26 -0
  9. package/dist/account/shared.d.ts +26 -0
  10. package/dist/account/shared.js +44 -0
  11. package/dist/account/two-factor.d.ts +5 -0
  12. package/dist/account/two-factor.js +60 -0
  13. package/dist/actions.d.ts +39 -0
  14. package/dist/actions.js +81 -0
  15. package/dist/api/audit.gen.d.ts +80 -0
  16. package/dist/api/audit.gen.js +43 -0
  17. package/dist/api/auth.gen.d.ts +537 -0
  18. package/dist/api/auth.gen.js +313 -0
  19. package/dist/api/errors.gen.d.ts +16 -0
  20. package/dist/api/errors.gen.js +2 -0
  21. package/dist/api/gormx.gen.d.ts +60 -0
  22. package/dist/api/gormx.gen.js +16 -0
  23. package/dist/api/health.gen.d.ts +103 -0
  24. package/dist/api/health.gen.js +23 -0
  25. package/dist/api/index.gen.d.ts +21 -0
  26. package/dist/api/index.gen.js +22 -0
  27. package/dist/api/invitations.gen.d.ts +128 -0
  28. package/dist/api/invitations.gen.js +57 -0
  29. package/dist/api/ledger.gen.d.ts +269 -0
  30. package/dist/api/ledger.gen.js +113 -0
  31. package/dist/api/msgtemplate.gen.d.ts +31 -0
  32. package/dist/api/msgtemplate.gen.js +2 -0
  33. package/dist/api/notifications.gen.d.ts +66 -0
  34. package/dist/api/notifications.gen.js +28 -0
  35. package/dist/api/outbox.gen.d.ts +8 -0
  36. package/dist/api/outbox.gen.js +2 -0
  37. package/dist/api/queue.gen.d.ts +112 -0
  38. package/dist/api/queue.gen.js +15 -0
  39. package/dist/api/rbac.gen.d.ts +406 -0
  40. package/dist/api/rbac.gen.js +191 -0
  41. package/dist/api/reauth.gen.d.ts +289 -0
  42. package/dist/api/reauth.gen.js +122 -0
  43. package/dist/api/recorded_payments.gen.d.ts +171 -0
  44. package/dist/api/recorded_payments.gen.js +79 -0
  45. package/dist/api/sessions.gen.d.ts +64 -0
  46. package/dist/api/sessions.gen.js +48 -0
  47. package/dist/api/settings.gen.d.ts +147 -0
  48. package/dist/api/settings.gen.js +69 -0
  49. package/dist/api/storage.gen.d.ts +327 -0
  50. package/dist/api/storage.gen.js +208 -0
  51. package/dist/api/support_access.gen.d.ts +155 -0
  52. package/dist/api/support_access.gen.js +131 -0
  53. package/dist/api/users.gen.d.ts +407 -0
  54. package/dist/api/users.gen.js +159 -0
  55. package/dist/api/verification.gen.d.ts +427 -0
  56. package/dist/api/verification.gen.js +280 -0
  57. package/dist/api/webhooks.gen.d.ts +110 -0
  58. package/dist/api/webhooks.gen.js +45 -0
  59. package/dist/auth-layout.d.ts +9 -0
  60. package/dist/auth-layout.js +5 -0
  61. package/dist/client.d.ts +41 -0
  62. package/dist/client.js +72 -0
  63. package/dist/config.d.ts +27 -0
  64. package/dist/config.js +82 -0
  65. package/dist/dates.d.ts +4 -0
  66. package/dist/dates.js +16 -0
  67. package/dist/header.d.ts +12 -0
  68. package/dist/header.js +105 -0
  69. package/dist/icons.d.ts +2 -0
  70. package/dist/icons.js +15 -0
  71. package/dist/index.d.ts +28 -0
  72. package/dist/index.js +42 -0
  73. package/dist/kit/avatar.d.ts +5 -0
  74. package/dist/kit/avatar.js +16 -0
  75. package/dist/kit/badge.d.ts +10 -0
  76. package/dist/kit/badge.js +31 -0
  77. package/dist/kit/card.d.ts +12 -0
  78. package/dist/kit/card.js +7 -0
  79. package/dist/kit/code-area.d.ts +15 -0
  80. package/dist/kit/code-area.js +69 -0
  81. package/dist/kit/dropdown.d.ts +26 -0
  82. package/dist/kit/dropdown.js +67 -0
  83. package/dist/kit/filter-tabs.d.ts +9 -0
  84. package/dist/kit/filter-tabs.js +7 -0
  85. package/dist/kit/modal.d.ts +8 -0
  86. package/dist/kit/modal.js +15 -0
  87. package/dist/kit/page-header.d.ts +13 -0
  88. package/dist/kit/page-header.js +13 -0
  89. package/dist/kit/search.d.ts +4 -0
  90. package/dist/kit/search.js +16 -0
  91. package/dist/kit/tooltip.d.ts +17 -0
  92. package/dist/kit/tooltip.js +52 -0
  93. package/dist/message-editor.d.ts +9 -0
  94. package/dist/message-editor.js +80 -0
  95. package/dist/money.d.ts +10 -0
  96. package/dist/money.js +17 -0
  97. package/dist/next.d.ts +6 -0
  98. package/dist/next.js +19 -0
  99. package/dist/pages/account.d.ts +1 -0
  100. package/dist/pages/account.js +47 -0
  101. package/dist/pages/audit.d.ts +1 -0
  102. package/dist/pages/audit.js +88 -0
  103. package/dist/pages/forgot-password.d.ts +1 -0
  104. package/dist/pages/forgot-password.js +73 -0
  105. package/dist/pages/ledger.d.ts +1 -0
  106. package/dist/pages/ledger.js +132 -0
  107. package/dist/pages/roles.d.ts +1 -0
  108. package/dist/pages/roles.js +102 -0
  109. package/dist/pages/settings.d.ts +1 -0
  110. package/dist/pages/settings.js +86 -0
  111. package/dist/pages/sign-in.d.ts +5 -0
  112. package/dist/pages/sign-in.js +117 -0
  113. package/dist/pages/status.d.ts +1 -0
  114. package/dist/pages/status.js +122 -0
  115. package/dist/pages/support.d.ts +1 -0
  116. package/dist/pages/support.js +90 -0
  117. package/dist/pages/teams.d.ts +1 -0
  118. package/dist/pages/teams.js +94 -0
  119. package/dist/pages/users.d.ts +1 -0
  120. package/dist/pages/users.js +158 -0
  121. package/dist/pages/webhooks.d.ts +1 -0
  122. package/dist/pages/webhooks.js +88 -0
  123. package/dist/permissions.d.ts +5 -0
  124. package/dist/permissions.js +31 -0
  125. package/dist/proof.d.ts +10 -0
  126. package/dist/proof.js +78 -0
  127. package/dist/proxy.d.ts +10 -0
  128. package/dist/proxy.js +166 -0
  129. package/dist/retry.d.ts +8 -0
  130. package/dist/retry.js +30 -0
  131. package/dist/router.d.ts +13 -0
  132. package/dist/router.js +14 -0
  133. package/dist/setting-fields.d.ts +12 -0
  134. package/dist/setting-fields.js +102 -0
  135. package/dist/setting-list.d.ts +22 -0
  136. package/dist/setting-list.js +78 -0
  137. package/dist/shell.d.ts +40 -0
  138. package/dist/shell.js +97 -0
  139. package/dist/support.d.ts +37 -0
  140. package/dist/support.js +76 -0
  141. package/dist/table.d.ts +40 -0
  142. package/dist/table.js +73 -0
  143. package/dist/ui.d.ts +39 -0
  144. package/dist/ui.js +56 -0
  145. package/dist/user-actions.d.ts +30 -0
  146. package/dist/user-actions.js +129 -0
  147. package/dist/user-roles.d.ts +4 -0
  148. package/dist/user-roles.js +51 -0
  149. package/dist/user-row-menu.d.ts +14 -0
  150. package/dist/user-row-menu.js +45 -0
  151. package/dist/version.d.ts +1 -0
  152. package/dist/version.js +3 -0
  153. package/package.json +59 -4
  154. package/README.md +0 -3
@@ -0,0 +1,17 @@
1
+ import { type ReactNode } from "react";
2
+ export declare function Tooltip(props: {
3
+ /** What the tip says. */
4
+ tip: ReactNode;
5
+ /** The trigger's content: an icon, a word. */
6
+ children: ReactNode;
7
+ /** The trigger's name for screen readers. */
8
+ label: string;
9
+ /** The trigger's classes. */
10
+ className?: string;
11
+ }): import("react").JSX.Element;
12
+ /** A "?" in a circle whose tip explains what it sits beside. */
13
+ export declare function InfoTip(props: {
14
+ children: ReactNode;
15
+ label?: string;
16
+ className?: string;
17
+ }): import("react").JSX.Element;
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // A tip shown when its trigger is clicked, and hidden on a click outside,
4
+ // Escape, a scroll, or when focus moves away. It is drawn at the top of the
5
+ // page (a portal), so no list that scrolls, and no moving parent, can clip
6
+ // or shift it. InfoTip is the "?" version.
7
+ import { useEffect, useRef, useState } from "react";
8
+ import { createPortal } from "react-dom";
9
+ export function Tooltip(props) {
10
+ const [place, setPlace] = useState(null);
11
+ const ref = useRef(null);
12
+ useEffect(() => {
13
+ if (place === null) {
14
+ return;
15
+ }
16
+ const hide = () => setPlace(null);
17
+ const outside = (e) => {
18
+ if (!ref.current?.contains(e.target)) {
19
+ hide();
20
+ }
21
+ };
22
+ const onKey = (e) => e.key === "Escape" && hide();
23
+ document.addEventListener("mousedown", outside);
24
+ document.addEventListener("keydown", onKey);
25
+ window.addEventListener("scroll", hide, true);
26
+ window.addEventListener("resize", hide);
27
+ return () => {
28
+ document.removeEventListener("mousedown", outside);
29
+ document.removeEventListener("keydown", onKey);
30
+ window.removeEventListener("scroll", hide, true);
31
+ window.removeEventListener("resize", hide);
32
+ };
33
+ }, [place]);
34
+ const toggle = () => {
35
+ const box = ref.current?.getBoundingClientRect();
36
+ if (place !== null || box === undefined) {
37
+ setPlace(null);
38
+ return;
39
+ }
40
+ // Beside the trigger when there is room on the right, else under it.
41
+ setPlace(box.right + 300 < window.innerWidth
42
+ ? { left: box.right + 10, top: Math.max(8, box.top - 8) }
43
+ : { right: Math.max(8, window.innerWidth - box.right), top: box.bottom + 8 });
44
+ };
45
+ return (_jsxs(_Fragment, { children: [_jsx("button", { ref: ref, type: "button", "aria-label": props.label, "aria-expanded": place !== null, onClick: toggle, onBlur: () => setPlace(null), className: props.className, children: props.children }), place !== null &&
46
+ createPortal(_jsx("span", { role: "tooltip", style: place, className: "fixed z-[999] w-72 animate-pop-in rounded-xl bg-gray-900 px-4 py-3 text-xs leading-relaxed text-white shadow-lg dark:bg-gray-700", children: props.tip }), document.body)] }));
47
+ }
48
+ /** A "?" in a circle whose tip explains what it sits beside. */
49
+ export function InfoTip(props) {
50
+ return (_jsx(Tooltip, { tip: props.children, label: props.label ?? "More about this", className: `flex size-5 shrink-0 items-center justify-center rounded-full border text-[11px] font-medium transition-colors ${props.className ??
51
+ "border-gray-300 text-gray-500 hover:border-brand-500 hover:text-brand-500 dark:border-gray-600 dark:text-gray-400"}`, children: "?" }));
52
+ }
@@ -0,0 +1,9 @@
1
+ import type * as settings from "./api/settings.gen";
2
+ type Setting = settings.SettingResponse;
3
+ export declare function MessageEditor(props: {
4
+ setting: Setting;
5
+ editable: boolean;
6
+ onSaved(s: Setting): void;
7
+ onClose(): void;
8
+ }): import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ // The editor of a message setting (a verification code, a notice, an
4
+ // invitation): the email's subject, text and HTML, and the SMS, beside a
5
+ // preview the API renders with sample data as you type
6
+ // (POST /v1/settings/{key}/preview). Saving goes through the usual PATCH,
7
+ // which checks the templates again and refuses a broken one.
8
+ import { useEffect, useState } from "react";
9
+ import { Cancelled, useAction } from "./actions";
10
+ import { api } from "./client";
11
+ import { CodeArea } from "./kit/code-area";
12
+ import { FilterTabs } from "./kit/filter-tabs";
13
+ import { Modal } from "./kit/modal";
14
+ import { InfoTip } from "./kit/tooltip";
15
+ export function MessageEditor(props) {
16
+ const { setting: s, editable } = props;
17
+ const [draft, setDraft] = useState(() => read(s.value));
18
+ const [preview, setPreview] = useState(null);
19
+ const [shown, setShown] = useState(0);
20
+ const [asText, setAsText] = useState(false);
21
+ const [error, setError] = useState("");
22
+ const [busy, setBusy] = useState(false);
23
+ const { run, dialogs } = useAction();
24
+ const value = JSON.stringify(draft);
25
+ // The preview follows the typing, a moment after it stops.
26
+ useEffect(() => {
27
+ const timer = setTimeout(() => {
28
+ api
29
+ .post(`/v1/settings/${encodeURIComponent(s.key)}/preview`, {
30
+ value: JSON.parse(value),
31
+ })
32
+ .then(setPreview)
33
+ .catch((err) => setPreview({ rendered: [], problem: err.message }));
34
+ }, 400);
35
+ return () => clearTimeout(timer);
36
+ }, [s.key, value]);
37
+ const email = (part, v) => setDraft({ ...draft, email: { ...draft.email, [part]: v } });
38
+ const save = async () => {
39
+ setError("");
40
+ setBusy(true);
41
+ try {
42
+ props.onSaved(await run((o) => api.patch(`/v1/settings/${encodeURIComponent(s.key)}`, { value: JSON.parse(value) }, o)));
43
+ props.onClose();
44
+ }
45
+ catch (err) {
46
+ if (!(err instanceof Cancelled)) {
47
+ setError(err instanceof Error ? err.message : String(err));
48
+ }
49
+ }
50
+ finally {
51
+ setBusy(false);
52
+ }
53
+ };
54
+ const rendered = preview?.rendered ?? [];
55
+ const current = rendered[Math.min(shown, rendered.length - 1)];
56
+ return (_jsxs(Modal, { size: "xl", onClose: props.onClose, title: _jsxs("span", { className: "flex items-center gap-2", children: [(s.key.split(".").pop() ?? s.key).replaceAll("_", " "), " message", _jsx(InfoTip, { label: "Variables you can use", children: s.description })] }), footer: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: props.onClose, className: "rounded-lg border border-gray-300 px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-white/5", children: editable ? "Cancel" : "Close" }), editable && (_jsx("button", { type: "button", disabled: busy || value === JSON.stringify(read(s.value)), onClick: save, className: "rounded-lg bg-brand-500 px-5 py-2 text-sm font-medium text-white hover:bg-brand-600 disabled:opacity-40", children: "Save" }))] }), children: [_jsxs("div", { className: "grid gap-6 lg:grid-cols-2", children: [_jsxs("div", { className: "space-y-4", children: [_jsx(Part, { label: "Email subject", children: _jsx(CodeArea, { singleLine: true, lang: "template", label: "Email subject", value: draft.email.subject, disabled: !editable, onChange: (v) => email("subject", v) }) }), _jsx(Part, { label: "Email HTML", hint: "Optional. Most inboxes show this; leave it empty to send text only.", children: _jsx(CodeArea, { rows: 12, label: "Email HTML", value: draft.email.html, disabled: !editable, onChange: (v) => email("html", v) }) }), _jsx(Part, { label: "Email text", hint: "Required: shown by inboxes that don't show HTML.", children: _jsx(CodeArea, { rows: 7, lang: "template", label: "Email text", value: draft.email.text, disabled: !editable, onChange: (v) => email("text", v) }) }), _jsx(Part, { label: "SMS", hint: `${draft.sms.length} characters; an SMS holds about 160.`, children: _jsx(CodeArea, { rows: 3, lang: "template", label: "SMS", value: draft.sms, disabled: !editable, onChange: (v) => setDraft({ ...draft, sms: v }) }) })] }), _jsxs("div", { className: "space-y-3 lg:sticky lg:top-0 lg:self-start", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("p", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: "Preview" }), rendered.length > 0 && (_jsx(FilterTabs, { value: String(Math.min(shown, rendered.length - 1)), onChange: (k) => setShown(Number(k)), tabs: rendered.map((r, i) => ({ key: String(i), label: r.name })) }))] }), error !== "" && (_jsx("p", { className: "rounded-lg bg-red-50 px-4 py-3 text-sm text-red-600", children: error })), preview?.problem && (_jsxs("p", { className: "rounded-lg bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:bg-amber-500/10 dark:text-amber-400", children: ["It can't be saved like this: ", preview.problem] })), current !== undefined && (_jsx(Rendered, { message: current, asText: asText, onAsText: setAsText })), _jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: "Shown with sample values (app \"Example\", code 246810)." })] })] }), dialogs] }));
57
+ }
58
+ function Rendered(props) {
59
+ const m = props.message;
60
+ if (m.sms) {
61
+ return (_jsx("div", { className: "rounded-2xl bg-gray-100 p-4 dark:bg-white/5", children: _jsx("p", { className: "max-w-xs rounded-2xl rounded-bl-sm bg-white px-4 py-3 text-sm whitespace-pre-wrap text-gray-800 shadow-sm dark:bg-gray-800 dark:text-white/90", children: m.sms }) }));
62
+ }
63
+ const html = m.html && !props.asText;
64
+ return (_jsxs("div", { className: "overflow-hidden rounded-xl border border-gray-200 dark:border-gray-800", children: [_jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-gray-200 bg-gray-50 px-4 py-2.5 dark:border-gray-800 dark:bg-white/[0.03]", children: [_jsx("p", { className: "truncate text-sm font-medium text-gray-800 dark:text-white/90", children: m.subject }), m.html && (_jsx("button", { type: "button", onClick: () => props.onAsText(!props.asText), className: "shrink-0 text-xs text-brand-500 hover:text-brand-600", children: props.asText ? "Show HTML" : "Show text" }))] }), html ? (
65
+ // No scripts or links run in it: a sandbox with nothing allowed.
66
+ _jsx("iframe", { title: "Email preview", sandbox: "", srcDoc: m.html, className: "h-96 w-full bg-white" })) : (_jsx("pre", { className: "h-96 overflow-auto p-4 font-sans text-sm whitespace-pre-wrap text-gray-800 dark:text-white/90", children: m.text }))] }));
67
+ }
68
+ function Part(props) {
69
+ return (
70
+ // biome-ignore lint/a11y/noLabelWithoutControl: the control is the child
71
+ _jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300", children: props.label }), props.children, props.hint && (_jsx("span", { className: "mt-1 block text-xs text-gray-500 dark:text-gray-400", children: props.hint }))] }));
72
+ }
73
+ /** The stored value as a template, its missing parts empty. */
74
+ function read(value) {
75
+ const t = JSON.parse(value || "{}");
76
+ return {
77
+ email: { subject: "", text: "", html: "", ...t.email },
78
+ sms: t.sms ?? "",
79
+ };
80
+ }
@@ -0,0 +1,10 @@
1
+ export interface Money {
2
+ amount: number;
3
+ currency: string;
4
+ }
5
+ /**
6
+ * For showing only: the browser's currency data gives the decimals, and
7
+ * for a few currencies differs from the API's (pkg/platform/money). So
8
+ * amounts are sent in minor units, never converted from this.
9
+ */
10
+ export declare function formatMoney(m: Money): string;
package/dist/money.js ADDED
@@ -0,0 +1,17 @@
1
+ // Money as the API sends it: an amount in minor units (1250 is NGN 12.50)
2
+ // and an ISO 4217 currency.
3
+ /**
4
+ * For showing only: the browser's currency data gives the decimals, and
5
+ * for a few currencies differs from the API's (pkg/platform/money). So
6
+ * amounts are sent in minor units, never converted from this.
7
+ */
8
+ export function formatMoney(m) {
9
+ try {
10
+ const f = new Intl.NumberFormat(undefined, { style: "currency", currency: m.currency });
11
+ const digits = f.resolvedOptions().maximumFractionDigits ?? 2;
12
+ return f.format(m.amount / 10 ** digits);
13
+ }
14
+ catch {
15
+ return `${m.amount} ${m.currency} (minor units)`;
16
+ }
17
+ }
package/dist/next.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ import type { AdminConfig } from "./config";
3
+ export declare function NextAdmin({ config, children }: {
4
+ config: AdminConfig;
5
+ children: ReactNode;
6
+ }): import("react").JSX.Element;
package/dist/next.js ADDED
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ // The Next router adapter: with the proxy, the only part of the package
4
+ // that imports Next (docs/admin.md). The template's app/layout.tsx wraps
5
+ // the app in <NextAdmin config={config}>.
6
+ import Link from "next/link";
7
+ import { usePathname, useRouter } from "next/navigation";
8
+ import { useMemo } from "react";
9
+ import { ColveorAdmin } from "./shell";
10
+ export function NextAdmin({ config, children }) {
11
+ const pathname = usePathname();
12
+ const next = useRouter();
13
+ const router = useMemo(() => ({
14
+ pathname,
15
+ navigate: (href) => next.push(href),
16
+ Link,
17
+ }), [pathname, next]);
18
+ return (_jsx(ColveorAdmin, { config: config, router: router, children: children }));
19
+ }
@@ -0,0 +1 @@
1
+ export default function AccountPage(): import("react").JSX.Element;
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Account settings (the user menu's "Account"): the signed-in admin's
4
+ // profile, password, two-step verification, devices and data.
5
+ import { useEffect, useState } from "react";
6
+ import { DataTab } from "../account/data";
7
+ import { PasswordTab, ProfileTab } from "../account/profile";
8
+ import { SessionsTab } from "../account/sessions";
9
+ import { TwoFactorTab } from "../account/two-factor";
10
+ import { api } from "../client";
11
+ import { ACCOUNT_TAB_EVENT } from "../header";
12
+ import { PageHeader } from "../kit/page-header";
13
+ import { Alert } from "../ui";
14
+ const TABS = [
15
+ ["profile", "Profile"],
16
+ ["password", "Password"],
17
+ ["two-factor", "Two-step verification"],
18
+ ["sessions", "Devices"],
19
+ ["data", "Your data"],
20
+ ];
21
+ export default function AccountPage() {
22
+ const [tab, setTab] = useState("profile");
23
+ // ?tab=, and the user menu's links while the page is open.
24
+ useEffect(() => {
25
+ const pick = (key) => {
26
+ if (TABS.some(([k]) => k === key)) {
27
+ setTab(key);
28
+ }
29
+ };
30
+ pick(new URLSearchParams(window.location.search).get("tab"));
31
+ const onTab = (e) => pick(e.detail);
32
+ window.addEventListener(ACCOUNT_TAB_EVENT, onTab);
33
+ return () => window.removeEventListener(ACCOUNT_TAB_EVENT, onTab);
34
+ }, []);
35
+ const [me, setMe] = useState(null);
36
+ const [error, setError] = useState("");
37
+ const load = () => api
38
+ .get("/v1/me")
39
+ .then(setMe)
40
+ .catch((err) => setError(err.message));
41
+ useEffect(() => {
42
+ load();
43
+ }, []);
44
+ return (_jsxs("div", { className: "space-y-6", children: [_jsx(PageHeader, { title: "Account settings" }), error !== "" && _jsx(Alert, { children: error }), _jsx("div", { className: "flex gap-6 overflow-x-auto border-b border-gray-200 dark:border-gray-800", children: TABS.map(([key, label]) => (_jsxs("button", { type: "button", onClick: () => setTab(key), className: `relative shrink-0 pb-3 text-sm font-medium transition-colors ${tab === key
45
+ ? "text-brand-500"
46
+ : "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`, children: [label, _jsx("span", { className: `absolute inset-x-0 -bottom-px h-0.5 rounded-full bg-brand-500 transition-transform duration-200 ${tab === key ? "scale-x-100" : "scale-x-0"}` })] }, key))) }), me !== null && (_jsxs("div", { className: "animate-slide-in", children: [tab === "profile" && _jsx(ProfileTab, { me: me, onSaved: load }), tab === "password" && _jsx(PasswordTab, {}), tab === "two-factor" && _jsx(TwoFactorTab, { me: me, onSaved: load }), tab === "sessions" && _jsx(SessionsTab, {}), tab === "data" && _jsx(DataTab, {})] }, tab))] }));
47
+ }
@@ -0,0 +1 @@
1
+ export default function AuditPage(): import("react").JSX.Element;
@@ -0,0 +1,88 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ // The audit log: what users and admins did, newest first, with its
4
+ // filters, and the monthly archives. Reading it is recorded too.
5
+ import { useEffect, useState } from "react";
6
+ import { api } from "../client";
7
+ import { formatDateTime } from "../dates";
8
+ import { PageHeader } from "../kit/page-header";
9
+ import { DataTable } from "../table";
10
+ import { Alert } from "../ui";
11
+ const input = "w-full rounded-lg border border-gray-300 bg-transparent px-3 py-2 text-sm text-gray-800 focus:border-brand-300 focus:outline-none dark:border-gray-700 dark:text-white/90";
12
+ export default function AuditPage() {
13
+ const [tab, setTab] = useState("events");
14
+ return (_jsxs("div", { className: "space-y-6", children: [_jsx(PageHeader, { title: "Audit log", actions: _jsx("div", { className: "flex gap-1 rounded-lg bg-gray-100 p-1 text-sm dark:bg-gray-800", children: ["events", "archives"].map((t) => (_jsx("button", { type: "button", onClick: () => setTab(t), className: `rounded-md px-3 py-1.5 capitalize ${tab === t
15
+ ? "bg-white text-gray-800 shadow-sm dark:bg-gray-900 dark:text-white/90"
16
+ : "text-gray-500 dark:text-gray-400"}`, children: t }, t))) }) }), tab === "events" ? _jsx(Events, {}) : _jsx(Archives, {})] }));
17
+ }
18
+ function Events() {
19
+ const [query, setQuery] = useState({});
20
+ const apply = (event) => {
21
+ event.preventDefault();
22
+ const f = new FormData(event.currentTarget);
23
+ const get = (k) => String(f.get(k) ?? "").trim() || undefined;
24
+ // datetime-local is the admin's local time: the API takes RFC 3339.
25
+ const at = (k) => {
26
+ const v = get(k);
27
+ return v === undefined ? undefined : new Date(v).toISOString();
28
+ };
29
+ setQuery({
30
+ action: get("action"),
31
+ outcome: get("outcome"),
32
+ actor_id: get("actor_id"),
33
+ target_type: get("target_type"),
34
+ target_id: get("target_id"),
35
+ from: at("from"),
36
+ to: at("to"),
37
+ });
38
+ };
39
+ return (_jsxs("div", { className: "space-y-4", children: [_jsxs("form", { onSubmit: apply, className: "grid gap-3 rounded-2xl border border-gray-200 bg-white p-4 md:grid-cols-4 dark:border-gray-800 dark:bg-white/[0.03]", children: [_jsx(Filter, { label: "Action", name: "action", placeholder: "rbac.RoleCreated" }), _jsxs("div", { children: [_jsx("label", { htmlFor: "audit-outcome", className: "mb-1 block text-xs text-gray-500", children: "Outcome" }), _jsxs("select", { id: "audit-outcome", name: "outcome", className: input, children: [_jsx("option", { value: "", children: "Any" }), _jsx("option", { value: "success", children: "Success" }), _jsx("option", { value: "failure", children: "Failure" })] })] }), _jsx(Filter, { label: "Actor (user ID)", name: "actor_id" }), _jsx(Filter, { label: "Target type", name: "target_type", placeholder: "user" }), _jsx(Filter, { label: "Target ID", name: "target_id" }), _jsx(Filter, { label: "From", name: "from", type: "datetime-local" }), _jsx(Filter, { label: "Until", name: "to", type: "datetime-local" }), _jsxs("div", { className: "flex items-end gap-2", children: [_jsx("button", { type: "submit", className: "h-10 flex-1 rounded-lg bg-brand-500 text-sm font-medium text-white hover:bg-brand-600", children: "Filter" }), _jsx("button", { type: "reset", onClick: () => setQuery({}), className: "h-10 rounded-lg px-3 text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400", children: "Clear" })] })] }), _jsx(DataTable, { path: "/v1/audit", query: query, empty: "No events match.", columns: [
40
+ { header: "When", cell: (e) => formatDateTime(e.occurred_at) },
41
+ {
42
+ header: "Action",
43
+ cell: (e) => (_jsxs(_Fragment, { children: [_jsx("span", { className: "font-mono text-xs", children: e.action }), e.outcome === "failure" && (_jsx("span", { className: "ml-2 rounded-full bg-red-50 px-2 py-0.5 text-xs text-red-600", children: "failed" }))] })),
44
+ },
45
+ { header: "Actor", cell: (e) => _jsx(Mono, { children: e.actor_id ?? "system" }) },
46
+ {
47
+ header: "Target",
48
+ cell: (e) => (_jsxs(Mono, { children: [e.target_type, e.target_id !== "" && `: ${e.target_id}`] })),
49
+ },
50
+ { header: "Reason", cell: (e) => e.reason },
51
+ {
52
+ header: "Details",
53
+ cell: (e) => (_jsxs("details", { children: [_jsx("summary", { className: "cursor-pointer text-brand-500", children: "Show" }), _jsx("pre", { className: "mt-2 max-w-md overflow-auto rounded-lg bg-gray-50 p-3 text-xs dark:bg-gray-900", children: JSON.stringify({
54
+ metadata: e.metadata,
55
+ ip: e.ip,
56
+ user_agent: e.user_agent,
57
+ request_id: e.request_id,
58
+ seq: e.seq,
59
+ }, null, 2) })] })),
60
+ },
61
+ ] })] }));
62
+ }
63
+ function Archives() {
64
+ const [archives, setArchives] = useState(null);
65
+ const [error, setError] = useState("");
66
+ useEffect(() => {
67
+ // Small by design (one per month): not paged.
68
+ api
69
+ .get("/v1/audit/archives")
70
+ .then(setArchives)
71
+ .catch((err) => setError(err.message));
72
+ }, []);
73
+ if (error !== "") {
74
+ return _jsx(Alert, { children: error });
75
+ }
76
+ return (_jsxs("div", { className: "overflow-hidden rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-white/[0.03]", children: [_jsxs("table", { className: "min-w-full text-left text-sm", children: [_jsx("thead", { className: "border-b border-gray-100 text-gray-500 dark:border-gray-800 dark:text-gray-400", children: _jsxs("tr", { children: [_jsx("th", { className: "px-5 py-3 font-medium", children: "Month" }), _jsx("th", { className: "px-5 py-3 font-medium", children: "Events" }), _jsx("th", { className: "px-5 py-3 font-medium", children: "Size" }), _jsx("th", { className: "px-5 py-3 font-medium", children: "Status" }), _jsx("th", { className: "px-5 py-3 font-medium", children: "File" })] }) }), _jsx("tbody", { className: "divide-y divide-gray-100 text-gray-800 dark:divide-gray-800 dark:text-white/90", children: archives?.map((a) => (_jsxs("tr", { children: [_jsx("td", { className: "px-5 py-3", children: new Date(a.period_start).toLocaleDateString(undefined, {
77
+ year: "numeric",
78
+ month: "long",
79
+ timeZone: a.timezone,
80
+ }) }), _jsx("td", { className: "px-5 py-3", children: a.record_count.toLocaleString() }), _jsxs("td", { className: "px-5 py-3", children: [(a.size_bytes / 1024).toFixed(0), " KB"] }), _jsxs("td", { className: "px-5 py-3", children: [a.status, a.error !== "" && _jsx("span", { className: "block text-xs text-red-600", children: a.error })] }), _jsx("td", { className: "px-5 py-3", children: _jsx(Mono, { children: a.key }) })] }, a.id))) })] }), archives?.length === 0 && (_jsx("p", { className: "p-5 text-sm text-gray-500 dark:text-gray-400", children: "No months archived yet." }))] }));
81
+ }
82
+ function Filter(props) {
83
+ const id = `audit-${props.name}`;
84
+ return (_jsxs("div", { children: [_jsx("label", { htmlFor: id, className: "mb-1 block text-xs text-gray-500", children: props.label }), _jsx("input", { id: id, name: props.name, type: props.type ?? "text", placeholder: props.placeholder, className: input })] }));
85
+ }
86
+ function Mono({ children }) {
87
+ return _jsx("span", { className: "font-mono text-xs break-all", children: children });
88
+ }
@@ -0,0 +1 @@
1
+ export default function ForgotPasswordPage(): import("react").JSX.Element;
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ // Forgot password: the admin's email, the code sent to it, then a new
4
+ // password. The project's app/forgot-password/page.tsx re-exports it.
5
+ import { useState } from "react";
6
+ import { AuthLayout } from "../auth-layout";
7
+ import { call } from "../client";
8
+ import { useConfig } from "../shell";
9
+ import { Alert, Button, CodeInput, Field } from "../ui";
10
+ export default function ForgotPasswordPage() {
11
+ const { config, router } = useConfig();
12
+ const { Link } = router;
13
+ const signIn = config.signInPath ?? "/login";
14
+ const [step, setStep] = useState({ kind: "email" });
15
+ const [code, setCode] = useState("");
16
+ const [error, setError] = useState("");
17
+ const [busy, setBusy] = useState(false);
18
+ const attempt = async (fn) => {
19
+ setError("");
20
+ setBusy(true);
21
+ try {
22
+ await fn();
23
+ }
24
+ catch (err) {
25
+ setError(err instanceof Error ? err.message : String(err));
26
+ }
27
+ finally {
28
+ setBusy(false);
29
+ }
30
+ };
31
+ const back = (_jsx(Link, { href: signIn, className: "text-brand-500 hover:text-brand-600", children: "Back to sign in" }));
32
+ if (step.kind === "done") {
33
+ return (_jsx(AuthLayout, { name: config.name, title: "Password changed", footer: back, children: _jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: "Your password is changed, and you are signed out everywhere. Sign in with the new one." }) }));
34
+ }
35
+ if (step.kind === "password") {
36
+ const save = (event) => {
37
+ event.preventDefault();
38
+ const f = new FormData(event.currentTarget);
39
+ if (f.get("password") !== f.get("again")) {
40
+ setError("The two passwords aren't the same.");
41
+ return;
42
+ }
43
+ attempt(async () => {
44
+ await call("/v1/auth/reset-password", {
45
+ body: { token: step.token, password: f.get("password") },
46
+ });
47
+ setStep({ kind: "done" });
48
+ });
49
+ };
50
+ return (_jsxs(AuthLayout, { name: config.name, title: "Choose a new password", footer: back, children: [error !== "" && _jsx(Alert, { children: error }), _jsxs("form", { className: "animate-slide-in space-y-5", onSubmit: save, children: [_jsx(Field, { label: "New password", name: "password", type: "password", autoComplete: "new-password" }), _jsx(Field, { label: "Again", name: "again", type: "password", autoComplete: "new-password" }), _jsx(Button, { type: "submit", busy: busy, children: "Change password" })] })] }));
51
+ }
52
+ if (step.kind === "code") {
53
+ const verify = (value) => attempt(async () => {
54
+ const verified = await call("/v1/auth/verifications/verify", {
55
+ body: { verification_id: step.verificationId, code: value },
56
+ });
57
+ setStep({ kind: "password", token: verified.data.verification_token });
58
+ });
59
+ return (_jsx(AuthLayout, { name: config.name, title: "Check your email", subtitle: _jsxs(_Fragment, { children: ["If ", _jsx("span", { className: "font-medium", children: step.email }), " has an account, we sent it a code."] }), footer: back, children: _jsxs("div", { className: "animate-slide-in space-y-4", children: [error !== "" && _jsx(Alert, { children: error }), _jsx(CodeInput, { value: code, onChange: setCode, onComplete: verify, disabled: busy }), _jsx(Button, { busy: busy, onClick: () => verify(code), children: "Continue" })] }) }));
60
+ }
61
+ const send = (event) => {
62
+ event.preventDefault();
63
+ const email = String(new FormData(event.currentTarget).get("email")).trim();
64
+ attempt(async () => {
65
+ const res = await call("/v1/auth/forgot-password", {
66
+ body: { email, mode: "code" },
67
+ });
68
+ setCode("");
69
+ setStep({ kind: "code", email, verificationId: res.verification_id });
70
+ });
71
+ };
72
+ return (_jsxs(AuthLayout, { name: config.name, title: "Forgot your password?", subtitle: "Enter your email, and we'll send you a code to choose a new one.", footer: back, children: [error !== "" && _jsx(Alert, { children: error }), _jsxs("form", { className: "animate-fade-in space-y-5", onSubmit: send, children: [_jsx(Field, { label: "Email", name: "email", type: "email", autoComplete: "username" }), _jsx(Button, { type: "submit", busy: busy, children: "Send the code" })] })] }));
73
+ }
@@ -0,0 +1 @@
1
+ export default function LedgerPage(): import("react").JSX.Element;
@@ -0,0 +1,132 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // The ledger's admin side (docs/ledger.md): the adjustments waiting for a
4
+ // second admin (ledger.approve), an account looked up by ID with freeze and
5
+ // unfreeze (ledger.manage), and a request for an adjustment (ledger.adjust,
6
+ // with re-authentication). Every change asks for a reason. Shown only when
7
+ // the ledger module is on (its permissions exist only then).
8
+ import { useEffect, useState } from "react";
9
+ import { Cancelled, useAction } from "../actions";
10
+ import * as ledger from "../api/ledger.gen";
11
+ import { ApiError, api } from "../client";
12
+ import { formatDateTime } from "../dates";
13
+ import { PageHeader } from "../kit/page-header";
14
+ import { formatMoney } from "../money";
15
+ import { useCan } from "../shell";
16
+ import { DataTable } from "../table";
17
+ import { Alert } from "../ui";
18
+ const input = "w-full rounded-lg border border-gray-300 bg-transparent px-3 py-2 text-sm text-gray-800 focus:border-brand-300 focus:outline-none dark:border-gray-700 dark:text-white/90";
19
+ const card = "space-y-4 rounded-2xl border border-gray-200 bg-white p-5 dark:border-gray-800 dark:bg-white/[0.03]";
20
+ const small = "rounded-lg border border-gray-300 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-50 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300";
21
+ /** Runs a change, showing its error unless the user cancelled a dialog. */
22
+ function useChange() {
23
+ const { run, dialogs } = useAction();
24
+ const [error, setError] = useState("");
25
+ const change = async (fn) => {
26
+ setError("");
27
+ try {
28
+ return await run(fn);
29
+ }
30
+ catch (err) {
31
+ if (!(err instanceof Cancelled)) {
32
+ setError(err instanceof Error ? err.message : String(err));
33
+ }
34
+ return undefined;
35
+ }
36
+ };
37
+ return { change, error, dialogs };
38
+ }
39
+ export default function LedgerPage() {
40
+ const canApprove = useCan(ledger.PermissionApprove);
41
+ const canManage = useCan(ledger.PermissionManage);
42
+ const canAdjust = useCan(ledger.PermissionAdjust);
43
+ const [accountId, setAccountId] = useState("");
44
+ return (_jsxs("div", { className: "space-y-6", children: [_jsx(PageHeader, { title: "Ledger" }), canApprove && _jsx(Approvals, { onAccount: setAccountId }), canManage && _jsx(AccountLookup, { id: accountId, onId: setAccountId }), canAdjust && _jsx(RequestAdjustment, { accountId: accountId })] }));
45
+ }
46
+ function Approvals({ onAccount }) {
47
+ const [status, setStatus] = useState(ledger.AdjustmentPending);
48
+ const [reload, setReload] = useState(0);
49
+ const { change, error, dialogs } = useChange();
50
+ const decide = async (a, approve) => {
51
+ const done = await change((o) => api.post(`/v1/ledger/adjustments/${a.id}/${approve ? "approve" : "reject"}`, undefined, o));
52
+ if (done !== undefined) {
53
+ setReload((n) => n + 1);
54
+ }
55
+ };
56
+ return (_jsxs("section", { className: card, children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsx("h2", { className: "font-medium text-gray-800 dark:text-white/90", children: "Adjustments" }), _jsxs("select", { "aria-label": "Status", value: status, onChange: (e) => setStatus(e.target.value), className: `${input} max-w-48`, children: [_jsx("option", { value: ledger.AdjustmentPending, children: "Waiting for approval" }), _jsx("option", { value: ledger.AdjustmentApproved, children: "Approved" }), _jsx("option", { value: ledger.AdjustmentRejected, children: "Rejected" })] })] }), error !== "" && _jsx(Alert, { children: error }), _jsx(DataTable, { path: "/v1/ledger/adjustments", query: { status }, reload: reload, empty: "None.", columns: [
57
+ { header: "Requested", cell: (a) => formatDateTime(a.created_at) },
58
+ {
59
+ header: "Account",
60
+ cell: (a) => (_jsx("button", { type: "button", onClick: () => onAccount(a.account_id), className: "font-mono text-xs text-brand-500 hover:underline", children: a.account_id })),
61
+ },
62
+ { header: "Amount", cell: (a) => formatMoney(a.amount) },
63
+ { header: "Reason", cell: (a) => a.reason },
64
+ {
65
+ header: "By",
66
+ cell: (a) => _jsx("span", { className: "font-mono text-xs", children: a.requested_by }),
67
+ },
68
+ {
69
+ header: "",
70
+ cell: (a) => a.status === ledger.AdjustmentPending && (_jsxs("span", { className: "flex gap-2", children: [_jsx("button", { type: "button", className: small, onClick: () => decide(a, true), children: "Approve" }), _jsx("button", { type: "button", className: small, onClick: () => decide(a, false), children: "Reject" })] })),
71
+ },
72
+ ] }), _jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: "The admin who requested an adjustment can't decide it." }), dialogs] }));
73
+ }
74
+ function AccountLookup({ id, onId }) {
75
+ const [account, setAccount] = useState(null);
76
+ const [loadError, setLoadError] = useState("");
77
+ const { change, error, dialogs } = useChange();
78
+ // The account typed in, or picked in the adjustments table.
79
+ useEffect(() => {
80
+ if (id === "") {
81
+ return;
82
+ }
83
+ let current = true;
84
+ setLoadError("");
85
+ setAccount(null);
86
+ api
87
+ .get(`/v1/ledger/accounts/${id}`)
88
+ .then((a) => current && setAccount(a))
89
+ .catch((err) => current &&
90
+ setLoadError(err instanceof ApiError && err.status === 404 ? "No account has this ID." : err.message));
91
+ return () => {
92
+ current = false;
93
+ };
94
+ }, [id]);
95
+ const find = (event) => {
96
+ event.preventDefault();
97
+ onId(String(new FormData(event.currentTarget).get("id")).trim());
98
+ };
99
+ const freeze = async (frozen) => {
100
+ if (account === null) {
101
+ return;
102
+ }
103
+ const res = await change((o) => api.post(`/v1/ledger/accounts/${account.id}/${frozen ? "freeze" : "unfreeze"}`, undefined, o));
104
+ if (res !== undefined) {
105
+ setAccount(res);
106
+ }
107
+ };
108
+ return (_jsxs("section", { className: card, children: [_jsx("h2", { className: "font-medium text-gray-800 dark:text-white/90", children: "Account" }), _jsxs("form", { onSubmit: find, className: "flex gap-2", children: [_jsx("input", { name: "id", required: true, "aria-label": "Account ID", placeholder: "Account ID", defaultValue: id, className: `${input} max-w-md font-mono` }, id), _jsx("button", { type: "submit", className: "rounded-lg bg-brand-500 px-4 text-sm font-medium text-white hover:bg-brand-600", children: "Find" })] }), loadError !== "" && _jsx(Alert, { children: loadError }), error !== "" && _jsx(Alert, { children: error }), account !== null && (_jsxs("div", { className: "grid gap-4 md:grid-cols-[1fr_auto]", children: [_jsxs("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-sm", children: [_jsx("dt", { className: "text-gray-500", children: "Owner" }), _jsxs("dd", { className: "font-mono text-xs", children: [account.owner.type, ": ", account.owner.id] }), _jsx("dt", { className: "text-gray-500", children: "Kind" }), _jsxs("dd", { children: [account.type, " \u00B7 ", account.kind, " \u00B7 ", account.currency] }), _jsx("dt", { className: "text-gray-500", children: "Status" }), _jsx("dd", { className: account.status === ledger.StatusActive ? "" : "text-red-600", children: account.status }), _jsx("dt", { className: "text-gray-500", children: "Balance" }), _jsx("dd", { children: formatMoney(account.balance) }), _jsx("dt", { className: "text-gray-500", children: "Held" }), _jsx("dd", { children: formatMoney(account.held) }), _jsx("dt", { className: "text-gray-500", children: "Available" }), _jsx("dd", { className: "font-medium", children: formatMoney(account.available) })] }), _jsxs("div", { children: [account.status === ledger.StatusActive && (_jsx("button", { type: "button", className: small, onClick: () => freeze(true), children: "Freeze (nothing can leave it)" })), account.status === ledger.StatusFrozen && (_jsx("button", { type: "button", className: small, onClick: () => freeze(false), children: "Unfreeze" }))] })] })), dialogs] }));
109
+ }
110
+ function RequestAdjustment({ accountId }) {
111
+ const [minor, setMinor] = useState("");
112
+ const [currency, setCurrency] = useState("");
113
+ const [result, setResult] = useState(null);
114
+ const { change, error, dialogs } = useChange();
115
+ const submit = async (event) => {
116
+ event.preventDefault();
117
+ const f = new FormData(event.currentTarget);
118
+ const reason = String(f.get("reason")).trim();
119
+ setResult(null);
120
+ // The form's reason is the adjustment's, and the audit log's: the API
121
+ // then asks only for re-authentication.
122
+ const res = await change((o) => api.post("/v1/ledger/adjustments", { account_id: String(f.get("account_id")).trim(), amount: Number(minor), reason }, { ...o, reason: o.reason ?? reason }));
123
+ if (res !== undefined) {
124
+ setResult(res);
125
+ }
126
+ };
127
+ return (_jsxs("section", { className: card, children: [_jsx("h2", { className: "font-medium text-gray-800 dark:text-white/90", children: "Request an adjustment" }), _jsxs("form", { onSubmit: submit, className: "grid gap-3 md:grid-cols-2", children: [_jsx("input", { name: "account_id", required: true, "aria-label": "Account ID", placeholder: "Account ID", defaultValue: accountId, className: `${input} font-mono` }, accountId), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("input", { required: true, type: "number", step: 1, "aria-label": "Amount in minor units", placeholder: "Minor units: 5000, or -5000 to take", value: minor, onChange: (e) => setMinor(e.target.value), className: input }), _jsx("input", { "aria-label": "Currency, for the preview", placeholder: "NGN", maxLength: 3, value: currency, onChange: (e) => setCurrency(e.target.value.toUpperCase()), className: `${input} w-20` })] }), _jsx("input", { name: "reason", required: true, "aria-label": "Reason", placeholder: "Reason (kept with the adjustment)", className: `${input} md:col-span-2` }), _jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400 md:col-span-2", children: minor !== "" && currency.length === 3
128
+ ? `${formatMoney({ amount: Number(minor), currency })}: check it.`
129
+ : "The amount is in minor units (kobo, cents), as the API takes it." }), _jsx("div", { className: "md:col-span-2", children: _jsx("button", { type: "submit", className: "rounded-lg bg-brand-500 px-4 py-2 text-sm font-medium text-white hover:bg-brand-600", children: "Request" }) })] }), error !== "" && _jsx(Alert, { children: error }), result !== null && (_jsxs("p", { className: "text-sm text-gray-700 dark:text-gray-300", children: [formatMoney(result.amount), ":", " ", result.status === ledger.AdjustmentApproved
130
+ ? "posted (within the amount one admin may post)."
131
+ : "waiting for a second admin to approve it."] })), dialogs] }));
132
+ }
@@ -0,0 +1 @@
1
+ export default function RolesPage(): import("react").JSX.Element;