@burdenoff/microfe-subscriberbot 2026.1102.1 → 2026.1102.3

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 (88) hide show
  1. package/dist/stories/pages/InsightsPage.stories.d.ts +1 -0
  2. package/dist/stories/pages/InsightsPage.stories.d.ts.map +1 -1
  3. package/dist/stories/pages/ProcurementDetailPage.stories.d.ts +10 -0
  4. package/dist/stories/pages/ProcurementDetailPage.stories.d.ts.map +1 -0
  5. package/dist/stories/pages/ProcurementNewPage.stories.d.ts +9 -0
  6. package/dist/stories/pages/ProcurementNewPage.stories.d.ts.map +1 -0
  7. package/dist/stories/pages/ProcurementPage.stories.d.ts +11 -0
  8. package/dist/stories/pages/ProcurementPage.stories.d.ts.map +1 -0
  9. package/dist/stories/pages/RenewalsPage.stories.d.ts +18 -0
  10. package/dist/stories/pages/RenewalsPage.stories.d.ts.map +1 -0
  11. package/dist/stories/support/fixtures.d.ts +2 -1
  12. package/dist/stories/support/fixtures.d.ts.map +1 -1
  13. package/dist/stories/support/handlers.d.ts.map +1 -1
  14. package/dist/stories/support/procurementFixtures.d.ts +14 -0
  15. package/dist/stories/support/procurementFixtures.d.ts.map +1 -0
  16. package/dist/subscriberbot/SubscriberBotRoot.d.ts.map +1 -1
  17. package/dist/subscriberbot/SubscriberBotRoot.js +57 -49
  18. package/dist/subscriberbot/SubscriberBotRoot.js.map +1 -1
  19. package/dist/subscriberbot/SubscriberBotRoutes.d.ts.map +1 -1
  20. package/dist/subscriberbot/SubscriberBotRoutes.js +25 -9
  21. package/dist/subscriberbot/SubscriberBotRoutes.js.map +1 -1
  22. package/dist/subscriberbot/admin/AdminDashboardPage.d.ts.map +1 -1
  23. package/dist/subscriberbot/admin/AdminDashboardPage.js +170 -160
  24. package/dist/subscriberbot/admin/AdminDashboardPage.js.map +1 -1
  25. package/dist/subscriberbot/admin/ProcurementDeskPanel.d.ts +4 -0
  26. package/dist/subscriberbot/admin/ProcurementDeskPanel.d.ts.map +1 -0
  27. package/dist/subscriberbot/admin/ProcurementDeskPanel.js +450 -0
  28. package/dist/subscriberbot/admin/ProcurementDeskPanel.js.map +1 -0
  29. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.d.ts +12 -0
  30. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.d.ts.map +1 -0
  31. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js +155 -0
  32. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js.map +1 -0
  33. package/dist/subscriberbot/components/procurement/ProcurementStatusPill.d.ts +8 -0
  34. package/dist/subscriberbot/components/procurement/ProcurementStatusPill.d.ts.map +1 -0
  35. package/dist/subscriberbot/components/procurement/ProcurementStatusPill.js +18 -0
  36. package/dist/subscriberbot/components/procurement/ProcurementStatusPill.js.map +1 -0
  37. package/dist/subscriberbot/components/procurement/ProcurementThread.d.ts +13 -0
  38. package/dist/subscriberbot/components/procurement/ProcurementThread.d.ts.map +1 -0
  39. package/dist/subscriberbot/components/procurement/ProcurementThread.js +51 -0
  40. package/dist/subscriberbot/components/procurement/ProcurementThread.js.map +1 -0
  41. package/dist/subscriberbot/components/procurement/index.d.ts +5 -0
  42. package/dist/subscriberbot/components/procurement/index.d.ts.map +1 -0
  43. package/dist/subscriberbot/components/procurement/index.js +4 -0
  44. package/dist/subscriberbot/components/procurement/labels.d.ts +16 -0
  45. package/dist/subscriberbot/components/procurement/labels.d.ts.map +1 -0
  46. package/dist/subscriberbot/components/procurement/labels.js +154 -0
  47. package/dist/subscriberbot/components/procurement/labels.js.map +1 -0
  48. package/dist/subscriberbot/hooks/index.d.ts +1 -1
  49. package/dist/subscriberbot/hooks/index.d.ts.map +1 -1
  50. package/dist/subscriberbot/hooks/useProcurementApi.d.ts +58 -0
  51. package/dist/subscriberbot/hooks/useProcurementApi.d.ts.map +1 -0
  52. package/dist/subscriberbot/hooks/useProcurementApi.js +128 -0
  53. package/dist/subscriberbot/hooks/useProcurementApi.js.map +1 -0
  54. package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts +8 -1
  55. package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts.map +1 -1
  56. package/dist/subscriberbot/hooks/useSubscriberBotApi.js +87 -36
  57. package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
  58. package/dist/subscriberbot/pages/InsightsPage.d.ts.map +1 -1
  59. package/dist/subscriberbot/pages/InsightsPage.js +12 -3
  60. package/dist/subscriberbot/pages/InsightsPage.js.map +1 -1
  61. package/dist/subscriberbot/pages/RenewalsPage.d.ts +4 -0
  62. package/dist/subscriberbot/pages/RenewalsPage.d.ts.map +1 -0
  63. package/dist/subscriberbot/pages/RenewalsPage.js +582 -0
  64. package/dist/subscriberbot/pages/RenewalsPage.js.map +1 -0
  65. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.d.ts +11 -0
  66. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.d.ts.map +1 -0
  67. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js +276 -0
  68. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js.map +1 -0
  69. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.d.ts +12 -0
  70. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.d.ts.map +1 -0
  71. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js +362 -0
  72. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js.map +1 -0
  73. package/dist/subscriberbot/pages/procurement/ProcurementPage.d.ts +11 -0
  74. package/dist/subscriberbot/pages/procurement/ProcurementPage.d.ts.map +1 -0
  75. package/dist/subscriberbot/pages/procurement/ProcurementPage.js +156 -0
  76. package/dist/subscriberbot/pages/procurement/ProcurementPage.js.map +1 -0
  77. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.d.ts.map +1 -1
  78. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +323 -312
  79. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
  80. package/dist/subscriberbot/types/index.d.ts +79 -0
  81. package/dist/subscriberbot/types/index.d.ts.map +1 -1
  82. package/dist/subscriberbot/types/procurement.d.ts +127 -0
  83. package/dist/subscriberbot/types/procurement.d.ts.map +1 -0
  84. package/dist/subscriberbot/utils/renewals.d.ts +19 -0
  85. package/dist/subscriberbot/utils/renewals.d.ts.map +1 -0
  86. package/dist/subscriberbot/utils/renewals.js +26 -0
  87. package/dist/subscriberbot/utils/renewals.js.map +1 -0
  88. package/package.json +1 -1
@@ -0,0 +1,362 @@
1
+ import { useSubscriberBot as e } from "../../context/SubscriberBotContext.js";
2
+ import { PageLayout as t } from "../../components/PageLayout.js";
3
+ import { useTr as n } from "../../hooks/useTr.js";
4
+ import { useRelationship as r, useRelationships as i } from "../../hooks/useSubscriberBotApi.js";
5
+ import { REQUEST_TYPES as a, REQUEST_TYPE_LABEL as o } from "../../components/procurement/labels.js";
6
+ import "../../components/procurement/index.js";
7
+ import { useCreateProcurementRequest as ee, useProcurementTerms as te } from "../../hooks/useProcurementApi.js";
8
+ import { useEffect as s, useMemo as c, useRef as ne, useState as l } from "react";
9
+ import { ArrowLeft as u, CalendarClock as re, FileText as d, Target as f } from "lucide-react";
10
+ import { useSearchParams as p } from "react-router";
11
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
+ import { GlassCard as g, PagePurpose as _ } from "@burdenoff/fe-libs/ui";
13
+ //#region src/subscriberbot/pages/procurement/ProcurementNewPage.tsx
14
+ var ie = {
15
+ DAILY: 365,
16
+ WEEKLY: 52,
17
+ MONTHLY: 12,
18
+ QUARTERLY: 4,
19
+ YEARLY: 1
20
+ }, v = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", y = "mb-1.5 block text-xs font-medium text-text-secondary";
21
+ function b({ icon: e, title: t, description: n, children: r }) {
22
+ return /* @__PURE__ */ h(g, {
23
+ treatment: "metric",
24
+ className: "p-5 sm:p-6",
25
+ children: [/* @__PURE__ */ h("div", {
26
+ className: "flex items-start gap-3",
27
+ children: [/* @__PURE__ */ m("span", {
28
+ className: "mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-bg-sunken text-text-secondary",
29
+ children: e
30
+ }), /* @__PURE__ */ h("div", {
31
+ className: "min-w-0",
32
+ children: [/* @__PURE__ */ m("h2", {
33
+ className: "text-sm font-semibold text-text-primary",
34
+ children: t
35
+ }), /* @__PURE__ */ m("p", {
36
+ className: "mt-0.5 text-xs text-text-secondary",
37
+ children: n
38
+ })]
39
+ })]
40
+ }), /* @__PURE__ */ m("div", {
41
+ className: "mt-4",
42
+ children: r
43
+ })]
44
+ });
45
+ }
46
+ function x(e) {
47
+ if (!e) return "";
48
+ let t = e instanceof Date ? e : new Date(e);
49
+ return Number.isNaN(t.getTime()) ? "" : t.toISOString().slice(0, 10);
50
+ }
51
+ var S = (e) => {
52
+ if (!e.trim()) return null;
53
+ let t = Number(e);
54
+ return Number.isFinite(t) && t > 0 ? t : null;
55
+ };
56
+ function C() {
57
+ let g = n(), { navigateTo: C } = e(), [ae] = p(), w = ee(), T = te(), E = i({ pagination: {
58
+ limit: 100,
59
+ offset: 0
60
+ } }), [D, O] = l(ae.get("relationshipId") ?? ""), k = r(D || void 0), A = c(() => {
61
+ let e = E.data?.items ?? [], t = k.data;
62
+ return t && !e.some((e) => e.id === t.id) ? [t, ...e] : e;
63
+ }, [E.data, k.data]), [j, M] = l(""), [N, oe] = l(""), [P, se] = l(""), [F, ce] = l("RENEWAL"), [I, L] = l("USD"), [R, z] = l(""), [B, V] = l(""), [H, U] = l(""), [W, le] = l("12"), [G, ue] = l(""), [K, q] = l(""), [J, de] = l(""), [Y, X] = l(null), Z = D ? A.find((e) => e.id === D) : void 0, Q = ne(null);
64
+ s(() => {
65
+ if (!Z || Q.current === Z.id) return;
66
+ Q.current = Z.id, M(Z.label), L(Z.currency);
67
+ let e = ie[Z.interval] ?? 0;
68
+ z(Z.amount > 0 && e > 0 ? String(Math.round(Z.amount * e * 100) / 100) : ""), q(Z.renewsAt ? x(Z.renewsAt) : "");
69
+ }, [Z]);
70
+ let $ = T.data ? Math.round(T.data.feeRate * 100) : null, fe = x(/* @__PURE__ */ new Date());
71
+ return /* @__PURE__ */ h(t, {
72
+ title: g("procurement.new.title", "Request an expert negotiation"),
73
+ description: g("procurement.new.description", "Tell the procurement desk about the contract and what matters to you."),
74
+ actions: /* @__PURE__ */ h("button", {
75
+ type: "button",
76
+ onClick: () => C("/procurement"),
77
+ className: "inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
78
+ children: [
79
+ /* @__PURE__ */ m(u, { className: "h-4 w-4" }),
80
+ " ",
81
+ g("procurement.back", "Back")
82
+ ]
83
+ }),
84
+ children: [/* @__PURE__ */ m(_, {
85
+ className: "mb-6",
86
+ children: $ == null ? g("procurement.new.purpose", "Nothing reaches the vendor until you submit the request. You only pay a share of the savings the expert secures.") : g("procurement.new.purposeFee", "Nothing reaches the vendor until you submit the request. The fee is {{pct}}% of the first-year savings against the vendor quote (or your current price), and only when the expert gets the price down.", { pct: $ })
87
+ }), /* @__PURE__ */ h("form", {
88
+ onSubmit: (e) => {
89
+ e.preventDefault(), X(null);
90
+ let t = S(R), n = S(B), r = Number(W);
91
+ if (!j.trim()) {
92
+ X(g("procurement.form.vendorRequired", "Which vendor is the contract with?"));
93
+ return;
94
+ }
95
+ if (t == null && n == null) {
96
+ X(g("procurement.form.baselineRequired", "Enter what you pay per year today or the annual value of the vendor quote."));
97
+ return;
98
+ }
99
+ if (!K) {
100
+ X(g("procurement.form.deadlineRequired", "When must the decision be made?"));
101
+ return;
102
+ }
103
+ if (!Number.isInteger(r) || r < 1 || r > (T.data?.maxTermMonths ?? 60)) {
104
+ X(g("procurement.form.termInvalid", "The term must be between 1 and {{max}} months.", { max: T.data?.maxTermMonths ?? 60 }));
105
+ return;
106
+ }
107
+ let i = S(H), a = S(G), o = {
108
+ vendorName: j.trim(),
109
+ requestType: F,
110
+ currency: I.trim().toUpperCase() || "USD",
111
+ termMonths: r,
112
+ deadline: (/* @__PURE__ */ new Date(`${K}T23:59:59`)).toISOString(),
113
+ ...D ? { relationshipId: D } : {},
114
+ ...N.trim() ? { productName: N.trim() } : {},
115
+ ...P.trim() ? { category: P.trim() } : {},
116
+ ...t == null ? {} : { currentAnnualValue: t },
117
+ ...n == null ? {} : { quotedAnnualValue: n },
118
+ ...i == null ? {} : { targetAnnualValue: i },
119
+ ...a == null ? {} : { seats: Math.round(a) },
120
+ ...J.trim() ? { notes: J.trim() } : {}
121
+ };
122
+ w.mutate({ input: o }, {
123
+ onSuccess: (e) => C(`/procurement/${e.id}`),
124
+ onError: (e) => X(e instanceof Error ? e.message : g("procurement.form.error", "Could not create the request."))
125
+ });
126
+ },
127
+ className: "max-w-3xl space-y-5",
128
+ "data-testid": "procurement-form",
129
+ children: [
130
+ Y && /* @__PURE__ */ m("div", {
131
+ role: "alert",
132
+ className: "rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text",
133
+ children: Y
134
+ }),
135
+ /* @__PURE__ */ m(b, {
136
+ icon: /* @__PURE__ */ m(d, { className: "h-4 w-4" }),
137
+ title: g("procurement.form.contract.title", "The contract"),
138
+ description: g("procurement.form.contract.description", "Link a tracked subscription to prefill it, or describe the contract."),
139
+ children: /* @__PURE__ */ h("div", {
140
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
141
+ children: [
142
+ /* @__PURE__ */ h("div", {
143
+ className: "sm:col-span-2",
144
+ children: [/* @__PURE__ */ m("label", {
145
+ htmlFor: "proc-relationship",
146
+ className: y,
147
+ children: g("procurement.form.relationship", "Tracked subscription (optional)")
148
+ }), /* @__PURE__ */ h("select", {
149
+ id: "proc-relationship",
150
+ value: D,
151
+ onChange: (e) => O(e.target.value),
152
+ className: v,
153
+ children: [/* @__PURE__ */ m("option", {
154
+ value: "",
155
+ children: g("procurement.form.noRelationship", "Not linked")
156
+ }), A.map((e) => /* @__PURE__ */ m("option", {
157
+ value: e.id,
158
+ children: e.label
159
+ }, e.id))]
160
+ })]
161
+ }),
162
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ h("label", {
163
+ htmlFor: "proc-vendor",
164
+ className: y,
165
+ children: [
166
+ g("procurement.form.vendor", "Vendor"),
167
+ " ",
168
+ /* @__PURE__ */ m("span", {
169
+ className: "text-status-error-text",
170
+ children: "*"
171
+ })
172
+ ]
173
+ }), /* @__PURE__ */ m("input", {
174
+ id: "proc-vendor",
175
+ value: j,
176
+ onChange: (e) => M(e.target.value),
177
+ placeholder: g("procurement.form.vendorPlaceholder", "e.g. Salesforce"),
178
+ className: v
179
+ })] }),
180
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
181
+ htmlFor: "proc-product",
182
+ className: y,
183
+ children: g("procurement.form.product", "Product or plan")
184
+ }), /* @__PURE__ */ m("input", {
185
+ id: "proc-product",
186
+ value: N,
187
+ onChange: (e) => oe(e.target.value),
188
+ placeholder: g("procurement.form.productPlaceholder", "e.g. Sales Cloud Enterprise"),
189
+ className: v
190
+ })] }),
191
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
192
+ htmlFor: "proc-type",
193
+ className: y,
194
+ children: g("procurement.form.type", "Type of request")
195
+ }), /* @__PURE__ */ m("select", {
196
+ id: "proc-type",
197
+ value: F,
198
+ onChange: (e) => ce(e.target.value),
199
+ className: v,
200
+ children: a.map((e) => /* @__PURE__ */ m("option", {
201
+ value: e,
202
+ children: g(o[e].key, o[e].fallback)
203
+ }, e))
204
+ })] }),
205
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
206
+ htmlFor: "proc-category",
207
+ className: y,
208
+ children: g("procurement.form.category", "Software category")
209
+ }), /* @__PURE__ */ m("input", {
210
+ id: "proc-category",
211
+ value: P,
212
+ onChange: (e) => se(e.target.value),
213
+ placeholder: g("procurement.form.categoryPlaceholder", "e.g. CRM, Security, HR"),
214
+ className: v
215
+ })] })
216
+ ]
217
+ })
218
+ }),
219
+ /* @__PURE__ */ m(b, {
220
+ icon: /* @__PURE__ */ m(f, { className: "h-4 w-4" }),
221
+ title: g("procurement.form.value.title", "Price and terms"),
222
+ description: g("procurement.form.value.description", "Annual values. Savings are measured against the quote, or the current price when there is no quote."),
223
+ children: /* @__PURE__ */ h("div", {
224
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
225
+ children: [
226
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
227
+ htmlFor: "proc-current",
228
+ className: y,
229
+ children: g("procurement.form.current", "What you pay per year today")
230
+ }), /* @__PURE__ */ m("input", {
231
+ id: "proc-current",
232
+ type: "number",
233
+ min: "0",
234
+ step: "0.01",
235
+ value: R,
236
+ onChange: (e) => z(e.target.value),
237
+ className: v
238
+ })] }),
239
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
240
+ htmlFor: "proc-quoted",
241
+ className: y,
242
+ children: g("procurement.form.quoted", "Vendor quote per year")
243
+ }), /* @__PURE__ */ m("input", {
244
+ id: "proc-quoted",
245
+ type: "number",
246
+ min: "0",
247
+ step: "0.01",
248
+ value: B,
249
+ onChange: (e) => V(e.target.value),
250
+ className: v
251
+ })] }),
252
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
253
+ htmlFor: "proc-target",
254
+ className: y,
255
+ children: g("procurement.form.target", "Annual price you would be happy with")
256
+ }), /* @__PURE__ */ m("input", {
257
+ id: "proc-target",
258
+ type: "number",
259
+ min: "0",
260
+ step: "0.01",
261
+ value: H,
262
+ onChange: (e) => U(e.target.value),
263
+ className: v
264
+ })] }),
265
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
266
+ htmlFor: "proc-currency",
267
+ className: y,
268
+ children: g("procurement.form.currency", "Currency")
269
+ }), /* @__PURE__ */ m("input", {
270
+ id: "proc-currency",
271
+ value: I,
272
+ maxLength: 3,
273
+ onChange: (e) => L(e.target.value),
274
+ className: v
275
+ })] }),
276
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
277
+ htmlFor: "proc-term",
278
+ className: y,
279
+ children: g("procurement.form.term", "Contract term (months)")
280
+ }), /* @__PURE__ */ m("input", {
281
+ id: "proc-term",
282
+ type: "number",
283
+ min: "1",
284
+ max: T.data?.maxTermMonths ?? 60,
285
+ step: "1",
286
+ value: W,
287
+ onChange: (e) => le(e.target.value),
288
+ className: v
289
+ })] }),
290
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
291
+ htmlFor: "proc-seats",
292
+ className: y,
293
+ children: g("procurement.form.seats", "Seats or licences")
294
+ }), /* @__PURE__ */ m("input", {
295
+ id: "proc-seats",
296
+ type: "number",
297
+ min: "1",
298
+ step: "1",
299
+ value: G,
300
+ onChange: (e) => ue(e.target.value),
301
+ className: v
302
+ })] })
303
+ ]
304
+ })
305
+ }),
306
+ /* @__PURE__ */ m(b, {
307
+ icon: /* @__PURE__ */ m(re, { className: "h-4 w-4" }),
308
+ title: g("procurement.form.deadline.title", "Deadline and priorities"),
309
+ description: g("procurement.form.deadline.description", "The earlier the expert starts, the more leverage there is. Requests are worked in deadline order."),
310
+ children: /* @__PURE__ */ h("div", {
311
+ className: "grid grid-cols-1 gap-4",
312
+ children: [/* @__PURE__ */ h("div", {
313
+ className: "sm:max-w-xs",
314
+ children: [/* @__PURE__ */ h("label", {
315
+ htmlFor: "proc-deadline",
316
+ className: y,
317
+ children: [
318
+ g("procurement.form.deadline", "Decision deadline (renewal or signature date)"),
319
+ " ",
320
+ /* @__PURE__ */ m("span", {
321
+ className: "text-status-error-text",
322
+ children: "*"
323
+ })
324
+ ]
325
+ }), /* @__PURE__ */ m("input", {
326
+ id: "proc-deadline",
327
+ type: "date",
328
+ min: fe,
329
+ value: K,
330
+ onChange: (e) => q(e.target.value),
331
+ className: v
332
+ })]
333
+ }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
334
+ htmlFor: "proc-notes",
335
+ className: y,
336
+ children: g("procurement.form.notes", "Priorities and constraints (must-have features, budget, flexibility on term or seats)")
337
+ }), /* @__PURE__ */ m("textarea", {
338
+ id: "proc-notes",
339
+ rows: 4,
340
+ value: J,
341
+ onChange: (e) => de(e.target.value),
342
+ className: v
343
+ })] })]
344
+ })
345
+ }),
346
+ /* @__PURE__ */ m("div", {
347
+ className: "flex justify-end",
348
+ children: /* @__PURE__ */ m("button", {
349
+ type: "submit",
350
+ disabled: w.isPending,
351
+ className: "rounded-lg bg-action-primary-bg px-5 py-2.5 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50",
352
+ children: w.isPending ? g("procurement.form.creating", "Creating…") : g("procurement.form.create", "Create request")
353
+ })
354
+ })
355
+ ]
356
+ })]
357
+ });
358
+ }
359
+ //#endregion
360
+ export { C as ProcurementNewPage };
361
+
362
+ //# sourceMappingURL=ProcurementNewPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcurementNewPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/procurement/ProcurementNewPage.tsx"],"sourcesContent":["/**\n * New expert procurement request\n * @module subscriberbot/pages/procurement\n *\n * `/subscriberbot/procurement/new[?relationshipId=…]` — describe the contract\n * (vendor, current price or quote, term, seats, decision deadline,\n * priorities). Creates a DRAFT through `subCreateProcurementRequest`; the\n * customer accepts the procurement authorisation and submits from the detail\n * page.\n */\n\nimport { useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { ArrowLeft, CalendarClock, FileText, Target } from 'lucide-react';\nimport { GlassCard, PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { REQUEST_TYPES, REQUEST_TYPE_LABEL } from '../../components/procurement';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport { useCreateProcurementRequest, useProcurementTerms } from '../../hooks/useProcurementApi';\nimport { useRelationship, useRelationships } from '../../hooks/useSubscriberBotApi';\nimport { useTr } from '../../hooks/useTr';\nimport type {\n SubCreateProcurementRequestInput,\n SubProcurementRequestType,\n} from '../../types/procurement';\n\nconst PERIODS_PER_YEAR: Record<string, number> = {\n DAILY: 365,\n WEEKLY: 52,\n MONTHLY: 12,\n QUARTERLY: 4,\n YEARLY: 1,\n};\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst labelCls = 'mb-1.5 block text-xs font-medium text-text-secondary';\n\nfunction FormSection({\n icon,\n title,\n description,\n children,\n}: {\n icon: ReactNode;\n title: string;\n description: string;\n children: ReactNode;\n}) {\n return (\n <GlassCard treatment=\"metric\" className=\"p-5 sm:p-6\">\n <div className=\"flex items-start gap-3\">\n <span className=\"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-bg-sunken text-text-secondary\">\n {icon}\n </span>\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-text-primary\">{title}</h2>\n <p className=\"mt-0.5 text-xs text-text-secondary\">{description}</p>\n </div>\n </div>\n <div className=\"mt-4\">{children}</div>\n </GlassCard>\n );\n}\n\n/** `YYYY-MM-DD` for a date input. */\nfunction toDateInput(value: string | Date | null | undefined): string {\n if (!value) return '';\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? '' : date.toISOString().slice(0, 10);\n}\n\nconst positive = (value: string): number | null => {\n if (!value.trim()) return null;\n const n = Number(value);\n return Number.isFinite(n) && n > 0 ? n : null;\n};\n\nexport function ProcurementNewPage() {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [params] = useSearchParams();\n const create = useCreateProcurementRequest();\n const terms = useProcurementTerms();\n const relationshipsQ = useRelationships({ pagination: { limit: 100, offset: 0 } });\n const [relationshipId, setRelationshipId] = useState(params.get('relationshipId') ?? '');\n // The selected subscription is fetched by id, so pre-fill works even when it\n // is not on the first page of the picker (opened from its detail page).\n const linkedQ = useRelationship(relationshipId || undefined);\n const relationships = useMemo(() => {\n const items = relationshipsQ.data?.items ?? [];\n const selected = linkedQ.data;\n return selected && !items.some((r) => r.id === selected.id) ? [selected, ...items] : items;\n }, [relationshipsQ.data, linkedQ.data]);\n const [vendorName, setVendorName] = useState('');\n const [productName, setProductName] = useState('');\n const [category, setCategory] = useState('');\n const [requestType, setRequestType] = useState<SubProcurementRequestType>('RENEWAL');\n const [currency, setCurrency] = useState('USD');\n const [currentAnnualValue, setCurrentAnnualValue] = useState('');\n const [quotedAnnualValue, setQuotedAnnualValue] = useState('');\n const [targetAnnualValue, setTargetAnnualValue] = useState('');\n const [termMonths, setTermMonths] = useState('12');\n const [seats, setSeats] = useState('');\n const [deadline, setDeadline] = useState('');\n const [notes, setNotes] = useState('');\n const [formError, setFormError] = useState<string | null>(null);\n\n // Prefill from the linked relationship once per selection, so a background\n // refetch of the relationships list never overwrites the user's edits.\n const linked = relationshipId ? relationships.find((r) => r.id === relationshipId) : undefined;\n const prefilledFor = useRef<string | null>(null);\n useEffect(() => {\n if (!linked || prefilledFor.current === linked.id) return;\n prefilledFor.current = linked.id;\n setVendorName(linked.label);\n setCurrency(linked.currency);\n // Every relationship-derived value is replaced (or cleared when this\n // subscription cannot supply it), so a previous selection's price or\n // renewal date never leaks into this request.\n const periods = PERIODS_PER_YEAR[linked.interval] ?? 0;\n setCurrentAnnualValue(\n linked.amount > 0 && periods > 0\n ? String(Math.round(linked.amount * periods * 100) / 100)\n : ''\n );\n setDeadline(linked.renewsAt ? toDateInput(linked.renewsAt) : '');\n }, [linked]);\n\n const feePct = terms.data ? Math.round(terms.data.feeRate * 100) : null;\n const today = toDateInput(new Date());\n\n const handleSubmit = (e: FormEvent) => {\n e.preventDefault();\n setFormError(null);\n const current = positive(currentAnnualValue);\n const quoted = positive(quotedAnnualValue);\n const term = Number(termMonths);\n if (!vendorName.trim()) {\n setFormError(tr('procurement.form.vendorRequired', 'Which vendor is the contract with?'));\n return;\n }\n if (current == null && quoted == null) {\n setFormError(\n tr(\n 'procurement.form.baselineRequired',\n 'Enter what you pay per year today or the annual value of the vendor quote.'\n )\n );\n return;\n }\n if (!deadline) {\n setFormError(tr('procurement.form.deadlineRequired', 'When must the decision be made?'));\n return;\n }\n if (!Number.isInteger(term) || term < 1 || term > (terms.data?.maxTermMonths ?? 60)) {\n setFormError(\n tr('procurement.form.termInvalid', 'The term must be between 1 and {{max}} months.', {\n max: terms.data?.maxTermMonths ?? 60,\n })\n );\n return;\n }\n const target = positive(targetAnnualValue);\n const seatCount = positive(seats);\n const input: SubCreateProcurementRequestInput = {\n vendorName: vendorName.trim(),\n requestType,\n currency: currency.trim().toUpperCase() || 'USD',\n termMonths: term,\n // End of the chosen day, so a same-day deadline can still be submitted.\n deadline: new Date(`${deadline}T23:59:59`).toISOString(),\n ...(relationshipId ? { relationshipId } : {}),\n ...(productName.trim() ? { productName: productName.trim() } : {}),\n ...(category.trim() ? { category: category.trim() } : {}),\n ...(current != null ? { currentAnnualValue: current } : {}),\n ...(quoted != null ? { quotedAnnualValue: quoted } : {}),\n ...(target != null ? { targetAnnualValue: target } : {}),\n ...(seatCount != null ? { seats: Math.round(seatCount) } : {}),\n ...(notes.trim() ? { notes: notes.trim() } : {}),\n };\n create.mutate(\n { input },\n {\n onSuccess: (p) => navigateTo(`/procurement/${p.id}`),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('procurement.form.error', 'Could not create the request.')\n ),\n }\n );\n };\n\n return (\n <PageLayout\n title={tr('procurement.new.title', 'Request an expert negotiation')}\n description={tr(\n 'procurement.new.description',\n 'Tell the procurement desk about the contract and what matters to you.'\n )}\n actions={\n <button\n type=\"button\"\n onClick={() => navigateTo('/procurement')}\n className=\"inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"h-4 w-4\" /> {tr('procurement.back', 'Back')}\n </button>\n }\n >\n <PagePurpose className=\"mb-6\">\n {feePct != null\n ? tr(\n 'procurement.new.purposeFee',\n 'Nothing reaches the vendor until you submit the request. The fee is {{pct}}% of the first-year savings against the vendor quote (or your current price), and only when the expert gets the price down.',\n { pct: feePct }\n )\n : tr(\n 'procurement.new.purpose',\n 'Nothing reaches the vendor until you submit the request. You only pay a share of the savings the expert secures.'\n )}\n </PagePurpose>\n\n <form onSubmit={handleSubmit} className=\"max-w-3xl space-y-5\" data-testid=\"procurement-form\">\n {formError && (\n <div\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n\n <FormSection\n icon={<FileText className=\"h-4 w-4\" />}\n title={tr('procurement.form.contract.title', 'The contract')}\n description={tr(\n 'procurement.form.contract.description',\n 'Link a tracked subscription to prefill it, or describe the contract.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div className=\"sm:col-span-2\">\n <label htmlFor=\"proc-relationship\" className={labelCls}>\n {tr('procurement.form.relationship', 'Tracked subscription (optional)')}\n </label>\n <select\n id=\"proc-relationship\"\n value={relationshipId}\n onChange={(e) => setRelationshipId(e.target.value)}\n className={inputCls}\n >\n <option value=\"\">{tr('procurement.form.noRelationship', 'Not linked')}</option>\n {relationships.map((r) => (\n <option key={r.id} value={r.id}>\n {r.label}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"proc-vendor\" className={labelCls}>\n {tr('procurement.form.vendor', 'Vendor')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id=\"proc-vendor\"\n value={vendorName}\n onChange={(e) => setVendorName(e.target.value)}\n placeholder={tr('procurement.form.vendorPlaceholder', 'e.g. Salesforce')}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-product\" className={labelCls}>\n {tr('procurement.form.product', 'Product or plan')}\n </label>\n <input\n id=\"proc-product\"\n value={productName}\n onChange={(e) => setProductName(e.target.value)}\n placeholder={tr(\n 'procurement.form.productPlaceholder',\n 'e.g. Sales Cloud Enterprise'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-type\" className={labelCls}>\n {tr('procurement.form.type', 'Type of request')}\n </label>\n <select\n id=\"proc-type\"\n value={requestType}\n onChange={(e) => setRequestType(e.target.value as SubProcurementRequestType)}\n className={inputCls}\n >\n {REQUEST_TYPES.map((t) => (\n <option key={t} value={t}>\n {tr(REQUEST_TYPE_LABEL[t].key, REQUEST_TYPE_LABEL[t].fallback)}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"proc-category\" className={labelCls}>\n {tr('procurement.form.category', 'Software category')}\n </label>\n <input\n id=\"proc-category\"\n value={category}\n onChange={(e) => setCategory(e.target.value)}\n placeholder={tr('procurement.form.categoryPlaceholder', 'e.g. CRM, Security, HR')}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <FormSection\n icon={<Target className=\"h-4 w-4\" />}\n title={tr('procurement.form.value.title', 'Price and terms')}\n description={tr(\n 'procurement.form.value.description',\n 'Annual values. Savings are measured against the quote, or the current price when there is no quote.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"proc-current\" className={labelCls}>\n {tr('procurement.form.current', 'What you pay per year today')}\n </label>\n <input\n id=\"proc-current\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={currentAnnualValue}\n onChange={(e) => setCurrentAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-quoted\" className={labelCls}>\n {tr('procurement.form.quoted', 'Vendor quote per year')}\n </label>\n <input\n id=\"proc-quoted\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={quotedAnnualValue}\n onChange={(e) => setQuotedAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-target\" className={labelCls}>\n {tr('procurement.form.target', 'Annual price you would be happy with')}\n </label>\n <input\n id=\"proc-target\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={targetAnnualValue}\n onChange={(e) => setTargetAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-currency\" className={labelCls}>\n {tr('procurement.form.currency', 'Currency')}\n </label>\n <input\n id=\"proc-currency\"\n value={currency}\n maxLength={3}\n onChange={(e) => setCurrency(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-term\" className={labelCls}>\n {tr('procurement.form.term', 'Contract term (months)')}\n </label>\n <input\n id=\"proc-term\"\n type=\"number\"\n min=\"1\"\n max={terms.data?.maxTermMonths ?? 60}\n step=\"1\"\n value={termMonths}\n onChange={(e) => setTermMonths(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-seats\" className={labelCls}>\n {tr('procurement.form.seats', 'Seats or licences')}\n </label>\n <input\n id=\"proc-seats\"\n type=\"number\"\n min=\"1\"\n step=\"1\"\n value={seats}\n onChange={(e) => setSeats(e.target.value)}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <FormSection\n icon={<CalendarClock className=\"h-4 w-4\" />}\n title={tr('procurement.form.deadline.title', 'Deadline and priorities')}\n description={tr(\n 'procurement.form.deadline.description',\n 'The earlier the expert starts, the more leverage there is. Requests are worked in deadline order.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4\">\n <div className=\"sm:max-w-xs\">\n <label htmlFor=\"proc-deadline\" className={labelCls}>\n {tr('procurement.form.deadline', 'Decision deadline (renewal or signature date)')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id=\"proc-deadline\"\n type=\"date\"\n min={today}\n value={deadline}\n onChange={(e) => setDeadline(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-notes\" className={labelCls}>\n {tr(\n 'procurement.form.notes',\n 'Priorities and constraints (must-have features, budget, flexibility on term or seats)'\n )}\n </label>\n <textarea\n id=\"proc-notes\"\n rows={4}\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <div className=\"flex justify-end\">\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-5 py-2.5 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('procurement.form.creating', 'Creating…')\n : tr('procurement.form.create', 'Create request')}\n </button>\n </div>\n </form>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,IAAM,KAA2C;CAC/C,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW;CACX,QAAQ;AACV,GAEM,IACJ,0MACI,IAAW;AAEjB,SAAS,EAAY,EACnB,SACA,UACA,gBACA,eAMC;CACD,OACE,kBAAC,GAAD;EAAW,WAAU;EAAS,WAAU;YAAxC,CACE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,QAAD;IAAM,WAAU;cACb;GACG,CAAA,GACN,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,MAAD;KAAI,WAAU;eAA2C;IAAU,CAAA,GACnE,kBAAC,KAAD;KAAG,WAAU;eAAsC;IAAe,CAAA,CAC/D;KACF;MACL,kBAAC,OAAD;GAAK,WAAU;GAAQ;EAAc,CAAA,CAC5B;;AAEf;AAGA,SAAS,EAAY,GAAiD;CACpE,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,IAAO,aAAiB,OAAO,IAAQ,IAAI,KAAK,CAAK;CAC3D,OAAO,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAI,KAAK,EAAK,YAAY,EAAE,MAAM,GAAG,EAAE;AAC3E;AAEA,IAAM,KAAY,MAAiC;CACjD,IAAI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,MAAM,kBAAC,IAAD,EAAe,WAAU,UAAW,CAAA;KAC1C,OAAO,EAAG,mCAAmC,yBAAyB;KACtE,aAAa,EACX,yCACA,mGACF;eAEA,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,SAAD;QAAO,SAAQ;QAAgB,WAAW;kBAA1C;SACG,EAAG,6BAA6B,+CAA+C;SAAG;SACnF,kBAAC,QAAD;UAAM,WAAU;oBAAyB;SAAO,CAAA;QAC3C;WACP,kBAAC,SAAD;QACE,IAAG;QACH,MAAK;QACL,KAAK;QACL,OAAO;QACP,WAAW,MAAM,EAAY,EAAE,OAAO,KAAK;QAC3C,WAAW;OACZ,CAAA,CACE;UACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;OAAO,SAAQ;OAAa,WAAW;iBACpC,EACC,0BACA,uFACF;MACK,CAAA,GACP,kBAAC,YAAD;OACE,IAAG;OACH,MAAM;OACN,OAAO;OACP,WAAW,MAAM,GAAS,EAAE,OAAO,KAAK;OACxC,WAAW;MACZ,CAAA,CACE,EAAA,CAAA,CACF;;IACM,CAAA;IAEb,kBAAC,OAAD;KAAK,WAAU;eACb,kBAAC,UAAD;MACE,MAAK;MACL,UAAU,EAAO;MACjB,WAAU;gBAET,EAAO,YACJ,EAAG,6BAA6B,WAAW,IAC3C,EAAG,2BAA2B,gBAAgB;KAC5C,CAAA;IACL,CAAA;GACD;IACI;;AAEhB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Human procurement overview
3
+ * @module subscriberbot/pages/procurement
4
+ *
5
+ * `/subscriberbot/procurement` — every expert procurement request in the
6
+ * workspace (BOFF-4158) with the savings Subscriber Bot's procurement experts
7
+ * secured, backed by the real `subListProcurementRequests` /
8
+ * `subProcurementSummary` queries.
9
+ */
10
+ export declare function ProcurementPage(): import("react").JSX.Element;
11
+ //# sourceMappingURL=ProcurementPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcurementPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/procurement/ProcurementPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8BH,wBAAgB,eAAe,gCAyL9B"}
@@ -0,0 +1,156 @@
1
+ import { useSubscriberBot as e } from "../../context/SubscriberBotContext.js";
2
+ import { cn as t } from "../../utils/cn.js";
3
+ import { PageLayout as n } from "../../components/PageLayout.js";
4
+ import { MetricsCard as r } from "../../components/MetricsCard.js";
5
+ import { formatCurrency as i, formatDate as a } from "../../utils/formatters.js";
6
+ import { EmptyState as o } from "../../components/EmptyState.js";
7
+ import { useTr as s } from "../../hooks/useTr.js";
8
+ import { ErrorView as c, LoadingView as l } from "../../components/StateViews.js";
9
+ import "../../components/index.js";
10
+ import { REQUEST_TYPE_LABEL as u, STATUS_LABEL as d } from "../../components/procurement/labels.js";
11
+ import { ProcurementStatusPill as f } from "../../components/procurement/ProcurementStatusPill.js";
12
+ import "../../components/procurement/index.js";
13
+ import { useProcurementRequests as p, useProcurementSummary as m } from "../../hooks/useProcurementApi.js";
14
+ import { useState as h } from "react";
15
+ import { BadgePercent as g, Briefcase as _, PiggyBank as v, Plus as y, Timer as b } from "lucide-react";
16
+ import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
17
+ import { PagePurpose as w } from "@burdenoff/fe-libs/ui";
18
+ //#region src/subscriberbot/pages/procurement/ProcurementPage.tsx
19
+ var T = [
20
+ "ALL",
21
+ "DRAFT",
22
+ "SUBMITTED",
23
+ "ASSIGNED",
24
+ "IN_PROGRESS",
25
+ "AWAITING_CUSTOMER",
26
+ "SUCCEEDED",
27
+ "NO_SAVINGS",
28
+ "CANCELLED"
29
+ ];
30
+ function E() {
31
+ let E = s(), { navigateTo: D } = e(), [O, k] = h("ALL"), A = p(O === "ALL" ? null : O), j = m(), M = A.data?.pages.flatMap((e) => e.items) ?? [], N = j.data?.totals.filter((e) => e.firstYearSavings > 0).map((e) => i(e.firstYearSavings, e.currency)).join(" + ") || i(0, "USD"), P = /* @__PURE__ */ C("button", {
32
+ type: "button",
33
+ onClick: () => D("/procurement/new"),
34
+ className: "inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90",
35
+ children: [
36
+ /* @__PURE__ */ S(y, {
37
+ className: "h-4 w-4",
38
+ "aria-hidden": !0
39
+ }),
40
+ " ",
41
+ E("procurement.new", "Request an expert negotiation")
42
+ ]
43
+ });
44
+ return /* @__PURE__ */ C(n, {
45
+ title: E("procurement.title", "Expert procurement"),
46
+ description: E("procurement.description", "A Subscriber Bot procurement expert negotiates your SaaS renewals and purchases for you."),
47
+ actions: P,
48
+ children: [
49
+ /* @__PURE__ */ S(w, {
50
+ className: "mb-6",
51
+ children: E("procurement.purpose", "Send a renewal, a new purchase or an expansion to the procurement desk. An expert is assigned, talks to the vendor for you and brings back the best offer; you review and sign it yourself. The desk only charges a share of the first-year savings it secures: no savings, no fee.")
52
+ }),
53
+ !j.isError && /* @__PURE__ */ C("div", {
54
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
55
+ children: [
56
+ /* @__PURE__ */ S(r, {
57
+ icon: /* @__PURE__ */ S(b, { className: "h-5 w-5" }),
58
+ value: j.isLoading ? "—" : j.data?.openCount ?? 0,
59
+ label: E("procurement.metrics.open", "Open requests")
60
+ }),
61
+ /* @__PURE__ */ S(r, {
62
+ icon: /* @__PURE__ */ S(_, { className: "h-5 w-5" }),
63
+ value: j.isLoading ? "—" : j.data?.succeededCount ?? 0,
64
+ label: E("procurement.metrics.succeeded", "Contracts negotiated down")
65
+ }),
66
+ /* @__PURE__ */ S(r, {
67
+ icon: /* @__PURE__ */ S(v, { className: "h-5 w-5" }),
68
+ value: j.isLoading ? "—" : N,
69
+ label: E("procurement.metrics.savings", "First-year savings")
70
+ }),
71
+ /* @__PURE__ */ S(r, {
72
+ icon: /* @__PURE__ */ S(g, { className: "h-5 w-5" }),
73
+ value: j.isLoading ? "—" : j.data?.noSavingsCount ?? 0,
74
+ label: E("procurement.metrics.noSavings", "No savings (no fee)")
75
+ })
76
+ ]
77
+ }),
78
+ /* @__PURE__ */ S("div", {
79
+ role: "tablist",
80
+ "aria-label": E("procurement.filter.label", "Request status"),
81
+ className: "mt-6 flex flex-wrap gap-1.5",
82
+ children: T.map((e) => /* @__PURE__ */ S("button", {
83
+ type: "button",
84
+ role: "tab",
85
+ "aria-selected": O === e,
86
+ onClick: () => k(e),
87
+ className: t("rounded-lg px-3 py-1.5 text-xs font-medium", O === e ? "bg-action-primary-bg text-action-primary-text" : "border border-border-subtle text-text-primary hover:bg-bg-sunken"),
88
+ children: e === "ALL" ? E("procurement.filter.all", "All") : E(d[e].key, d[e].fallback)
89
+ }, e))
90
+ }),
91
+ /* @__PURE__ */ C("div", {
92
+ className: "mt-4",
93
+ children: [A.isLoading ? /* @__PURE__ */ S(l, { label: E("procurement.loading", "Loading procurement requests…") }) : A.isError ? /* @__PURE__ */ S(c, {
94
+ message: A.error instanceof Error ? A.error.message : void 0,
95
+ onRetry: () => void A.refetch()
96
+ }) : M.length === 0 ? /* @__PURE__ */ S(o, {
97
+ illustration: "empty-data",
98
+ title: E("procurement.empty.title", "No procurement requests yet"),
99
+ description: E("procurement.empty.description", "Have a renewal coming up or a quote on the table? Send it to the procurement desk and an expert will negotiate it for you."),
100
+ action: P
101
+ }) : /* @__PURE__ */ S("ul", {
102
+ className: "grid grid-cols-1 gap-3 lg:grid-cols-2",
103
+ "data-testid": "procurement-list",
104
+ children: M.map((e) => /* @__PURE__ */ S("li", { children: /* @__PURE__ */ C("button", {
105
+ type: "button",
106
+ onClick: () => D(`/procurement/${e.id}`),
107
+ className: "w-full rounded-xl border border-border-subtle bg-bg-surface p-4 text-left hover:bg-bg-sunken focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]",
108
+ children: [/* @__PURE__ */ C("div", {
109
+ className: "flex items-start justify-between gap-3",
110
+ children: [/* @__PURE__ */ C("div", {
111
+ className: "min-w-0",
112
+ children: [/* @__PURE__ */ C("p", {
113
+ className: "truncate text-sm font-semibold text-text-primary",
114
+ children: [e.vendorName, e.productName ? ` · ${e.productName}` : ""]
115
+ }), /* @__PURE__ */ C("p", {
116
+ className: "mt-0.5 text-xs text-text-secondary",
117
+ children: [
118
+ E(u[e.requestType].key, u[e.requestType].fallback),
119
+ " · ",
120
+ E("procurement.card.deadline", "Decide by {{date}}", { date: a(e.deadline) }),
121
+ e.expertName ? ` · ${e.expertName}` : ""
122
+ ]
123
+ })]
124
+ }), /* @__PURE__ */ S(f, { status: e.status })]
125
+ }), /* @__PURE__ */ C("div", {
126
+ className: "mt-3 flex flex-wrap items-end justify-between gap-2 text-sm",
127
+ children: [/* @__PURE__ */ C("span", {
128
+ className: "text-text-primary",
129
+ children: [e.baselineAnnualValue == null ? "—" : E("procurement.card.perYear", "{{amount}} / year", { amount: i(e.baselineAnnualValue, e.currency) }), e.finalAnnualValue != null && e.status === "SUCCEEDED" && /* @__PURE__ */ C(x, { children: [" → ", /* @__PURE__ */ S("span", {
130
+ className: "font-semibold text-status-success-text",
131
+ children: i(e.finalAnnualValue, e.currency)
132
+ })] })]
133
+ }), /* @__PURE__ */ S("span", {
134
+ className: "text-xs text-text-secondary",
135
+ children: e.firstYearSavings > 0 ? E("procurement.card.saved", "Saves {{amount}} in year one", { amount: i(e.firstYearSavings, e.currency) }) : a(e.createdAt)
136
+ })]
137
+ })]
138
+ }) }, e.id))
139
+ }), A.hasNextPage && /* @__PURE__ */ S("div", {
140
+ className: "mt-4 flex justify-center",
141
+ children: /* @__PURE__ */ S("button", {
142
+ type: "button",
143
+ disabled: A.isFetchingNextPage,
144
+ onClick: () => void A.fetchNextPage(),
145
+ className: "rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50",
146
+ children: A.isFetchingNextPage ? E("procurement.loadingMore", "Loading…") : E("procurement.loadMore", "Load more")
147
+ })
148
+ })]
149
+ })
150
+ ]
151
+ });
152
+ }
153
+ //#endregion
154
+ export { E as ProcurementPage };
155
+
156
+ //# sourceMappingURL=ProcurementPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcurementPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/procurement/ProcurementPage.tsx"],"sourcesContent":["/**\n * Human procurement overview\n * @module subscriberbot/pages/procurement\n *\n * `/subscriberbot/procurement` — every expert procurement request in the\n * workspace (BOFF-4158) with the savings Subscriber Bot's procurement experts\n * secured, backed by the real `subListProcurementRequests` /\n * `subProcurementSummary` queries.\n */\n\nimport { useState } from 'react';\nimport { BadgePercent, Briefcase, PiggyBank, Plus, Timer } from 'lucide-react';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { EmptyState, ErrorView, LoadingView, MetricsCard, PageLayout } from '../../components';\nimport {\n ProcurementStatusPill,\n REQUEST_TYPE_LABEL,\n STATUS_LABEL,\n} from '../../components/procurement';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport { useProcurementRequests, useProcurementSummary } from '../../hooks/useProcurementApi';\nimport { useTr } from '../../hooks/useTr';\nimport { cn } from '../../utils/cn';\nimport { formatCurrency, formatDate } from '../../utils/formatters';\nimport type { SubProcurementStatus } from '../../types/procurement';\n\nconst FILTERS: Array<SubProcurementStatus | 'ALL'> = [\n 'ALL',\n 'DRAFT',\n 'SUBMITTED',\n 'ASSIGNED',\n 'IN_PROGRESS',\n 'AWAITING_CUSTOMER',\n 'SUCCEEDED',\n 'NO_SAVINGS',\n 'CANCELLED',\n];\n\nexport function ProcurementPage() {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [filter, setFilter] = useState<SubProcurementStatus | 'ALL'>('ALL');\n const list = useProcurementRequests(filter === 'ALL' ? null : filter);\n const summary = useProcurementSummary();\n const items = list.data?.pages.flatMap((page) => page.items) ?? [];\n\n const savingsText =\n summary.data?.totals\n .filter((t) => t.firstYearSavings > 0)\n .map((t) => formatCurrency(t.firstYearSavings, t.currency))\n .join(' + ') || formatCurrency(0, 'USD');\n\n const newButton = (\n <button\n type=\"button\"\n onClick={() => navigateTo('/procurement/new')}\n className=\"inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n <Plus className=\"h-4 w-4\" aria-hidden />{' '}\n {tr('procurement.new', 'Request an expert negotiation')}\n </button>\n );\n\n return (\n <PageLayout\n title={tr('procurement.title', 'Expert procurement')}\n description={tr(\n 'procurement.description',\n 'A Subscriber Bot procurement expert negotiates your SaaS renewals and purchases for you.'\n )}\n actions={newButton}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'procurement.purpose',\n 'Send a renewal, a new purchase or an expansion to the procurement desk. An expert is assigned, talks to the vendor for you and brings back the best offer; you review and sign it yourself. The desk only charges a share of the first-year savings it secures: no savings, no fee.'\n )}\n </PagePurpose>\n\n {!summary.isError && (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <MetricsCard\n icon={<Timer className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.openCount ?? 0)}\n label={tr('procurement.metrics.open', 'Open requests')}\n />\n <MetricsCard\n icon={<Briefcase className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.succeededCount ?? 0)}\n label={tr('procurement.metrics.succeeded', 'Contracts negotiated down')}\n />\n <MetricsCard\n icon={<PiggyBank className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : savingsText}\n label={tr('procurement.metrics.savings', 'First-year savings')}\n />\n <MetricsCard\n icon={<BadgePercent className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.noSavingsCount ?? 0)}\n label={tr('procurement.metrics.noSavings', 'No savings (no fee)')}\n />\n </div>\n )}\n\n <div\n role=\"tablist\"\n aria-label={tr('procurement.filter.label', 'Request status')}\n className=\"mt-6 flex flex-wrap gap-1.5\"\n >\n {FILTERS.map((f) => (\n <button\n key={f}\n type=\"button\"\n role=\"tab\"\n aria-selected={filter === f}\n onClick={() => setFilter(f)}\n className={cn(\n 'rounded-lg px-3 py-1.5 text-xs font-medium',\n filter === f\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'border border-border-subtle text-text-primary hover:bg-bg-sunken'\n )}\n >\n {f === 'ALL'\n ? tr('procurement.filter.all', 'All')\n : tr(STATUS_LABEL[f].key, STATUS_LABEL[f].fallback)}\n </button>\n ))}\n </div>\n\n <div className=\"mt-4\">\n {list.isLoading ? (\n <LoadingView label={tr('procurement.loading', 'Loading procurement requests…')} />\n ) : list.isError ? (\n <ErrorView\n message={list.error instanceof Error ? list.error.message : undefined}\n onRetry={() => void list.refetch()}\n />\n ) : items.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('procurement.empty.title', 'No procurement requests yet')}\n description={tr(\n 'procurement.empty.description',\n 'Have a renewal coming up or a quote on the table? Send it to the procurement desk and an expert will negotiate it for you.'\n )}\n action={newButton}\n />\n ) : (\n <ul className=\"grid grid-cols-1 gap-3 lg:grid-cols-2\" data-testid=\"procurement-list\">\n {items.map((p) => (\n <li key={p.id}>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/procurement/${p.id}`)}\n className=\"w-full rounded-xl border border-border-subtle bg-bg-surface p-4 text-left hover:bg-bg-sunken focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {p.vendorName}\n {p.productName ? ` · ${p.productName}` : ''}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n REQUEST_TYPE_LABEL[p.requestType].key,\n REQUEST_TYPE_LABEL[p.requestType].fallback\n )}\n {' · '}\n {tr('procurement.card.deadline', 'Decide by {{date}}', {\n date: formatDate(p.deadline),\n })}\n {p.expertName ? ` · ${p.expertName}` : ''}\n </p>\n </div>\n <ProcurementStatusPill status={p.status} />\n </div>\n <div className=\"mt-3 flex flex-wrap items-end justify-between gap-2 text-sm\">\n <span className=\"text-text-primary\">\n {p.baselineAnnualValue != null\n ? tr('procurement.card.perYear', '{{amount}} / year', {\n amount: formatCurrency(p.baselineAnnualValue, p.currency),\n })\n : '—'}\n {p.finalAnnualValue != null && p.status === 'SUCCEEDED' && (\n <>\n {' → '}\n <span className=\"font-semibold text-status-success-text\">\n {formatCurrency(p.finalAnnualValue, p.currency)}\n </span>\n </>\n )}\n </span>\n <span className=\"text-xs text-text-secondary\">\n {p.firstYearSavings > 0\n ? tr('procurement.card.saved', 'Saves {{amount}} in year one', {\n amount: formatCurrency(p.firstYearSavings, p.currency),\n })\n : formatDate(p.createdAt)}\n </span>\n </div>\n </button>\n </li>\n ))}\n </ul>\n )}\n {list.hasNextPage && (\n <div className=\"mt-4 flex justify-center\">\n <button\n type=\"button\"\n disabled={list.isFetchingNextPage}\n onClick={() => void list.fetchNextPage()}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n {list.isFetchingNextPage\n ? tr('procurement.loadingMore', 'Loading…')\n : tr('procurement.loadMore', 'Load more')}\n </button>\n </div>\n )}\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAM,IAA+C;CACnD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,IAAkB;CAChC,IAAM,IAAK,EAAM,GACX,EAAE,kBAAe,EAAiB,GAClC,CAAC,GAAQ,KAAa,EAAuC,KAAK,GAClE,IAAO,EAAuB,MAAW,QAAQ,OAAO,CAAM,GAC9D,IAAU,EAAsB,GAChC,IAAQ,EAAK,MAAM,MAAM,SAAS,MAAS,EAAK,KAAK,KAAK,CAAC,GAE3D,IACJ,EAAQ,MAAM,OACX,QAAQ,MAAM,EAAE,mBAAmB,CAAC,EACpC,KAAK,MAAM,EA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AA,CACvC;UACL,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,QAAD;QAAM,WAAU;kBAAhB,CACG,EAAE,uBAAuB,OAItB,MAHA,EAAG,4BAA4B,qBAAqB,EAClD,QAAQ,EAAe,EAAE,qBAAqB,EAAE,QAAQ,EAC1D,CAAC,GAEJ,EAAE,oBAAoB,QAAQ,EAAE,WAAW,eAC1C,kBAAA,GAAA,EAAA,UAAA,CACG,OACD,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAe,EAAE,kBAAkB,EAAE,QAAQ;QAC1C,CAAA,CACN,EAAA,CAAA,CAEA;WACN,kBAAC,QAAD;QAAM,WAAU;kBACb,EAAE,mBAAmB,IAClB,EAAG,0BAA0B,gCAAgC,EAC3D,QAAQ,EAAe,EAAE,kBAAkB,EAAE,QAAQ,EACvD,CAAC,IACD,EAAW,EAAE,SAAS;OACtB,CAAA,CACH;QACC;QACN,GAnDK,EAAE,EAmDP,CACL;IACC,CAAA,GAEL,EAAK,eACJ,kBAAC,OAAD;KAAK,WAAU;eACb,kBAAC,UAAD;MACE,MAAK;MACL,UAAU,EAAK;MACf,eAAe,KAAK,EAAK,cAAc;MACvC,WAAU;gBAET,EAAK,qBACF,EAAG,2BAA2B,UAAU,IACxC,EAAG,wBAAwB,WAAW;KACpC,CAAA;IACL,CAAA,CAEJ;;EACK;;AAEhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/relationships/RelationshipDetailPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAi2BH,wBAAgB,sBAAsB,gCA0kBrC"}
1
+ {"version":3,"file":"RelationshipDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/relationships/RelationshipDetailPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAk2BH,wBAAgB,sBAAsB,gCAqlBrC"}