@burdenoff/microfe-subscriberbot 2026.1113.1 → 2026.1123.1
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.
- package/dist/subscriberbot/components/InfiniteScrollSentinel.d.ts +24 -0
- package/dist/subscriberbot/components/InfiniteScrollSentinel.js +44 -0
- package/dist/subscriberbot/components/InfiniteScrollSentinel.js.map +1 -0
- package/dist/subscriberbot/components/index.d.ts +4 -0
- package/dist/subscriberbot/components/index.js +5 -2
- package/dist/subscriberbot/components/tags/EntityTagPicker.d.ts +25 -0
- package/dist/subscriberbot/components/tags/EntityTagPicker.js +205 -0
- package/dist/subscriberbot/components/tags/EntityTagPicker.js.map +1 -0
- package/dist/subscriberbot/components/tags/index.d.ts +2 -0
- package/dist/subscriberbot/components/tags/index.js +1 -0
- package/dist/subscriberbot/hooks/index.d.ts +2 -2
- package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts +53 -1
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js +664 -373
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
- package/dist/subscriberbot/pages/AssetVaultPage.js +192 -147
- package/dist/subscriberbot/pages/AssetVaultPage.js.map +1 -1
- package/dist/subscriberbot/pages/DashboardPage.js +9 -9
- package/dist/subscriberbot/pages/DashboardPage.js.map +1 -1
- package/dist/subscriberbot/pages/InboxPage.js +264 -281
- package/dist/subscriberbot/pages/InboxPage.js.map +1 -1
- package/dist/subscriberbot/pages/InsightsPage.js +8 -8
- package/dist/subscriberbot/pages/InvoicesPage.js +62 -78
- package/dist/subscriberbot/pages/InvoicesPage.js.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentDetailPage.js +1 -1
- package/dist/subscriberbot/pages/agents/AgentsListPage.js +5 -5
- package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.js +81 -81
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.js +326 -314
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/providers/ProviderInsights.js +17 -17
- package/dist/subscriberbot/pages/providers/ProviderNewPage.js +153 -140
- package/dist/subscriberbot/pages/providers/ProviderNewPage.js.map +1 -1
- package/dist/subscriberbot/pages/providers/ProvidersListPage.js +135 -146
- package/dist/subscriberbot/pages/providers/ProvidersListPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +482 -437
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js +59 -46
- package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js +104 -111
- package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js.map +1 -1
- package/dist/subscriberbot/types/index.d.ts +40 -1
- package/package.json +12 -9
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { useFormatters as e } from "../hooks/useFormatters.js";
|
|
2
2
|
import "../components/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useFileDownloadUrl as t, useInfiniteAssets as n, useRelationships as r } from "../hooks/useSubscriberBotApi.js";
|
|
4
4
|
import { PageLayout as i } from "../components/PageLayout.js";
|
|
5
5
|
import { MetricsCard as a } from "../components/MetricsCard.js";
|
|
6
6
|
import { EmptyState as o } from "../components/EmptyState.js";
|
|
7
7
|
import { ErrorView as s, LoadingView as c, Section as l } from "../components/StateViews.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
8
|
+
import { InfiniteScrollSentinel as u } from "../components/InfiniteScrollSentinel.js";
|
|
9
|
+
import { useTr as d } from "../hooks/useTr.js";
|
|
10
|
+
import { EntityTagPicker as f, TagFilterSelect as p } from "../components/tags/EntityTagPicker.js";
|
|
11
|
+
import { cn as m } from "../utils/cn.js";
|
|
12
|
+
import { useMemo as h, useState as g } from "react";
|
|
13
|
+
import { AlarmClock as _, Award as v, Download as y, File as b, FileKey as x, FileText as S, Globe as C, Receipt as w, Search as T, ShieldCheck as E, Tag as D, Vault as O } from "lucide-react";
|
|
14
|
+
import { jsx as k, jsxs as A } from "react/jsx-runtime";
|
|
15
|
+
import { GlassCard as j, PagePurpose as M } from "@burdenoff/fe-libs/ui";
|
|
14
16
|
// src/subscriberbot/pages/AssetVaultPage.tsx
|
|
15
|
-
var
|
|
16
|
-
CONTRACT:
|
|
17
|
-
LICENSE_KEY:
|
|
18
|
-
CREDENTIAL:
|
|
19
|
-
CERTIFICATE:
|
|
20
|
-
INVOICE:
|
|
21
|
-
RECEIPT:
|
|
22
|
-
WARRANTY:
|
|
23
|
-
DOMAIN:
|
|
24
|
-
},
|
|
17
|
+
var N = {
|
|
18
|
+
CONTRACT: S,
|
|
19
|
+
LICENSE_KEY: x,
|
|
20
|
+
CREDENTIAL: x,
|
|
21
|
+
CERTIFICATE: v,
|
|
22
|
+
INVOICE: w,
|
|
23
|
+
RECEIPT: w,
|
|
24
|
+
WARRANTY: E,
|
|
25
|
+
DOMAIN: C
|
|
26
|
+
}, P = [
|
|
25
27
|
"CONTRACT",
|
|
26
28
|
"LICENSE_KEY",
|
|
27
29
|
"CREDENTIAL",
|
|
@@ -30,198 +32,241 @@ var k = {
|
|
|
30
32
|
"RECEIPT",
|
|
31
33
|
"WARRANTY",
|
|
32
34
|
"DOMAIN"
|
|
33
|
-
],
|
|
35
|
+
], F = (e) => {
|
|
34
36
|
if (!e) return !1;
|
|
35
37
|
let t = new Date(e).getTime();
|
|
36
38
|
if (Number.isNaN(t)) return !1;
|
|
37
39
|
let n = (t - Date.now()) / 864e5;
|
|
38
40
|
return n >= 0 && n <= 30;
|
|
39
|
-
},
|
|
41
|
+
}, I = (e) => {
|
|
40
42
|
if (!e) return Infinity;
|
|
41
43
|
let t = new Date(e).getTime();
|
|
42
44
|
return Number.isNaN(t) ? Infinity : t;
|
|
43
45
|
};
|
|
44
|
-
function
|
|
45
|
-
let { formatDate: i, formatEnumLabel: a } = e(), o =
|
|
46
|
-
return /* @__PURE__ */
|
|
46
|
+
function L({ asset: n, subscription: r }) {
|
|
47
|
+
let { formatDate: i, formatEnumLabel: a } = e(), o = d(), s = t(), [c, l] = g(!1), [u, p] = g(!1), h = N[n.type] ?? b, _ = F(n.expiresAt);
|
|
48
|
+
return /* @__PURE__ */ A(j, {
|
|
47
49
|
treatment: "metric",
|
|
48
|
-
className: "flex
|
|
49
|
-
children: [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
className: "
|
|
69
|
-
children:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
50
|
+
className: "flex flex-col gap-2 p-4",
|
|
51
|
+
children: [/* @__PURE__ */ A("div", {
|
|
52
|
+
className: "flex items-start gap-3",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ k("span", {
|
|
55
|
+
className: "grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-accent-wash text-text-link",
|
|
56
|
+
children: /* @__PURE__ */ k(h, { className: "h-5 w-5" })
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ A("div", {
|
|
59
|
+
className: "min-w-0 flex-1",
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ k("p", {
|
|
62
|
+
className: "truncate font-medium text-text-primary",
|
|
63
|
+
children: n.name
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ k("p", {
|
|
66
|
+
className: "truncate text-xs text-text-secondary",
|
|
67
|
+
children: r
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ A("div", {
|
|
70
|
+
className: "mt-1 flex flex-wrap items-center gap-2 text-xs",
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ k("span", {
|
|
73
|
+
className: "rounded bg-bg-sunken px-1.5 py-0.5 text-text-secondary",
|
|
74
|
+
children: a(n.type)
|
|
75
|
+
}),
|
|
76
|
+
n.expiresAt && /* @__PURE__ */ k("span", {
|
|
77
|
+
className: m(_ ? "text-status-warning-text" : "text-text-secondary"),
|
|
78
|
+
children: o("assetVault.expires", "Expires {{date}}", { date: i(n.expiresAt) })
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ A("button", {
|
|
81
|
+
type: "button",
|
|
82
|
+
onClick: () => p((e) => !e),
|
|
83
|
+
"aria-expanded": u,
|
|
84
|
+
className: "inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-text-secondary hover:bg-bg-sunken hover:text-text-primary",
|
|
85
|
+
children: [/* @__PURE__ */ k(D, {
|
|
86
|
+
className: "h-3 w-3",
|
|
87
|
+
"aria-hidden": !0
|
|
88
|
+
}), o("assetVault.tags", "Tags")]
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
}),
|
|
94
|
+
n.file?.id && /* @__PURE__ */ k("button", {
|
|
95
|
+
type: "button",
|
|
96
|
+
onClick: async () => {
|
|
97
|
+
if (n.file?.id && !c) {
|
|
98
|
+
l(!0);
|
|
99
|
+
try {
|
|
100
|
+
let e = await s(n.file.id);
|
|
101
|
+
window.open(e, "_blank", "noopener,noreferrer");
|
|
102
|
+
} finally {
|
|
103
|
+
l(!1);
|
|
104
|
+
}
|
|
87
105
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
},
|
|
107
|
+
disabled: c,
|
|
108
|
+
"aria-label": o("assetVault.downloadAriaLabel", "Download {{name}}", { name: n.name }),
|
|
109
|
+
className: "shrink-0 rounded-lg border border-border-subtle p-2 text-text-secondary hover:text-text-primary disabled:opacity-50",
|
|
110
|
+
children: /* @__PURE__ */ k(y, { className: "h-4 w-4" })
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}), u && /* @__PURE__ */ k("div", {
|
|
114
|
+
className: "border-t border-border-subtle pt-2",
|
|
115
|
+
children: /* @__PURE__ */ k(f, {
|
|
116
|
+
entityType: "SUBSCRIBERBOT_ASSET",
|
|
117
|
+
entityId: n.id,
|
|
118
|
+
compact: !0,
|
|
119
|
+
label: ""
|
|
94
120
|
})
|
|
95
|
-
]
|
|
121
|
+
})]
|
|
96
122
|
});
|
|
97
123
|
}
|
|
98
|
-
var
|
|
99
|
-
let { formatDate:
|
|
124
|
+
var R = 24, z = () => {
|
|
125
|
+
let { formatDate: t, formatEnumLabel: f } = e(), [v, y] = g(""), x = n({
|
|
126
|
+
first: R,
|
|
127
|
+
tagId: v || void 0
|
|
128
|
+
}), C = r({ pagination: { limit: 100 } }), w = d(), [D, N] = g(""), [z, B] = g("ALL"), V = h(() => {
|
|
100
129
|
let e = /* @__PURE__ */ new Map();
|
|
101
|
-
for (let t of
|
|
130
|
+
for (let t of C.data?.items ?? []) e.set(t.id, t.label);
|
|
102
131
|
return e;
|
|
103
|
-
}, [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
]),
|
|
132
|
+
}, [C.data]), H = h(() => {
|
|
133
|
+
let e = /* @__PURE__ */ new Set(), t = [];
|
|
134
|
+
for (let n of x.data?.pages ?? []) for (let r of n.items) e.has(r.id) || (e.add(r.id), t.push(r));
|
|
135
|
+
return t;
|
|
136
|
+
}, [x.data]), U = h(() => H.filter((e) => (z === "ALL" || e.type === z) && (!D || e.name.toLowerCase().includes(D.toLowerCase()))), [
|
|
137
|
+
H,
|
|
138
|
+
z,
|
|
139
|
+
D
|
|
140
|
+
]), W = h(() => {
|
|
108
141
|
let e = /* @__PURE__ */ new Map();
|
|
109
|
-
for (let t of
|
|
110
|
-
return
|
|
111
|
-
}, [
|
|
112
|
-
return
|
|
113
|
-
message:
|
|
114
|
-
onRetry: () => void
|
|
115
|
-
}) : /* @__PURE__ */
|
|
116
|
-
title:
|
|
117
|
-
description:
|
|
142
|
+
for (let t of U) e.set(t.type, [...e.get(t.type) ?? [], t]);
|
|
143
|
+
return P.filter((t) => e.has(t)).map((t) => [t, e.get(t)]);
|
|
144
|
+
}, [U]), G = h(() => H.filter((e) => F(e.expiresAt)).sort((e, t) => I(e.expiresAt) - I(t.expiresAt)), [H]);
|
|
145
|
+
return x.isLoading ? /* @__PURE__ */ k(c, { label: w("assetVault.loading", "Loading your asset vault…") }) : x.isError ? /* @__PURE__ */ k(s, {
|
|
146
|
+
message: w("assetVault.error", "Could not load the asset vault."),
|
|
147
|
+
onRetry: () => void x.refetch()
|
|
148
|
+
}) : /* @__PURE__ */ A(i, {
|
|
149
|
+
title: w("assetVault.title", "Asset vault"),
|
|
150
|
+
description: w("assetVault.description", "Every contract, receipt, license key and document attached to your subscriptions — in one secure place."),
|
|
118
151
|
children: [
|
|
119
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ k(M, {
|
|
120
153
|
className: "mb-2",
|
|
121
|
-
children:
|
|
154
|
+
children: w("assetVault.purpose", "Your subscription documents, together — contracts, receipts, license keys and more. Assets are stored in the shared files service and linked to the subscription they belong to. Attach new documents from any relationship’s detail page.")
|
|
122
155
|
}),
|
|
123
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ A("div", {
|
|
124
157
|
className: "grid grid-cols-1 gap-4 sm:grid-cols-3",
|
|
125
158
|
children: [
|
|
126
|
-
/* @__PURE__ */
|
|
127
|
-
icon: /* @__PURE__ */
|
|
128
|
-
value:
|
|
129
|
-
label:
|
|
159
|
+
/* @__PURE__ */ k(a, {
|
|
160
|
+
icon: /* @__PURE__ */ k(b, { className: "h-5 w-5" }),
|
|
161
|
+
value: H.length,
|
|
162
|
+
label: w("assetVault.metrics.documentsStored", "Documents stored")
|
|
130
163
|
}),
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
icon: /* @__PURE__ */
|
|
133
|
-
value:
|
|
134
|
-
label:
|
|
164
|
+
/* @__PURE__ */ k(a, {
|
|
165
|
+
icon: /* @__PURE__ */ k(S, { className: "h-5 w-5" }),
|
|
166
|
+
value: W.length,
|
|
167
|
+
label: w("assetVault.metrics.documentTypes", "Document types")
|
|
135
168
|
}),
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
icon: /* @__PURE__ */
|
|
138
|
-
value:
|
|
139
|
-
label:
|
|
140
|
-
trend:
|
|
169
|
+
/* @__PURE__ */ k(a, {
|
|
170
|
+
icon: /* @__PURE__ */ k(E, { className: "h-5 w-5" }),
|
|
171
|
+
value: G.length,
|
|
172
|
+
label: w("assetVault.metrics.expiring30Days", "Expiring within 30 days"),
|
|
173
|
+
trend: G.length > 0 ? "down" : void 0
|
|
141
174
|
})
|
|
142
175
|
]
|
|
143
176
|
}),
|
|
144
|
-
/* @__PURE__ */
|
|
177
|
+
/* @__PURE__ */ A(j, {
|
|
145
178
|
treatment: "plain",
|
|
146
179
|
className: "flex flex-col gap-3 p-4 sm:flex-row sm:items-center",
|
|
147
|
-
children: [/* @__PURE__ */
|
|
180
|
+
children: [/* @__PURE__ */ A("div", {
|
|
148
181
|
className: "relative flex-1",
|
|
149
|
-
children: [/* @__PURE__ */ T
|
|
150
|
-
value:
|
|
151
|
-
onChange: (e) =>
|
|
152
|
-
placeholder:
|
|
153
|
-
"aria-label":
|
|
182
|
+
children: [/* @__PURE__ */ k(T, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ k("input", {
|
|
183
|
+
value: D,
|
|
184
|
+
onChange: (e) => N(e.target.value),
|
|
185
|
+
placeholder: w("assetVault.searchPlaceholder", "Search documents…"),
|
|
186
|
+
"aria-label": w("assetVault.searchAriaLabel", "Search documents"),
|
|
154
187
|
className: "w-full rounded-lg border border-border-subtle bg-bg-surface py-2 ps-9 pe-3 text-sm text-text-primary placeholder:text-text-secondary"
|
|
155
188
|
})]
|
|
156
|
-
}), /* @__PURE__ */
|
|
157
|
-
className: "flex flex-wrap gap-
|
|
158
|
-
children: [
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
className:
|
|
163
|
-
children:
|
|
164
|
-
|
|
189
|
+
}), /* @__PURE__ */ A("div", {
|
|
190
|
+
className: "flex flex-wrap items-center gap-2",
|
|
191
|
+
children: [/* @__PURE__ */ k(p, {
|
|
192
|
+
value: v,
|
|
193
|
+
onChange: y
|
|
194
|
+
}), /* @__PURE__ */ k("div", {
|
|
195
|
+
className: "flex flex-wrap gap-1.5",
|
|
196
|
+
children: ["ALL", ...P].map((e) => /* @__PURE__ */ k("button", {
|
|
197
|
+
type: "button",
|
|
198
|
+
onClick: () => B(e),
|
|
199
|
+
"aria-pressed": z === e,
|
|
200
|
+
className: m("rounded-full px-3 py-1 text-xs font-medium transition-colors", z === e ? "bg-action-primary-bg text-action-primary-text" : "bg-bg-sunken text-text-secondary hover:text-text-primary"),
|
|
201
|
+
children: e === "ALL" ? w("assetVault.filterAll", "All") : f(e)
|
|
202
|
+
}, e))
|
|
203
|
+
})]
|
|
165
204
|
})]
|
|
166
205
|
}),
|
|
167
|
-
/* @__PURE__ */
|
|
206
|
+
/* @__PURE__ */ A("div", {
|
|
168
207
|
className: "grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_20rem]",
|
|
169
|
-
children: [/* @__PURE__ */
|
|
208
|
+
children: [/* @__PURE__ */ A("div", {
|
|
170
209
|
className: "min-w-0",
|
|
171
|
-
children:
|
|
172
|
-
icon: /* @__PURE__ */
|
|
173
|
-
title:
|
|
174
|
-
description:
|
|
175
|
-
}) :
|
|
176
|
-
title: `${
|
|
177
|
-
children: /* @__PURE__ */
|
|
210
|
+
children: [U.length === 0 ? /* @__PURE__ */ k(o, {
|
|
211
|
+
icon: /* @__PURE__ */ k(O, { className: "h-8 w-8" }),
|
|
212
|
+
title: H.length === 0 ? w("assetVault.empty.noDocumentsTitle", "No documents yet") : w("assetVault.empty.noMatchesTitle", "No matching documents"),
|
|
213
|
+
description: H.length === 0 ? w("assetVault.empty.noDocumentsDescription", "Attach a contract, receipt or license key from any subscription’s detail page and it will appear here.") : w("assetVault.empty.noMatchesDescription", "Try a different search or type filter.")
|
|
214
|
+
}) : W.map(([e, t]) => /* @__PURE__ */ k(l, {
|
|
215
|
+
title: `${f(e)} · ${t.length}`,
|
|
216
|
+
children: /* @__PURE__ */ k("div", {
|
|
178
217
|
className: "grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",
|
|
179
|
-
children: t.map((e) => /* @__PURE__ */
|
|
218
|
+
children: t.map((e) => /* @__PURE__ */ k(L, {
|
|
180
219
|
asset: e,
|
|
181
|
-
subscription:
|
|
220
|
+
subscription: V.get(e.relationshipId) ?? "—"
|
|
182
221
|
}, e.id))
|
|
183
222
|
})
|
|
184
|
-
}, e))
|
|
185
|
-
|
|
223
|
+
}, e)), H.length > 0 && /* @__PURE__ */ k(u, {
|
|
224
|
+
hasNextPage: !!x.hasNextPage,
|
|
225
|
+
isFetchingNextPage: x.isFetchingNextPage,
|
|
226
|
+
isFetching: x.isFetching,
|
|
227
|
+
loadedCount: H.length,
|
|
228
|
+
onLoadMore: () => void x.fetchNextPage()
|
|
229
|
+
})]
|
|
230
|
+
}), H.length > 0 && /* @__PURE__ */ k("aside", {
|
|
186
231
|
className: "lg:sticky lg:top-4 lg:self-start",
|
|
187
|
-
children: /* @__PURE__ */
|
|
232
|
+
children: /* @__PURE__ */ A(j, {
|
|
188
233
|
treatment: "insight",
|
|
189
234
|
className: "p-5",
|
|
190
235
|
children: [
|
|
191
|
-
/* @__PURE__ */
|
|
236
|
+
/* @__PURE__ */ A("h3", {
|
|
192
237
|
className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
|
|
193
|
-
children: [/* @__PURE__ */
|
|
238
|
+
children: [/* @__PURE__ */ k(_, {
|
|
194
239
|
className: "h-4 w-4 text-status-warning-text",
|
|
195
240
|
"aria-hidden": !0
|
|
196
|
-
}),
|
|
241
|
+
}), w("assetVault.expiringSoon.title", "Expiring soon")]
|
|
197
242
|
}),
|
|
198
|
-
/* @__PURE__ */
|
|
243
|
+
/* @__PURE__ */ k("p", {
|
|
199
244
|
className: "mt-0.5 text-xs text-text-secondary",
|
|
200
|
-
children:
|
|
245
|
+
children: w("assetVault.expiringSoon.description", "Documents lapsing in the next 30 days")
|
|
201
246
|
}),
|
|
202
|
-
|
|
247
|
+
G.length === 0 ? /* @__PURE__ */ k("p", {
|
|
203
248
|
className: "mt-4 text-sm text-text-secondary",
|
|
204
|
-
children:
|
|
205
|
-
}) : /* @__PURE__ */
|
|
249
|
+
children: w("assetVault.expiringSoon.nothing", "Nothing in the vault expires in the next 30 days.")
|
|
250
|
+
}) : /* @__PURE__ */ k("ul", {
|
|
206
251
|
className: "mt-4 space-y-2.5",
|
|
207
|
-
children:
|
|
252
|
+
children: G.map((e) => /* @__PURE__ */ A("li", {
|
|
208
253
|
className: "rounded-lg border border-status-warning-border bg-status-warning-bg-subtle p-3",
|
|
209
254
|
children: [
|
|
210
|
-
/* @__PURE__ */
|
|
255
|
+
/* @__PURE__ */ k("p", {
|
|
211
256
|
className: "truncate text-sm font-medium text-status-warning-text",
|
|
212
257
|
children: e.name
|
|
213
258
|
}),
|
|
214
|
-
/* @__PURE__ */
|
|
259
|
+
/* @__PURE__ */ k("p", {
|
|
215
260
|
className: "truncate text-xs text-text-secondary",
|
|
216
|
-
children:
|
|
261
|
+
children: V.get(e.relationshipId) ?? "—"
|
|
217
262
|
}),
|
|
218
|
-
/* @__PURE__ */
|
|
263
|
+
/* @__PURE__ */ A("p", {
|
|
219
264
|
className: "mt-1 text-xs text-text-secondary",
|
|
220
265
|
children: [
|
|
221
|
-
|
|
266
|
+
f(e.type),
|
|
222
267
|
" ·",
|
|
223
268
|
" ",
|
|
224
|
-
|
|
269
|
+
w("assetVault.expires", "Expires {{date}}", { date: t(e.expiresAt) })
|
|
225
270
|
]
|
|
226
271
|
})
|
|
227
272
|
]
|
|
@@ -234,6 +279,6 @@ var P = () => {
|
|
|
234
279
|
]
|
|
235
280
|
});
|
|
236
281
|
};
|
|
237
|
-
export {
|
|
282
|
+
export { z as AssetVaultPage };
|
|
238
283
|
|
|
239
284
|
//# sourceMappingURL=AssetVaultPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetVaultPage.js","names":["FileIcon","EmptyState","EmptyState$1","TYPE_ICON","FileText","FileKey","Award","Receipt","ShieldCheck","Globe","TYPE_ORDER","isExpiringSoon","expiresAt","days","expiryTime","AssetCard","useFormatters","tr","useTr","getDownloadUrl","useFileDownloadUrl","busy","setBusy","useState","Icon","asset","File","soon","GlassCard","subscription","formatEnumLabel","cn","formatDate","url","Download","AssetVaultPage","assetsQuery","useAllAssets","relQuery","useRelationships","search","setSearch","typeFilter","setTypeFilter","relLabels","useMemo","map","r","assets","filtered","a","grouped","g","expiringSoon","b","LoadingView","ErrorView","PageLayout","PagePurpose","MetricsCard","Search","t","Vault","type","items","Section","AlarmClock"],"sources":["../../../src/subscriberbot/pages/AssetVaultPage.tsx"],"sourcesContent":["import { useFormatters } from '../hooks/useFormatters';\n/**\n * Digital Asset Vault — every document attached to any subscription in the\n * workspace (contracts, receipts, license keys, warranties). Real data only:\n * `useAllAssets` (workspace-wide) joined to `useRelationships` for the owning\n * subscription label; downloads resolve a presigned URL via files-svc. The\n * \"Expiring soon\" rail lists the real assets whose `expiresAt` falls inside the\n * next 30 days — the same set the headline metric counts.\n * @module subscriberbot/pages\n */\nimport { useMemo, useState, type FC } from 'react';\nimport {\n FileText,\n FileKey,\n Receipt,\n ShieldCheck,\n File as FileIcon,\n Globe,\n Award,\n Search,\n Download,\n Vault,\n AlarmClock,\n} from 'lucide-react';\nimport { GlassCard, PagePurpose } from '@burdenoff/fe-libs/ui';\nimport {\n PageLayout,\n MetricsCard,\n EmptyState,\n LoadingView,\n ErrorView,\n Section,\n} from '../components';\nimport { useAllAssets, useRelationships, useFileDownloadUrl } from '../hooks/useSubscriberBotApi';\nimport { useTr } from '../hooks/useTr';\n\nimport type { SubAsset, SubAssetType } from '../types';\nimport { cn } from '../utils/cn';\n\nconst TYPE_ICON: Record<SubAssetType, typeof FileText> = {\n CONTRACT: FileText,\n LICENSE_KEY: FileKey,\n CREDENTIAL: FileKey,\n CERTIFICATE: Award,\n INVOICE: Receipt,\n RECEIPT: Receipt,\n WARRANTY: ShieldCheck,\n DOMAIN: Globe,\n};\n\nconst TYPE_ORDER: SubAssetType[] = [\n 'CONTRACT',\n 'LICENSE_KEY',\n 'CREDENTIAL',\n 'CERTIFICATE',\n 'INVOICE',\n 'RECEIPT',\n 'WARRANTY',\n 'DOMAIN',\n];\n\nconst isExpiringSoon = (expiresAt: string | null): boolean => {\n if (!expiresAt) return false;\n const t = new Date(expiresAt).getTime();\n if (Number.isNaN(t)) return false;\n const days = (t - Date.now()) / 86_400_000;\n return days >= 0 && days <= 30;\n};\n\n/** Sort key for expiry — undated/unparseable assets sink to the bottom. */\nconst expiryTime = (expiresAt: string | null): number => {\n if (!expiresAt) return Number.POSITIVE_INFINITY;\n const t = new Date(expiresAt).getTime();\n return Number.isNaN(t) ? Number.POSITIVE_INFINITY : t;\n};\n\nfunction AssetCard({ asset, subscription }: { asset: SubAsset; subscription: string }) {\n const { formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const getDownloadUrl = useFileDownloadUrl();\n const [busy, setBusy] = useState(false);\n const Icon = TYPE_ICON[asset.type] ?? FileIcon;\n const soon = isExpiringSoon(asset.expiresAt);\n\n const download = async () => {\n if (!asset.file?.id || busy) return;\n setBusy(true);\n try {\n const url = await getDownloadUrl(asset.file.id);\n window.open(url, '_blank', 'noopener,noreferrer');\n } finally {\n setBusy(false);\n }\n };\n\n return (\n <GlassCard treatment=\"metric\" className=\"flex items-start gap-3 p-4\">\n <span className=\"grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-accent-wash text-text-link\">\n <Icon className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate font-medium text-text-primary\">{asset.name}</p>\n <p className=\"truncate text-xs text-text-secondary\">{subscription}</p>\n <div className=\"mt-1 flex flex-wrap items-center gap-2 text-xs\">\n <span className=\"rounded bg-bg-sunken px-1.5 py-0.5 text-text-secondary\">\n {formatEnumLabel(asset.type)}\n </span>\n {asset.expiresAt && (\n <span className={cn(soon ? 'text-status-warning-text' : 'text-text-secondary')}>\n {tr('assetVault.expires', 'Expires {{date}}', { date: formatDate(asset.expiresAt) })}\n </span>\n )}\n </div>\n </div>\n {asset.file?.id && (\n <button\n type=\"button\"\n onClick={download}\n disabled={busy}\n aria-label={tr('assetVault.downloadAriaLabel', 'Download {{name}}', { name: asset.name })}\n className=\"shrink-0 rounded-lg border border-border-subtle p-2 text-text-secondary hover:text-text-primary disabled:opacity-50\"\n >\n <Download className=\"h-4 w-4\" />\n </button>\n )}\n </GlassCard>\n );\n}\n\nexport const AssetVaultPage: FC = () => {\n const { formatDate, formatEnumLabel } = useFormatters();\n\n const assetsQuery = useAllAssets();\n const relQuery = useRelationships({ pagination: { limit: 100 } });\n const tr = useTr();\n const [search, setSearch] = useState('');\n const [typeFilter, setTypeFilter] = useState<SubAssetType | 'ALL'>('ALL');\n\n const relLabels = useMemo(() => {\n const map = new Map<string, string>();\n for (const r of relQuery.data?.items ?? []) map.set(r.id, r.label);\n return map;\n }, [relQuery.data]);\n\n const assets = useMemo(() => assetsQuery.data ?? [], [assetsQuery.data]);\n const filtered = useMemo(\n () =>\n assets.filter(\n (a) =>\n (typeFilter === 'ALL' || a.type === typeFilter) &&\n (!search || a.name.toLowerCase().includes(search.toLowerCase()))\n ),\n [assets, typeFilter, search]\n );\n\n const grouped = useMemo(() => {\n const g = new Map<SubAssetType, SubAsset[]>();\n for (const a of filtered) g.set(a.type, [...(g.get(a.type) ?? []), a]);\n return TYPE_ORDER.filter((t) => g.has(t)).map((t) => [t, g.get(t)!] as const);\n }, [filtered]);\n\n const expiringSoon = useMemo(\n () =>\n assets\n .filter((a) => isExpiringSoon(a.expiresAt))\n .sort((a, b) => expiryTime(a.expiresAt) - expiryTime(b.expiresAt)),\n [assets]\n );\n\n if (assetsQuery.isLoading)\n return <LoadingView label={tr('assetVault.loading', 'Loading your asset vault…')} />;\n if (assetsQuery.isError)\n return (\n <ErrorView\n message={tr('assetVault.error', 'Could not load the asset vault.')}\n onRetry={() => void assetsQuery.refetch()}\n />\n );\n\n return (\n <PageLayout\n title={tr('assetVault.title', 'Asset vault')}\n description={tr(\n 'assetVault.description',\n 'Every contract, receipt, license key and document attached to your subscriptions — in one secure place.'\n )}\n >\n <PagePurpose className=\"mb-2\">\n {tr(\n 'assetVault.purpose',\n 'Your subscription documents, together — contracts, receipts, license keys and more. Assets are stored in the shared files service and linked to the subscription they belong to. Attach new documents from any relationship’s detail page.'\n )}\n </PagePurpose>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <MetricsCard\n icon={<FileIcon className=\"h-5 w-5\" />}\n value={assets.length}\n label={tr('assetVault.metrics.documentsStored', 'Documents stored')}\n />\n <MetricsCard\n icon={<FileText className=\"h-5 w-5\" />}\n value={grouped.length}\n label={tr('assetVault.metrics.documentTypes', 'Document types')}\n />\n <MetricsCard\n icon={<ShieldCheck className=\"h-5 w-5\" />}\n value={expiringSoon.length}\n label={tr('assetVault.metrics.expiring30Days', 'Expiring within 30 days')}\n trend={expiringSoon.length > 0 ? 'down' : undefined}\n />\n </div>\n\n <GlassCard treatment=\"plain\" className=\"flex flex-col gap-3 p-4 sm:flex-row sm:items-center\">\n <div className=\"relative flex-1\">\n <Search className=\"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary\" />\n <input\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder={tr('assetVault.searchPlaceholder', 'Search documents…')}\n aria-label={tr('assetVault.searchAriaLabel', 'Search documents')}\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface py-2 ps-9 pe-3 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n <div className=\"flex flex-wrap gap-1.5\">\n {(['ALL', ...TYPE_ORDER] as const).map((t) => (\n <button\n key={t}\n type=\"button\"\n onClick={() => setTypeFilter(t)}\n aria-pressed={typeFilter === t}\n className={cn(\n 'rounded-full px-3 py-1 text-xs font-medium transition-colors',\n typeFilter === t\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'bg-bg-sunken text-text-secondary hover:text-text-primary'\n )}\n >\n {t === 'ALL' ? tr('assetVault.filterAll', 'All') : formatEnumLabel(t)}\n </button>\n ))}\n </div>\n </GlassCard>\n\n <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_20rem]\">\n <div className=\"min-w-0\">\n {filtered.length === 0 ? (\n <EmptyState\n icon={<Vault className=\"h-8 w-8\" />}\n title={\n assets.length === 0\n ? tr('assetVault.empty.noDocumentsTitle', 'No documents yet')\n : tr('assetVault.empty.noMatchesTitle', 'No matching documents')\n }\n description={\n assets.length === 0\n ? tr(\n 'assetVault.empty.noDocumentsDescription',\n 'Attach a contract, receipt or license key from any subscription’s detail page and it will appear here.'\n )\n : tr(\n 'assetVault.empty.noMatchesDescription',\n 'Try a different search or type filter.'\n )\n }\n />\n ) : (\n grouped.map(([type, items]) => (\n <Section key={type} title={`${formatEnumLabel(type)} · ${items.length}`}>\n <div className=\"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {items.map((a) => (\n <AssetCard\n key={a.id}\n asset={a}\n subscription={relLabels.get(a.relationshipId) ?? '—'}\n />\n ))}\n </div>\n </Section>\n ))\n )}\n </div>\n\n {assets.length > 0 && (\n <aside className=\"lg:sticky lg:top-4 lg:self-start\">\n <GlassCard treatment=\"insight\" className=\"p-5\">\n <h3 className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <AlarmClock className=\"h-4 w-4 text-status-warning-text\" aria-hidden />\n {tr('assetVault.expiringSoon.title', 'Expiring soon')}\n </h3>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr('assetVault.expiringSoon.description', 'Documents lapsing in the next 30 days')}\n </p>\n {expiringSoon.length === 0 ? (\n <p className=\"mt-4 text-sm text-text-secondary\">\n {tr(\n 'assetVault.expiringSoon.nothing',\n 'Nothing in the vault expires in the next 30 days.'\n )}\n </p>\n ) : (\n <ul className=\"mt-4 space-y-2.5\">\n {expiringSoon.map((a) => (\n <li\n key={a.id}\n className=\"rounded-lg border border-status-warning-border bg-status-warning-bg-subtle p-3\"\n >\n <p className=\"truncate text-sm font-medium text-status-warning-text\">\n {a.name}\n </p>\n <p className=\"truncate text-xs text-text-secondary\">\n {relLabels.get(a.relationshipId) ?? '—'}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {formatEnumLabel(a.type)} ·{' '}\n {tr('assetVault.expires', 'Expires {{date}}', {\n date: formatDate(a.expiresAt),\n })}\n </p>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n </aside>\n )}\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAuCA,IAAMG,IAAmD;CACvD,UAAUC;CACV,aAAaC;CACb,YAAYA;CACZ,aAAaC;CACb,SAASC;CACT,SAASA;CACT,UAAUC;CACV,QAAQC;AACV,GAEMC,IAA6B;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,KAAkB,MAAsC;CAC5D,IAAI,CAACC,GAAW,OAAO;CACvB,IAAM,IAAI,IAAI,KAAKA,CAAS,CAAC,CAAC,QAAQ;CACtC,IAAI,OAAO,MAAM,CAAC,GAAG,OAAO;CAC5B,IAAMC,KAA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GR,CACF;MACE,CAAA;KACE,GAVKa,CAUL,CACV;IAEA,CAAA,GAEJf,EAAO,SAAS,KACf,kBAAC,SAAD;KAAO,WAAU;KACf,UAAA,kBAACpB,GAAD;MAAW,WAAU;MAAU,WAAU;MAAzC,UAAA;OACE,kBAAC,MAAD;QAAI,WAAU;QAAd,UAAA,CACE,kBAACsC,GAAD;SAAY,WAAU;SAAmC,eAAA;QAAa,CAAA,GACrEjD,EAAG,iCAAiC,eAAe,CAClD;;OACJ,kBAAC,KAAD;QAAG,WAAU;QACV,UAAAA,EAAG,uCAAuC,uCAAuC;OACjF,CAAA;OACFoC,EAAa,WAAW,IACvB,kBAAC,KAAD;QAAG,WAAU;QACV,UAAApC,EACC,mCACA,mDACF;OACC,CAAA,IAEH,kBAAC,MAAD;QAAI,WAAU;QACX,UAAAoC,EAAa,KAAK,MACjB,kBAAC,MAAD;SAEE,WAAU;SAFZ,UAAA;UAIE,kBAAC,KAAD;WAAG,WAAU;WACV,UAAAH,EAAE;UACF,CAAA;UACH,kBAAC,KAAD;WAAG,WAAU;WACV,UAAAN,EAAU,IAAIM,EAAE,cAAc,KAAK;UACnC,CAAA;UACH,kBAAC,KAAD;WAAG,WAAU;WAAb,UAAA;YACGpB,EAAgBoB,EAAE,IAAI;YAAE;YAAG;YAC3BjC,EAAG,sBAAsB,oBAAoB,EAC5C,MAAMe,EAAWkB,EAAE,SAAS,EAC9B,CAAC;WACA;;SACD;QAfG,GAAAA,EAAE,EAeL,CACL;OACC,CAAA;MAEG;;IACN,CAAA,CAEN;;EACK;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"AssetVaultPage.js","names":["FileIcon","EmptyState","EmptyState$1","TYPE_ICON","FileText","FileKey","Award","Receipt","ShieldCheck","Globe","TYPE_ORDER","isExpiringSoon","expiresAt","days","expiryTime","AssetCard","useFormatters","tr","useTr","getDownloadUrl","useFileDownloadUrl","busy","setBusy","useState","showTags","setShowTags","Icon","asset","File","soon","GlassCard","subscription","formatEnumLabel","cn","formatDate","v","Tag","url","Download","EntityTagPicker","ASSET_PAGE_SIZE","AssetVaultPage","tagFilter","setTagFilter","assetsQuery","useInfiniteAssets","relQuery","useRelationships","search","setSearch","typeFilter","setTypeFilter","relLabels","useMemo","map","r","assets","seen","list","page","item","filtered","a","grouped","g","expiringSoon","b","LoadingView","ErrorView","PageLayout","PagePurpose","MetricsCard","Search","TagFilterSelect","t","Vault","type","items","Section","InfiniteScrollSentinel","AlarmClock"],"sources":["../../../src/subscriberbot/pages/AssetVaultPage.tsx"],"sourcesContent":["import { useFormatters } from '../hooks/useFormatters';\n/**\n * Digital Asset Vault — every document attached to any subscription in the\n * workspace (contracts, receipts, license keys, warranties). Real data only:\n * `useAllAssets` (workspace-wide) joined to `useRelationships` for the owning\n * subscription label; downloads resolve a presigned URL via files-svc. The\n * \"Expiring soon\" rail lists the real assets whose `expiresAt` falls inside the\n * next 30 days — the same set the headline metric counts.\n * @module subscriberbot/pages\n */\nimport { useMemo, useState, type FC } from 'react';\nimport {\n FileText,\n FileKey,\n Receipt,\n ShieldCheck,\n File as FileIcon,\n Globe,\n Award,\n Search,\n Download,\n Vault,\n AlarmClock,\n Tag,\n} from 'lucide-react';\nimport { GlassCard, PagePurpose } from '@burdenoff/fe-libs/ui';\nimport {\n PageLayout,\n MetricsCard,\n EmptyState,\n LoadingView,\n ErrorView,\n Section,\n InfiniteScrollSentinel,\n EntityTagPicker,\n TagFilterSelect,\n} from '../components';\nimport {\n useInfiniteAssets,\n useRelationships,\n useFileDownloadUrl,\n} from '../hooks/useSubscriberBotApi';\nimport { useTr } from '../hooks/useTr';\n\nimport type { SubAsset, SubAssetType } from '../types';\nimport { cn } from '../utils/cn';\n\nconst TYPE_ICON: Record<SubAssetType, typeof FileText> = {\n CONTRACT: FileText,\n LICENSE_KEY: FileKey,\n CREDENTIAL: FileKey,\n CERTIFICATE: Award,\n INVOICE: Receipt,\n RECEIPT: Receipt,\n WARRANTY: ShieldCheck,\n DOMAIN: Globe,\n};\n\nconst TYPE_ORDER: SubAssetType[] = [\n 'CONTRACT',\n 'LICENSE_KEY',\n 'CREDENTIAL',\n 'CERTIFICATE',\n 'INVOICE',\n 'RECEIPT',\n 'WARRANTY',\n 'DOMAIN',\n];\n\nconst isExpiringSoon = (expiresAt: string | null): boolean => {\n if (!expiresAt) return false;\n const t = new Date(expiresAt).getTime();\n if (Number.isNaN(t)) return false;\n const days = (t - Date.now()) / 86_400_000;\n return days >= 0 && days <= 30;\n};\n\n/** Sort key for expiry — undated/unparseable assets sink to the bottom. */\nconst expiryTime = (expiresAt: string | null): number => {\n if (!expiresAt) return Number.POSITIVE_INFINITY;\n const t = new Date(expiresAt).getTime();\n return Number.isNaN(t) ? Number.POSITIVE_INFINITY : t;\n};\n\nfunction AssetCard({ asset, subscription }: { asset: SubAsset; subscription: string }) {\n const { formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const getDownloadUrl = useFileDownloadUrl();\n const [busy, setBusy] = useState(false);\n const [showTags, setShowTags] = useState(false);\n const Icon = TYPE_ICON[asset.type] ?? FileIcon;\n const soon = isExpiringSoon(asset.expiresAt);\n\n const download = async () => {\n if (!asset.file?.id || busy) return;\n setBusy(true);\n try {\n const url = await getDownloadUrl(asset.file.id);\n window.open(url, '_blank', 'noopener,noreferrer');\n } finally {\n setBusy(false);\n }\n };\n\n return (\n <GlassCard treatment=\"metric\" className=\"flex flex-col gap-2 p-4\">\n <div className=\"flex items-start gap-3\">\n <span className=\"grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-accent-wash text-text-link\">\n <Icon className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate font-medium text-text-primary\">{asset.name}</p>\n <p className=\"truncate text-xs text-text-secondary\">{subscription}</p>\n <div className=\"mt-1 flex flex-wrap items-center gap-2 text-xs\">\n <span className=\"rounded bg-bg-sunken px-1.5 py-0.5 text-text-secondary\">\n {formatEnumLabel(asset.type)}\n </span>\n {asset.expiresAt && (\n <span className={cn(soon ? 'text-status-warning-text' : 'text-text-secondary')}>\n {tr('assetVault.expires', 'Expires {{date}}', {\n date: formatDate(asset.expiresAt),\n })}\n </span>\n )}\n <button\n type=\"button\"\n onClick={() => setShowTags((v) => !v)}\n aria-expanded={showTags}\n className=\"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-text-secondary hover:bg-bg-sunken hover:text-text-primary\"\n >\n <Tag className=\"h-3 w-3\" aria-hidden />\n {tr('assetVault.tags', 'Tags')}\n </button>\n </div>\n </div>\n {asset.file?.id && (\n <button\n type=\"button\"\n onClick={download}\n disabled={busy}\n aria-label={tr('assetVault.downloadAriaLabel', 'Download {{name}}', {\n name: asset.name,\n })}\n className=\"shrink-0 rounded-lg border border-border-subtle p-2 text-text-secondary hover:text-text-primary disabled:opacity-50\"\n >\n <Download className=\"h-4 w-4\" />\n </button>\n )}\n </div>\n {showTags && (\n <div className=\"border-t border-border-subtle pt-2\">\n <EntityTagPicker entityType=\"SUBSCRIBERBOT_ASSET\" entityId={asset.id} compact label=\"\" />\n </div>\n )}\n </GlassCard>\n );\n}\n\nconst ASSET_PAGE_SIZE = 24;\n\nexport const AssetVaultPage: FC = () => {\n const { formatDate, formatEnumLabel } = useFormatters();\n\n const [tagFilter, setTagFilter] = useState('');\n const assetsQuery = useInfiniteAssets({\n first: ASSET_PAGE_SIZE,\n tagId: tagFilter || undefined,\n });\n const relQuery = useRelationships({ pagination: { limit: 100 } });\n const tr = useTr();\n const [search, setSearch] = useState('');\n const [typeFilter, setTypeFilter] = useState<SubAssetType | 'ALL'>('ALL');\n\n const relLabels = useMemo(() => {\n const map = new Map<string, string>();\n for (const r of relQuery.data?.items ?? []) map.set(r.id, r.label);\n return map;\n }, [relQuery.data]);\n\n const assets = useMemo(() => {\n const seen = new Set<string>();\n const list: SubAsset[] = [];\n for (const page of assetsQuery.data?.pages ?? []) {\n for (const item of page.items) {\n if (!seen.has(item.id)) {\n seen.add(item.id);\n list.push(item);\n }\n }\n }\n return list;\n }, [assetsQuery.data]);\n const filtered = useMemo(\n () =>\n assets.filter(\n (a) =>\n (typeFilter === 'ALL' || a.type === typeFilter) &&\n (!search || a.name.toLowerCase().includes(search.toLowerCase()))\n ),\n [assets, typeFilter, search]\n );\n\n const grouped = useMemo(() => {\n const g = new Map<SubAssetType, SubAsset[]>();\n for (const a of filtered) g.set(a.type, [...(g.get(a.type) ?? []), a]);\n return TYPE_ORDER.filter((t) => g.has(t)).map((t) => [t, g.get(t)!] as const);\n }, [filtered]);\n\n const expiringSoon = useMemo(\n () =>\n assets\n .filter((a) => isExpiringSoon(a.expiresAt))\n .sort((a, b) => expiryTime(a.expiresAt) - expiryTime(b.expiresAt)),\n [assets]\n );\n\n if (assetsQuery.isLoading)\n return <LoadingView label={tr('assetVault.loading', 'Loading your asset vault…')} />;\n if (assetsQuery.isError)\n return (\n <ErrorView\n message={tr('assetVault.error', 'Could not load the asset vault.')}\n onRetry={() => void assetsQuery.refetch()}\n />\n );\n\n return (\n <PageLayout\n title={tr('assetVault.title', 'Asset vault')}\n description={tr(\n 'assetVault.description',\n 'Every contract, receipt, license key and document attached to your subscriptions — in one secure place.'\n )}\n >\n <PagePurpose className=\"mb-2\">\n {tr(\n 'assetVault.purpose',\n 'Your subscription documents, together — contracts, receipts, license keys and more. Assets are stored in the shared files service and linked to the subscription they belong to. Attach new documents from any relationship’s detail page.'\n )}\n </PagePurpose>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <MetricsCard\n icon={<FileIcon className=\"h-5 w-5\" />}\n value={assets.length}\n label={tr('assetVault.metrics.documentsStored', 'Documents stored')}\n />\n <MetricsCard\n icon={<FileText className=\"h-5 w-5\" />}\n value={grouped.length}\n label={tr('assetVault.metrics.documentTypes', 'Document types')}\n />\n <MetricsCard\n icon={<ShieldCheck className=\"h-5 w-5\" />}\n value={expiringSoon.length}\n label={tr('assetVault.metrics.expiring30Days', 'Expiring within 30 days')}\n trend={expiringSoon.length > 0 ? 'down' : undefined}\n />\n </div>\n\n <GlassCard treatment=\"plain\" className=\"flex flex-col gap-3 p-4 sm:flex-row sm:items-center\">\n <div className=\"relative flex-1\">\n <Search className=\"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary\" />\n <input\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder={tr('assetVault.searchPlaceholder', 'Search documents…')}\n aria-label={tr('assetVault.searchAriaLabel', 'Search documents')}\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface py-2 ps-9 pe-3 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n <TagFilterSelect value={tagFilter} onChange={setTagFilter} />\n <div className=\"flex flex-wrap gap-1.5\">\n {(['ALL', ...TYPE_ORDER] as const).map((t) => (\n <button\n key={t}\n type=\"button\"\n onClick={() => setTypeFilter(t)}\n aria-pressed={typeFilter === t}\n className={cn(\n 'rounded-full px-3 py-1 text-xs font-medium transition-colors',\n typeFilter === t\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'bg-bg-sunken text-text-secondary hover:text-text-primary'\n )}\n >\n {t === 'ALL' ? tr('assetVault.filterAll', 'All') : formatEnumLabel(t)}\n </button>\n ))}\n </div>\n </div>\n </GlassCard>\n\n <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_20rem]\">\n <div className=\"min-w-0\">\n {filtered.length === 0 ? (\n <EmptyState\n icon={<Vault className=\"h-8 w-8\" />}\n title={\n assets.length === 0\n ? tr('assetVault.empty.noDocumentsTitle', 'No documents yet')\n : tr('assetVault.empty.noMatchesTitle', 'No matching documents')\n }\n description={\n assets.length === 0\n ? tr(\n 'assetVault.empty.noDocumentsDescription',\n 'Attach a contract, receipt or license key from any subscription’s detail page and it will appear here.'\n )\n : tr(\n 'assetVault.empty.noMatchesDescription',\n 'Try a different search or type filter.'\n )\n }\n />\n ) : (\n grouped.map(([type, items]) => (\n <Section key={type} title={`${formatEnumLabel(type)} · ${items.length}`}>\n <div className=\"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {items.map((a) => (\n <AssetCard\n key={a.id}\n asset={a}\n subscription={relLabels.get(a.relationshipId) ?? '—'}\n />\n ))}\n </div>\n </Section>\n ))\n )}\n\n {assets.length > 0 && (\n <InfiniteScrollSentinel\n hasNextPage={Boolean(assetsQuery.hasNextPage)}\n isFetchingNextPage={assetsQuery.isFetchingNextPage}\n isFetching={assetsQuery.isFetching}\n loadedCount={assets.length}\n onLoadMore={() => void assetsQuery.fetchNextPage()}\n />\n )}\n </div>\n\n {assets.length > 0 && (\n <aside className=\"lg:sticky lg:top-4 lg:self-start\">\n <GlassCard treatment=\"insight\" className=\"p-5\">\n <h3 className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <AlarmClock className=\"h-4 w-4 text-status-warning-text\" aria-hidden />\n {tr('assetVault.expiringSoon.title', 'Expiring soon')}\n </h3>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr('assetVault.expiringSoon.description', 'Documents lapsing in the next 30 days')}\n </p>\n {expiringSoon.length === 0 ? (\n <p className=\"mt-4 text-sm text-text-secondary\">\n {tr(\n 'assetVault.expiringSoon.nothing',\n 'Nothing in the vault expires in the next 30 days.'\n )}\n </p>\n ) : (\n <ul className=\"mt-4 space-y-2.5\">\n {expiringSoon.map((a) => (\n <li\n key={a.id}\n className=\"rounded-lg border border-status-warning-border bg-status-warning-bg-subtle p-3\"\n >\n <p className=\"truncate text-sm font-medium text-status-warning-text\">\n {a.name}\n </p>\n <p className=\"truncate text-xs text-text-secondary\">\n {relLabels.get(a.relationshipId) ?? '—'}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {formatEnumLabel(a.type)} ·{' '}\n {tr('assetVault.expires', 'Expires {{date}}', {\n date: formatDate(a.expiresAt),\n })}\n </p>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n </aside>\n )}\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;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as r } from "../components/MetricsCard.js";
|
|
|
6
6
|
import { StatusBadge as i } from "../components/StatusBadge.js";
|
|
7
7
|
import { EmptyState as a } from "../components/EmptyState.js";
|
|
8
8
|
import { ErrorView as ee, LoadingView as te, Section as o } from "../components/StateViews.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { useDecisions as s, useInboxMessages as c, useInvoices as l, useRelationships as u, useRenewalEvents as d } from "../hooks/useSubscriberBotApi.js";
|
|
10
|
+
import { Donut as f, Legend as p, Timeline as ne } from "../components/viz.js";
|
|
11
11
|
import { useTr as re } from "../hooks/useTr.js";
|
|
12
12
|
import { buildUpcomingRenewals as m, recurringSpend as h } from "../utils/portfolio.js";
|
|
13
13
|
import { useCompactViewport as g } from "../hooks/useCompactViewport.js";
|
|
@@ -19,16 +19,16 @@ import { jsx as O, jsxs as k } from "react/jsx-runtime";
|
|
|
19
19
|
import { GlassCard as A, PagePurpose as ae } from "@burdenoff/fe-libs/ui";
|
|
20
20
|
// src/subscriberbot/pages/DashboardPage.tsx
|
|
21
21
|
function j() {
|
|
22
|
-
let { formatCurrency: j, formatEnumLabel: M, formatRelativeTime: N } = e(), { navigateTo: P, currentUser: F } = t(), I = re(), L =
|
|
22
|
+
let { formatCurrency: j, formatEnumLabel: M, formatRelativeTime: N } = e(), { navigateTo: P, currentUser: F } = t(), I = re(), L = u({ pagination: {
|
|
23
23
|
limit: 100,
|
|
24
24
|
offset: 0
|
|
25
|
-
} }), R =
|
|
25
|
+
} }), R = l({ pagination: {
|
|
26
26
|
limit: 50,
|
|
27
27
|
offset: 0
|
|
28
|
-
} }), z =
|
|
28
|
+
} }), z = c({ pagination: {
|
|
29
29
|
limit: 50,
|
|
30
30
|
offset: 0
|
|
31
|
-
} }), B =
|
|
31
|
+
} }), B = d({ upcomingOnly: !0 }), V = g(), H = s({ status: "PROPOSED" }, { enabled: V }), U = v(() => L.data?.items ?? [], [L.data]), W = v(() => R.data?.items ?? [], [R.data]), G = v(() => z.data?.items ?? [], [z.data]), K = v(() => B.data ?? [], [B.data]), q = v(() => {
|
|
32
32
|
let e = /* @__PURE__ */ new Map();
|
|
33
33
|
return U.forEach((t) => e.set(t.id, t)), e;
|
|
34
34
|
}, [U]), J = v(() => {
|
|
@@ -198,7 +198,7 @@ function j() {
|
|
|
198
198
|
illustration: "empty-data",
|
|
199
199
|
title: I("dashboard.renewals.emptyTitle", "No upcoming renewals"),
|
|
200
200
|
description: I("dashboard.renewals.emptyDescription", "Renewals you track will appear here ahead of time.")
|
|
201
|
-
}) : /* @__PURE__ */ O(
|
|
201
|
+
}) : /* @__PURE__ */ O(ne, { items: Z })
|
|
202
202
|
})
|
|
203
203
|
})
|
|
204
204
|
}), /* @__PURE__ */ k("div", {
|
|
@@ -223,14 +223,14 @@ function j() {
|
|
|
223
223
|
})
|
|
224
224
|
}) : /* @__PURE__ */ k("div", {
|
|
225
225
|
className: "flex flex-col items-center gap-5 sm:flex-row sm:items-center lg:flex-col xl:flex-row",
|
|
226
|
-
children: [/* @__PURE__ */ O(
|
|
226
|
+
children: [/* @__PURE__ */ O(f, {
|
|
227
227
|
data: Y,
|
|
228
228
|
size: 148,
|
|
229
229
|
thickness: 20,
|
|
230
230
|
centerLabel: String(J.totalCount),
|
|
231
231
|
centerSub: I(J.totalCount === 1 ? "dashboard.portfolio.relationshipSingular" : "dashboard.portfolio.relationshipPlural", J.totalCount === 1 ? "relationship" : "relationships"),
|
|
232
232
|
className: "shrink-0"
|
|
233
|
-
}), /* @__PURE__ */ O(
|
|
233
|
+
}), /* @__PURE__ */ O(p, {
|
|
234
234
|
data: Y,
|
|
235
235
|
className: "w-full min-w-0 flex-1"
|
|
236
236
|
})]
|