@copilotz/directory 1.0.0-rc.80 → 1.0.0-rc.81

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 (68) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -68
  3. package/contract.d.ts +1 -8
  4. package/contract.js +1 -8
  5. package/mod.d.ts +2 -67
  6. package/mod.js +2 -122
  7. package/package.json +9 -35
  8. package/web.d.ts +2 -36
  9. package/web.js +2 -57
  10. package/WORDS.md +0 -198
  11. package/actions/code.d.ts +0 -4
  12. package/actions/code.js +0 -135
  13. package/actions/host.d.ts +0 -2
  14. package/actions/host.js +0 -55
  15. package/actions/invite.d.ts +0 -5
  16. package/actions/invite.js +0 -129
  17. package/actions/org.d.ts +0 -10
  18. package/actions/org.js +0 -273
  19. package/collections/credit-code.d.ts +0 -107
  20. package/collections/credit-code.js +0 -28
  21. package/collections/invite.d.ts +0 -74
  22. package/collections/invite.js +0 -20
  23. package/collections/membership.d.ts +0 -65
  24. package/collections/membership.js +0 -22
  25. package/collections/org-host.d.ts +0 -55
  26. package/collections/org-host.js +0 -30
  27. package/collections/org.d.ts +0 -134
  28. package/collections/org.js +0 -58
  29. package/collections/staff.d.ts +0 -35
  30. package/collections/staff.js +0 -12
  31. package/routes/console.d.ts +0 -26
  32. package/routes/console.js +0 -129
  33. package/routes/enter.d.ts +0 -18
  34. package/routes/enter.js +0 -47
  35. package/routes/forward.d.ts +0 -35
  36. package/routes/forward.js +0 -119
  37. package/routes/orgs.d.ts +0 -25
  38. package/routes/orgs.js +0 -113
  39. package/routes/signout.d.ts +0 -11
  40. package/routes/signout.js +0 -36
  41. package/shared/enter.d.ts +0 -36
  42. package/shared/enter.js +0 -82
  43. package/shared/http.d.ts +0 -42
  44. package/shared/http.js +0 -77
  45. package/shared/member.d.ts +0 -21
  46. package/shared/member.js +0 -73
  47. package/shared/settings.d.ts +0 -53
  48. package/shared/settings.js +0 -16
  49. package/shared/state.d.ts +0 -74
  50. package/shared/state.js +0 -101
  51. package/views/web/codes.d.ts +0 -27
  52. package/views/web/codes.js +0 -50
  53. package/views/web/console-codes.d.ts +0 -37
  54. package/views/web/console-codes.js +0 -166
  55. package/views/web/console.d.ts +0 -37
  56. package/views/web/console.js +0 -224
  57. package/views/web/lists.d.ts +0 -48
  58. package/views/web/lists.js +0 -42
  59. package/views/web/org.d.ts +0 -12
  60. package/views/web/org.js +0 -62
  61. package/views/web/orgs.d.ts +0 -148
  62. package/views/web/orgs.js +0 -253
  63. package/views/web/style.d.ts +0 -6
  64. package/views/web/style.js +0 -197
  65. package/views/web/switcher.d.ts +0 -81
  66. package/views/web/switcher.js +0 -367
  67. package/views/web/words.d.ts +0 -10
  68. package/views/web/words.js +0 -206
package/shared/state.js DELETED
@@ -1,101 +0,0 @@
1
- /**
2
- * What a directory keeps in memory, beside its store, shared by its routes
3
- * and the orgs it opened (`member(dir, org)`): one per directory runtime,
4
- * by its resources (the same object for its routes and for the app's `dir`).
5
- *
6
- * - **The handoff's key**: entering an org, the directory signs who goes in
7
- * (`/enter`, see member.ts) with a key of its own, made at start; the org
8
- * checks it. A handoff lives a minute, and never leaves the process.
9
- * - **Orgs as the directory has them** (`org.info`), kept 10 seconds, and
10
- * **hosts orgs claimed** (`orgHost.resolve`), a minute: every request asks.
11
- * What changes them here (a rename, a suspension, a claim) forgets them
12
- * at once.
13
- * - **When each org last told how it is** (`org.report`): at most once a
14
- * minute while it's used.
15
- */
16
- import { signLink, verifyLink } from "copilotz";
17
- const INFO_MS = 10_000;
18
- const CLAIMS_MS = 60_000;
19
- /** How long a handoff is good for. */
20
- export const HANDOFF_MS = 60_000;
21
- /** What a handoff signs: the org's own route, under its address. */
22
- export const HANDOFF = "/enter";
23
- const states = new WeakMap();
24
- /** The directory's state, by its resources. */
25
- export function stateOf(resources) {
26
- let state = states.get(resources);
27
- if (!state) {
28
- const bytes = crypto.getRandomValues(new Uint8Array(32));
29
- state = {
30
- handoff: {
31
- origin: "https://directory.invalid",
32
- secret: Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join(""),
33
- },
34
- info: new Map(),
35
- claims: new Map(),
36
- reported: new Map(),
37
- };
38
- states.set(resources, state);
39
- }
40
- return state;
41
- }
42
- /** A value kept a while, asked again once it's past (or failed). */
43
- function kept(map, key, ms, ask) {
44
- const found = map.get(key);
45
- if (found && found.until > Date.now())
46
- return found.value;
47
- const value = ask();
48
- map.set(key, { value, until: Date.now() + ms });
49
- value.catch(() => map.delete(key));
50
- return value;
51
- }
52
- /** An org as the directory has it, kept a little while. */
53
- export const infoOf = (dir, resources, org) => kept(stateOf(resources).info, org, INFO_MS, () => dir.query("org.info", { org }));
54
- /** A host as claims keep it: lowercase, no trailing dot. */
55
- export const plainHost = (host) => String(host ?? "").trim().toLowerCase().replace(/\.$/, "");
56
- /** Whose a host is, kept a minute. */
57
- export const claimOf = (dir, resources, host) => kept(stateOf(resources).claims, plainHost(host), CLAIMS_MS, () => dir.query("orgHost.resolve", { host: plainHost(host) }));
58
- /** Forgets what's kept of an org, or of a host, here: it just changed. */
59
- export function forget(resources, what) {
60
- const state = stateOf(resources);
61
- if (what.org !== undefined)
62
- state.info.delete(what.org);
63
- if (what.host !== undefined)
64
- state.claims.delete(plainHost(what.host));
65
- }
66
- /** A handoff, signed: the query of the org's `/enter`. */
67
- export async function signHandoff(resources, handoff) {
68
- const params = {};
69
- for (const [name, value] of Object.entries(handoff)) {
70
- if (value === undefined || value === false || value === "")
71
- continue;
72
- params[name] = value === true ? "1" : String(value);
73
- }
74
- const link = await signLink(stateOf(resources).handoff, HANDOFF, params, HANDOFF_MS);
75
- return new URL(link).search;
76
- }
77
- /** A handoff the directory signed, from an `/enter` request's query; undefined for any other. */
78
- export async function readHandoff(resources, query) {
79
- const params = await verifyLink(stateOf(resources).handoff, HANDOFF, Object.fromEntries(query));
80
- if (!params?.org || !params.person)
81
- return undefined;
82
- return {
83
- org: params.org,
84
- person: params.person,
85
- ...(params.email ? { email: params.email } : {}),
86
- ...(params.name ? { name: params.name } : {}),
87
- ...(params.picture ? { picture: params.picture } : {}),
88
- ...(params.role ? { role: params.role } : {}),
89
- ...(params.staff === "1" ? { staff: true } : {}),
90
- ...(params.to ? { to: params.to } : {}),
91
- };
92
- }
93
- /** Whether an org's report is due (at most once a minute), counting this one. */
94
- export function reportDue(resources, org) {
95
- const reported = stateOf(resources).reported;
96
- const now = Date.now();
97
- if (now - (reported.get(org) ?? 0) < 60_000)
98
- return false;
99
- reported.set(org, now);
100
- return true;
101
- }
@@ -1,27 +0,0 @@
1
- import type { GiftCode } from "./orgs.js";
2
- export type CodeStatus = "waiting" | "claimed" | "revoked" | "expired";
3
- /** Where a code stands: claimed, taken back, past its last moment, or still waiting. */
4
- export declare function codeStatus(code: GiftCode, now?: string): CodeStatus;
5
- /** The status as a label (said now, in the app's words), with the toolkit's tone for it. */
6
- export declare const statusOf: (status: CodeStatus) => {
7
- label: string;
8
- tone: "success" | "neutral" | "primary" | "warning";
9
- };
10
- /** What the form asks for, as `POST /console/codes` takes it; or why it can't be. */
11
- export declare function newCodeOf(form: {
12
- amount: string;
13
- expires: string;
14
- until: string;
15
- note: string;
16
- }): {
17
- amount: number;
18
- expires?: string;
19
- until?: string;
20
- note?: string;
21
- } | {
22
- error: string;
23
- };
24
- /** A day (`YYYY-MM-DD`, or a moment's), as the calendar has it, wherever you are. */
25
- export declare const dayOf: (at: string) => string;
26
- /** US dollars, cents only when there are some. */
27
- export declare const dollarsOf: (n: number) => string;
@@ -1,50 +0,0 @@
1
- /**
2
- * Gift codes in staff's console, as words: where each stands, and what a person
3
- * types turned into what's asked for. Pure.
4
- */
5
- import { formatDate, formatNumber } from "copilotz/web/words";
6
- import { say } from "./words.js";
7
- /** Where a code stands: claimed, taken back, past its last moment, or still waiting. */
8
- export function codeStatus(code, now = new Date().toISOString()) {
9
- if (code.org)
10
- return "claimed";
11
- if (code.revoked)
12
- return "revoked";
13
- if (code.until && code.until <= now)
14
- return "expired";
15
- return "waiting";
16
- }
17
- /** The status as a label (said now, in the app's words), with the toolkit's tone for it. */
18
- export const statusOf = (status) => ({
19
- waiting: { label: say("codeWaiting"), tone: "primary" },
20
- claimed: { label: say("codeClaimed"), tone: "success" },
21
- revoked: { label: say("codeRevoked"), tone: "neutral" },
22
- expired: { label: say("codeExpired"), tone: "neutral" },
23
- })[status];
24
- /** What the form asks for, as `POST /console/codes` takes it; or why it can't be. */
25
- export function newCodeOf(form) {
26
- const amount = Number(form.amount.trim().replace(/^\$\s*/, "").replace(/,/g, ""));
27
- if (!Number.isFinite(amount) || amount <= 0)
28
- return { error: say("sayDollars") };
29
- return {
30
- amount: Math.round(amount * 100) / 100,
31
- ...(form.expires ? { expires: form.expires } : {}),
32
- // A code can be claimed through the whole of its last day.
33
- ...(form.until ? { until: `${form.until}T23:59:59.999Z` } : {}),
34
- ...(form.note.trim() ? { note: form.note.trim() } : {}),
35
- };
36
- }
37
- /** A day (`YYYY-MM-DD`, or a moment's), as the calendar has it, wherever you are. */
38
- export const dayOf = (at) => formatDate(new Date(`${at.slice(0, 10)}T00:00:00Z`), {
39
- timeZone: "UTC",
40
- month: "short",
41
- day: "numeric",
42
- year: "numeric",
43
- });
44
- /** US dollars, cents only when there are some. */
45
- export const dollarsOf = (n) => formatNumber(n, {
46
- style: "currency",
47
- currency: "USD",
48
- minimumFractionDigits: Math.round(n * 100) % 100 ? 2 : 0,
49
- maximumFractionDigits: 2,
50
- });
@@ -1,37 +0,0 @@
1
- /**
2
- * Gift codes in staff's console (at `/console?tab=codes`): making one (how many
3
- * dollars of credits, when they lapse, the last day it can be claimed, what
4
- * it's for), which shows the code just this once, with a way to copy it and a
5
- * clear word that it won't be shown again, since only its hash is kept. Then
6
- * every code, newest first: how much, for what, where it stands, which org
7
- * claimed it; and taking back one nobody has claimed.
8
- */
9
- import { type ReactNode } from "react";
10
- import { type ConsoleOrg, type GiftCode } from "./orgs.js";
11
- export declare function GiftCodes({ orgs, ready }: {
12
- orgs: ConsoleOrg[];
13
- ready: boolean;
14
- }): ReactNode;
15
- export declare function Row({ code, orgName, onRevoke }: {
16
- code: GiftCode;
17
- orgName(id: string): string;
18
- onRevoke(): void;
19
- }): ReactNode;
20
- export declare function NewCode({ open, close, onMade }: {
21
- open: boolean;
22
- close(): void;
23
- onMade(code: string, amount: number): void;
24
- }): ReactNode;
25
- /** The code, just this once. */
26
- export declare function ShownOnce({ made, close }: {
27
- made?: {
28
- code: string;
29
- amount: number;
30
- };
31
- close(): void;
32
- }): ReactNode;
33
- export declare function Revoke({ code, close, onDone }: {
34
- code?: GiftCode;
35
- close(): void;
36
- onDone(): void;
37
- }): ReactNode;
@@ -1,166 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /**
3
- * Gift codes in staff's console (at `/console?tab=codes`): making one (how many
4
- * dollars of credits, when they lapse, the last day it can be claimed, what
5
- * it's for), which shows the code just this once, with a way to copy it and a
6
- * clear word that it won't be shown again, since only its hash is kept. Then
7
- * every code, newest first: how much, for what, where it stands, which org
8
- * claimed it; and taking back one nobody has claimed.
9
- */
10
- import { useEffect, useState } from "react";
11
- import { Badge, Button, CopyButton, Dialog, EmptyState, Field, Input, message, Notice, Skeleton, Time, } from "copilotz/web";
12
- import { createGiftCode, giftCodes, revokeGiftCode, } from "./orgs.js";
13
- import { codeStatus, dayOf, dollarsOf, newCodeOf, statusOf } from "./codes.js";
14
- import { say } from "./words.js";
15
- const STYLE = `
16
- .console-tabs { display: flex; margin-bottom: 18px; }
17
- .codes { container: codes / inline-size; display: grid; gap: 14px; }
18
- .codes-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
19
- .codes-tools p { margin: 0; color: var(--muted-foreground); font-size: 13px; }
20
- .codes-list { display: grid; margin: 0; padding: 0; list-style: none; border: 1px solid var(--border);
21
- border-radius: var(--radius-lg); background: var(--card); overflow: hidden; }
22
- .codes-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) minmax(120px, .8fr) 104px; align-items: center;
23
- gap: 8px 16px; min-height: 56px; padding: 10px 14px; }
24
- .codes-row + .codes-row { border-top: 1px solid var(--border); }
25
- .codes-amount { font-family: var(--font-display); font-size: 17px; font-weight: 650; letter-spacing: -.01em;
26
- font-variant-numeric: tabular-nums; }
27
- .codes-what { display: grid; gap: 1px; min-width: 0; font-size: 13.5px; line-height: 1.4; }
28
- .codes-what code { color: var(--secondary-foreground); font-size: 12px; }
29
- .codes-what small { color: var(--muted-foreground); font-size: 12.5px; }
30
- .codes-note { overflow: hidden; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
31
- .codes-end { display: flex; justify-content: flex-end; }
32
- .codes-status { display: grid; justify-items: start; gap: 2px; min-width: 0; color: var(--muted-foreground); font-size: 12.5px; }
33
- .codes-status span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
34
- .codes-form { display: grid; gap: 14px; }
35
- .codes-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; align-items: start; }
36
- .codes-money::before { content: "$"; color: var(--muted-foreground); font-size: 14.5px; }
37
- .codes-shown { display: flex; align-items: center; gap: 6px; padding: 12px 8px 12px 14px; border: 1px solid var(--border);
38
- border-radius: var(--radius-lg); background: var(--muted); }
39
- .codes-shown code { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 14.5px; font-weight: 600; line-height: 1.5;
40
- overflow-wrap: anywhere; user-select: all; }
41
- .codes-once { display: grid; gap: 12px; }
42
- .codes-text { margin: 0; color: var(--secondary-foreground); font-size: 14px; line-height: 1.55; }
43
- @container codes (max-width: 620px) {
44
- .codes-row { grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
45
- .codes-what { grid-column: 1 / -1; grid-row: 2; }
46
- .codes-status { grid-column: 1; grid-row: 3; }
47
- .codes-end { grid-column: 2; grid-row: 1; }
48
- }
49
- @media (max-width: 480px) {
50
- .codes-two { grid-template-columns: minmax(0, 1fr); }
51
- }
52
- `;
53
- export function GiftCodes({ orgs, ready }) {
54
- const [codes, setCodes] = useState();
55
- const [error, setError] = useState();
56
- const [making, setMaking] = useState(false);
57
- const [made, setMade] = useState();
58
- const [revoking, setRevoking] = useState();
59
- const load = async () => {
60
- try {
61
- setCodes(await giftCodes());
62
- setError(undefined);
63
- }
64
- catch (e) {
65
- setError(message(e));
66
- }
67
- };
68
- useEffect(() => {
69
- if (ready)
70
- void load();
71
- }, [ready]);
72
- const orgName = (id) => orgs.find((o) => o.id === id)?.name ?? id;
73
- return (_jsxs("div", { className: "codes", children: [_jsx("style", { href: "console-codes", precedence: "copilotz", children: STYLE }), _jsxs("div", { className: "codes-tools", children: [_jsx("p", { children: codes ? say("codesCount", { count: codes.length }) : " " }), _jsx(Button, { variant: "primary", icon: "plus", onClick: () => setMaking(true), children: say("newGiftCode") })] }), error && !codes
74
- ? (_jsx(Notice, { tone: "destructive", role: "alert", action: _jsx(Button, { size: "sm", onClick: () => void load(), children: say("tryAgain") }), children: error }))
75
- : null, !codes && !error
76
- ? (_jsx("div", { className: "codes-list", "aria-busy": "true", children: [0, 1, 2].map((i) => _jsx(Skeleton, { height: 56, radius: "sm" }, i)) }))
77
- : null, codes && !codes.length
78
- ? (_jsx(EmptyState, { icon: "star", title: say("noCodes"), action: _jsx(Button, { icon: "plus", onClick: () => setMaking(true), children: say("newGiftCode") }), children: say("noCodesAbout") }))
79
- : null, codes?.length
80
- ? (_jsx("ul", { className: "codes-list", children: codes.map((code) => (_jsx(Row, { code: code, orgName: orgName, onRevoke: () => setRevoking(code) }, code.id))) }))
81
- : null, _jsx(NewCode, { open: making, close: () => setMaking(false), onMade: (code, amount) => {
82
- setMaking(false);
83
- setMade({ code, amount });
84
- void load();
85
- } }), _jsx(ShownOnce, { made: made, close: () => setMade(undefined) }), _jsx(Revoke, { code: revoking, close: () => setRevoking(undefined), onDone: () => {
86
- setRevoking(undefined);
87
- void load();
88
- } })] }));
89
- }
90
- export function Row({ code, orgName, onRevoke }) {
91
- const status = codeStatus(code);
92
- const { label, tone } = statusOf(status);
93
- const claimBy = status === "waiting" && code.until ? dayOf(code.until) : undefined;
94
- const terms = say(code.expires
95
- ? claimBy ? "termsLapseClaim" : "termsLapse"
96
- : claimBy
97
- ? "termsNoLapseClaim"
98
- : "termsNoLapse", { lapse: code.expires ? dayOf(code.expires) : "", until: claimBy ?? "" });
99
- return (_jsxs("li", { className: "codes-row", children: [_jsx("span", { className: "codes-amount", children: dollarsOf(code.amount) }), _jsxs("span", { className: "codes-what", children: [code.note ? _jsx("span", { className: "codes-note", title: code.note, children: code.note }) : null, _jsx("small", { children: terms }), _jsxs("small", { children: [_jsx("code", { title: say("codeShortTitle"), children: code.short }), " ", say.nodes("codeMade", { time: _jsx(Time, { at: code.at }) })] })] }), _jsxs("span", { className: "codes-status", children: [_jsx(Badge, { tone: tone === "neutral" ? undefined : tone, children: label }), code.org
100
- ? (_jsx("span", { title: code.org, children: say("claimedBy", {
101
- org: orgName(code.org),
102
- day: code.claimed ? dayOf(code.claimed) : "",
103
- }) }))
104
- : null] }), _jsx("span", { className: "codes-end", children: status === "waiting"
105
- ? _jsx(Button, { size: "sm", onClick: onRevoke, children: say("takeBack") })
106
- : null })] }));
107
- }
108
- const EMPTY = { amount: "", expires: "", until: "", note: "" };
109
- export function NewCode({ open, close, onMade }) {
110
- const [form, setForm] = useState(EMPTY);
111
- const [busy, setBusy] = useState(false);
112
- const [error, setError] = useState();
113
- useEffect(() => {
114
- if (!open)
115
- return;
116
- setForm(EMPTY);
117
- setBusy(false);
118
- setError(undefined);
119
- }, [open]);
120
- const asked = newCodeOf(form);
121
- const ready = !("error" in asked);
122
- const set = (field) => (event) => setForm((now) => ({ ...now, [field]: event.target.value }));
123
- const go = async (event) => {
124
- event?.preventDefault();
125
- if ("error" in asked || busy)
126
- return;
127
- setBusy(true);
128
- setError(undefined);
129
- try {
130
- const { code } = await createGiftCode(asked);
131
- onMade(code, asked.amount);
132
- }
133
- catch (e) {
134
- setError(message(e));
135
- setBusy(false);
136
- }
137
- };
138
- return (_jsx(Dialog, { open: open, onClose: close, title: say("newGiftCode"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", onClick: close, disabled: busy, children: say("cancel") }), _jsx(Button, { variant: "primary", loading: busy, disabled: !ready, onClick: () => void go(), children: ready ? say("makeCode", { amount: dollarsOf(asked.amount) }) : say("makeTheCode") })] }), children: _jsxs("form", { className: "codes-form", onSubmit: (event) => void go(event), children: [_jsx(Field, { label: say("credits"), children: (control) => (_jsx(Input, { ...control, autoFocus: true, inputMode: "decimal", placeholder: "25", className: "codes-money", value: form.amount, onChange: set("amount") })) }), _jsxs("div", { className: "codes-two", children: [_jsx(Field, { label: say("lapseOn"), hint: say("lapseHint"), children: (control) => (_jsx(Input, { ...control, type: "date", value: form.expires, onChange: set("expires") })) }), _jsx(Field, { label: say("claimBy"), hint: say("claimHint"), children: (control) => (_jsx(Input, { ...control, type: "date", value: form.until, onChange: set("until") })) })] }), _jsx(Field, { label: say("whatFor"), hint: say("whatForHint"), children: (control) => (_jsx(Input, { ...control, maxLength: 200, placeholder: say("notePlaceholder"), value: form.note, onChange: set("note") })) }), error ? _jsx(Notice, { tone: "destructive", role: "alert", children: error }) : null] }) }));
139
- }
140
- /** The code, just this once. */
141
- export function ShownOnce({ made, close }) {
142
- return (_jsx(Dialog, { open: !!made, onClose: close, title: made ? say("yourCode", { amount: dollarsOf(made.amount) }) : "", footer: _jsx(Button, { variant: "primary", onClick: close, children: say("keptIt") }), children: made
143
- ? (_jsxs("div", { className: "codes-once", children: [_jsxs("div", { className: "codes-shown", children: [_jsx("code", { children: made.code }), _jsx(CopyButton, { text: made.code, label: say("copyCode") })] }), _jsx(Notice, { tone: "warning", title: say("notShownAgain"), children: say("notShownAgainAbout") })] }))
144
- : null }));
145
- }
146
- export function Revoke({ code, close, onDone }) {
147
- const [busy, setBusy] = useState(false);
148
- const [error, setError] = useState();
149
- useEffect(() => {
150
- setBusy(false);
151
- setError(undefined);
152
- }, [code]);
153
- return (_jsxs(Dialog, { open: !!code, onClose: close, size: "sm", title: code ? say("takeBackTitle", { amount: dollarsOf(code.amount) }) : "", footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", onClick: close, disabled: busy, children: say("cancel") }), _jsx(Button, { variant: "destructive", loading: busy, onClick: async () => {
154
- if (!code)
155
- return;
156
- setBusy(true);
157
- try {
158
- await revokeGiftCode(code.id);
159
- onDone();
160
- }
161
- catch (e) {
162
- setError(message(e));
163
- setBusy(false);
164
- }
165
- }, children: say("takeItBack") })] }), children: [_jsx("p", { className: "codes-text", children: say("takeBackAbout") }), error ? _jsx(Notice, { tone: "destructive", role: "alert", children: error }) : null] }));
166
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * The platform console (kind `console`, at `/console`), for staff where the
3
- * app serves many orgs: every org, with what it last reported (its people,
4
- * spaces, when it was last active), where its rows live and whether it's
5
- * suspended; searched by name, id, schema or maker, and filtered by kind or
6
- * status. For each: entering it as staff (on its record, as theirs), and
7
- * from its menu renaming it, suspending it (nobody but staff goes in) or
8
- * lifting that, moving its rows to a schema of its own, downloading them as
9
- * SQL, and deleting it for good, which its exact name confirms. The console
10
- * reads no org's content: only what the directory keeps. Its other tab (`?tab=codes`,
11
- * console-codes.tsx): gift codes of credits, made, listed and taken back.
12
- */
13
- import { type ReactNode } from "react";
14
- import type { ViewContext } from "copilotz";
15
- import { type ConsoleOrg } from "./orgs.js";
16
- export declare const consoleView: (_: unknown, ctx: ViewContext<ReactNode>) => ReactNode;
17
- /** What staff are doing to an org, in a dialog. */
18
- export type Doing = {
19
- what: "rename" | "suspend" | "move" | "delete";
20
- org: ConsoleOrg;
21
- };
22
- /** One org in the console's table. */
23
- export declare function Row({ org, here, inAsStaff, onDo }: {
24
- org: ConsoleOrg;
25
- here: boolean;
26
- inAsStaff: boolean;
27
- onDo(what: Doing["what"]): void;
28
- }): ReactNode;
29
- export type DialogProps = {
30
- doing?: Doing;
31
- close(): void;
32
- finished(note: string): void;
33
- };
34
- export declare function RenameDialog({ doing, close, finished }: DialogProps): ReactNode;
35
- export declare function SuspendDialog({ doing, close, finished }: DialogProps): ReactNode;
36
- export declare function MoveDialog({ doing, close, finished }: DialogProps): ReactNode;
37
- export declare function DeleteDialog({ doing, close, finished }: DialogProps): ReactNode;