@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.
- package/dist/stories/pages/InsightsPage.stories.d.ts +1 -0
- package/dist/stories/pages/InsightsPage.stories.d.ts.map +1 -1
- package/dist/stories/pages/ProcurementDetailPage.stories.d.ts +10 -0
- package/dist/stories/pages/ProcurementDetailPage.stories.d.ts.map +1 -0
- package/dist/stories/pages/ProcurementNewPage.stories.d.ts +9 -0
- package/dist/stories/pages/ProcurementNewPage.stories.d.ts.map +1 -0
- package/dist/stories/pages/ProcurementPage.stories.d.ts +11 -0
- package/dist/stories/pages/ProcurementPage.stories.d.ts.map +1 -0
- package/dist/stories/pages/RenewalsPage.stories.d.ts +18 -0
- package/dist/stories/pages/RenewalsPage.stories.d.ts.map +1 -0
- package/dist/stories/support/fixtures.d.ts +2 -1
- package/dist/stories/support/fixtures.d.ts.map +1 -1
- package/dist/stories/support/handlers.d.ts.map +1 -1
- package/dist/stories/support/procurementFixtures.d.ts +14 -0
- package/dist/stories/support/procurementFixtures.d.ts.map +1 -0
- package/dist/subscriberbot/SubscriberBotRoot.d.ts.map +1 -1
- package/dist/subscriberbot/SubscriberBotRoot.js +57 -49
- package/dist/subscriberbot/SubscriberBotRoot.js.map +1 -1
- package/dist/subscriberbot/SubscriberBotRoutes.d.ts.map +1 -1
- package/dist/subscriberbot/SubscriberBotRoutes.js +25 -9
- package/dist/subscriberbot/SubscriberBotRoutes.js.map +1 -1
- package/dist/subscriberbot/admin/AdminDashboardPage.d.ts.map +1 -1
- package/dist/subscriberbot/admin/AdminDashboardPage.js +170 -160
- package/dist/subscriberbot/admin/AdminDashboardPage.js.map +1 -1
- package/dist/subscriberbot/admin/ProcurementDeskPanel.d.ts +4 -0
- package/dist/subscriberbot/admin/ProcurementDeskPanel.d.ts.map +1 -0
- package/dist/subscriberbot/admin/ProcurementDeskPanel.js +450 -0
- package/dist/subscriberbot/admin/ProcurementDeskPanel.js.map +1 -0
- package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.d.ts +12 -0
- package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.d.ts.map +1 -0
- package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js +155 -0
- package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js.map +1 -0
- package/dist/subscriberbot/components/procurement/ProcurementStatusPill.d.ts +8 -0
- package/dist/subscriberbot/components/procurement/ProcurementStatusPill.d.ts.map +1 -0
- package/dist/subscriberbot/components/procurement/ProcurementStatusPill.js +18 -0
- package/dist/subscriberbot/components/procurement/ProcurementStatusPill.js.map +1 -0
- package/dist/subscriberbot/components/procurement/ProcurementThread.d.ts +13 -0
- package/dist/subscriberbot/components/procurement/ProcurementThread.d.ts.map +1 -0
- package/dist/subscriberbot/components/procurement/ProcurementThread.js +51 -0
- package/dist/subscriberbot/components/procurement/ProcurementThread.js.map +1 -0
- package/dist/subscriberbot/components/procurement/index.d.ts +5 -0
- package/dist/subscriberbot/components/procurement/index.d.ts.map +1 -0
- package/dist/subscriberbot/components/procurement/index.js +4 -0
- package/dist/subscriberbot/components/procurement/labels.d.ts +16 -0
- package/dist/subscriberbot/components/procurement/labels.d.ts.map +1 -0
- package/dist/subscriberbot/components/procurement/labels.js +154 -0
- package/dist/subscriberbot/components/procurement/labels.js.map +1 -0
- package/dist/subscriberbot/hooks/index.d.ts +1 -1
- package/dist/subscriberbot/hooks/index.d.ts.map +1 -1
- package/dist/subscriberbot/hooks/useProcurementApi.d.ts +58 -0
- package/dist/subscriberbot/hooks/useProcurementApi.d.ts.map +1 -0
- package/dist/subscriberbot/hooks/useProcurementApi.js +128 -0
- package/dist/subscriberbot/hooks/useProcurementApi.js.map +1 -0
- package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts +8 -1
- package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts.map +1 -1
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js +87 -36
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
- package/dist/subscriberbot/pages/InsightsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/InsightsPage.js +12 -3
- package/dist/subscriberbot/pages/InsightsPage.js.map +1 -1
- package/dist/subscriberbot/pages/RenewalsPage.d.ts +4 -0
- package/dist/subscriberbot/pages/RenewalsPage.d.ts.map +1 -0
- package/dist/subscriberbot/pages/RenewalsPage.js +582 -0
- package/dist/subscriberbot/pages/RenewalsPage.js.map +1 -0
- package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.d.ts +11 -0
- package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.d.ts.map +1 -0
- package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js +276 -0
- package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js.map +1 -0
- package/dist/subscriberbot/pages/procurement/ProcurementNewPage.d.ts +12 -0
- package/dist/subscriberbot/pages/procurement/ProcurementNewPage.d.ts.map +1 -0
- package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js +362 -0
- package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js.map +1 -0
- package/dist/subscriberbot/pages/procurement/ProcurementPage.d.ts +11 -0
- package/dist/subscriberbot/pages/procurement/ProcurementPage.d.ts.map +1 -0
- package/dist/subscriberbot/pages/procurement/ProcurementPage.js +156 -0
- package/dist/subscriberbot/pages/procurement/ProcurementPage.js.map +1 -0
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +323 -312
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
- package/dist/subscriberbot/types/index.d.ts +79 -0
- package/dist/subscriberbot/types/index.d.ts.map +1 -1
- package/dist/subscriberbot/types/procurement.d.ts +127 -0
- package/dist/subscriberbot/types/procurement.d.ts.map +1 -0
- package/dist/subscriberbot/utils/renewals.d.ts +19 -0
- package/dist/subscriberbot/utils/renewals.d.ts.map +1 -0
- package/dist/subscriberbot/utils/renewals.js +26 -0
- package/dist/subscriberbot/utils/renewals.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,582 @@
|
|
|
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, formatEnumLabel as o } from "../utils/formatters.js";
|
|
6
|
+
import { EmptyState as s } from "../components/EmptyState.js";
|
|
7
|
+
import { Modal as c } from "../components/Modal.js";
|
|
8
|
+
import { useTr as l } from "../hooks/useTr.js";
|
|
9
|
+
import { ErrorView as u, LoadingView as d, Section as f } from "../components/StateViews.js";
|
|
10
|
+
import "../components/index.js";
|
|
11
|
+
import { useCancelRelationship as p, useCancelRenewalReminder as m, useRenewalForecast as h, useSetRenewalReminder as g, useTransitionRelationship as _ } from "../hooks/useSubscriberBotApi.js";
|
|
12
|
+
import { countRenewalCharges as v, countRenewalsInWindow as y } from "../utils/renewals.js";
|
|
13
|
+
import { useMemo as b, useState as x } from "react";
|
|
14
|
+
import { Bell as S, BellOff as C, CalendarClock as w, CalendarRange as T, Hourglass as E, Layers as D, Plus as O, Search as k, Sparkles as A, Wallet as j } from "lucide-react";
|
|
15
|
+
import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
|
|
16
|
+
import { GlassCard as F, PagePurpose as I } from "@burdenoff/fe-libs/ui";
|
|
17
|
+
//#region src/subscriberbot/pages/RenewalsPage.tsx
|
|
18
|
+
var L = 864e5, R = 3, ee = [
|
|
19
|
+
3,
|
|
20
|
+
6,
|
|
21
|
+
12
|
|
22
|
+
], z = [
|
|
23
|
+
3,
|
|
24
|
+
7,
|
|
25
|
+
14,
|
|
26
|
+
30
|
|
27
|
+
], B = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", V = "rounded-lg border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", H = "mb-1.5 block text-xs font-medium text-text-secondary", U = "truncate rounded text-left text-sm font-medium text-text-primary hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", W = "inline-flex items-center gap-1.5 rounded-lg border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-60", G = "inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-2.5 py-1.5 text-xs font-medium text-action-primary-text hover:opacity-90 disabled:opacity-60";
|
|
28
|
+
function K(e) {
|
|
29
|
+
let t = /* @__PURE__ */ new Date();
|
|
30
|
+
return new Date(Date.UTC(t.getUTCFullYear(), t.getUTCMonth() + e, 1)).toISOString();
|
|
31
|
+
}
|
|
32
|
+
function q(e) {
|
|
33
|
+
let t = (e) => String(e).padStart(2, "0");
|
|
34
|
+
return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}`;
|
|
35
|
+
}
|
|
36
|
+
function J(e) {
|
|
37
|
+
let t = /* @__PURE__ */ new Date(new Date(e).getTime() - R * L), n = /* @__PURE__ */ new Date();
|
|
38
|
+
return q(t.getTime() < n.getTime() ? n : t);
|
|
39
|
+
}
|
|
40
|
+
function Y(e) {
|
|
41
|
+
return new Date(Date.UTC(e.year, e.month - 1, 1)).toLocaleDateString(void 0, {
|
|
42
|
+
month: "long",
|
|
43
|
+
year: "numeric",
|
|
44
|
+
timeZone: "UTC"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function X(e) {
|
|
48
|
+
return new Date(Date.UTC(e.year, e.month - 1, 1)).toLocaleDateString(void 0, {
|
|
49
|
+
month: "short",
|
|
50
|
+
timeZone: "UTC"
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function Z(e, t) {
|
|
54
|
+
return t <= 0 ? e("renewals.days.today", "today") : t === 1 ? e("renewals.days.tomorrow", "tomorrow") : e("renewals.days.inDays", "in {{days}} days", { days: t });
|
|
55
|
+
}
|
|
56
|
+
var Q = ({ target: e, onClose: t }) => {
|
|
57
|
+
let n = l(), r = g(), [i, o] = x(() => J(e.targetAt)), [s, u] = x(""), [d, f] = x(null);
|
|
58
|
+
return /* @__PURE__ */ N(c, {
|
|
59
|
+
title: n("renewals.remind.title", "Remind me about {{label}}", { label: e.label }),
|
|
60
|
+
description: e.kind === "trial" ? n("renewals.remind.trialDescription", "The trial ends on {{date}}. You will get an in-app notification on the day you choose.", { date: a(e.targetAt) }) : n("renewals.remind.renewalDescription", "It renews on {{date}}. You will get an in-app notification on the day you choose.", { date: a(e.targetAt) }),
|
|
61
|
+
onClose: t,
|
|
62
|
+
children: /* @__PURE__ */ P("form", {
|
|
63
|
+
onSubmit: (a) => {
|
|
64
|
+
a.preventDefault(), f(null);
|
|
65
|
+
let o = /* @__PURE__ */ new Date(`${i}T09:00:00`);
|
|
66
|
+
if (!i || Number.isNaN(o.getTime())) {
|
|
67
|
+
f(n("renewals.remind.dateRequired", "Choose the day to be reminded on."));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
r.mutate({
|
|
71
|
+
relationshipId: e.relationshipId,
|
|
72
|
+
remindAt: o.toISOString(),
|
|
73
|
+
note: s.trim()
|
|
74
|
+
}, {
|
|
75
|
+
onSuccess: t,
|
|
76
|
+
onError: (e) => f(e instanceof Error ? e.message : n("renewals.remind.error", "Could not set the reminder."))
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
className: "space-y-4",
|
|
80
|
+
children: [
|
|
81
|
+
d && /* @__PURE__ */ N("div", {
|
|
82
|
+
className: "rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text",
|
|
83
|
+
children: d
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
86
|
+
htmlFor: "renewal-reminder-day",
|
|
87
|
+
className: H,
|
|
88
|
+
children: n("renewals.remind.day", "Remind me on")
|
|
89
|
+
}), /* @__PURE__ */ N("input", {
|
|
90
|
+
id: "renewal-reminder-day",
|
|
91
|
+
type: "date",
|
|
92
|
+
value: i,
|
|
93
|
+
min: q(/* @__PURE__ */ new Date()),
|
|
94
|
+
onChange: (e) => o(e.target.value),
|
|
95
|
+
className: B
|
|
96
|
+
})] }),
|
|
97
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
98
|
+
htmlFor: "renewal-reminder-note",
|
|
99
|
+
className: H,
|
|
100
|
+
children: n("renewals.remind.note", "Note (optional)")
|
|
101
|
+
}), /* @__PURE__ */ N("textarea", {
|
|
102
|
+
id: "renewal-reminder-note",
|
|
103
|
+
value: s,
|
|
104
|
+
maxLength: 500,
|
|
105
|
+
rows: 3,
|
|
106
|
+
onChange: (e) => u(e.target.value),
|
|
107
|
+
placeholder: n("renewals.remind.notePlaceholder", "e.g. ask for the annual discount"),
|
|
108
|
+
className: B
|
|
109
|
+
})] }),
|
|
110
|
+
/* @__PURE__ */ P("div", {
|
|
111
|
+
className: "flex justify-end gap-2",
|
|
112
|
+
children: [/* @__PURE__ */ N("button", {
|
|
113
|
+
type: "button",
|
|
114
|
+
onClick: t,
|
|
115
|
+
className: W,
|
|
116
|
+
children: n("common.cancel", "Cancel")
|
|
117
|
+
}), /* @__PURE__ */ P("button", {
|
|
118
|
+
type: "submit",
|
|
119
|
+
disabled: r.isPending,
|
|
120
|
+
className: G,
|
|
121
|
+
children: [/* @__PURE__ */ N(S, {
|
|
122
|
+
className: "h-3.5 w-3.5",
|
|
123
|
+
"aria-hidden": !0
|
|
124
|
+
}), n("renewals.remind.save", "Set reminder")]
|
|
125
|
+
})]
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
}, te = ({ trial: e, onClose: t }) => {
|
|
131
|
+
let n = l(), r = p(), [i, a] = x(null);
|
|
132
|
+
return /* @__PURE__ */ P(c, {
|
|
133
|
+
title: n("renewals.trials.cancelTitle", "Cancel the {{label}} trial?", { label: e.label }),
|
|
134
|
+
description: n("renewals.trials.cancelDescription", "This marks the trial as cancelled in Subscriber Bot. Cancel it with the provider too, so you are not charged."),
|
|
135
|
+
onClose: t,
|
|
136
|
+
children: [i && /* @__PURE__ */ N("div", {
|
|
137
|
+
className: "mb-4 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text",
|
|
138
|
+
children: i
|
|
139
|
+
}), /* @__PURE__ */ P("div", {
|
|
140
|
+
className: "flex justify-end gap-2",
|
|
141
|
+
children: [/* @__PURE__ */ N("button", {
|
|
142
|
+
type: "button",
|
|
143
|
+
onClick: t,
|
|
144
|
+
className: W,
|
|
145
|
+
children: n("renewals.trials.keep", "Keep trial")
|
|
146
|
+
}), /* @__PURE__ */ N("button", {
|
|
147
|
+
type: "button",
|
|
148
|
+
disabled: r.isPending,
|
|
149
|
+
onClick: () => r.mutate(e.relationshipId, {
|
|
150
|
+
onSuccess: t,
|
|
151
|
+
onError: (e) => a(e instanceof Error ? e.message : n("renewals.trials.cancelError", "Could not cancel the trial."))
|
|
152
|
+
}),
|
|
153
|
+
className: "inline-flex items-center gap-1.5 rounded-lg bg-action-danger-bg px-2.5 py-1.5 text-xs font-medium text-action-danger-text hover:bg-action-danger-bg-hover disabled:opacity-60",
|
|
154
|
+
children: n("renewals.trials.confirmCancel", "Cancel trial")
|
|
155
|
+
})]
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
}, $ = ({ reminderId: e, reminderAt: t, label: n, onRemind: r, testId: i }) => {
|
|
159
|
+
let o = l(), s = m();
|
|
160
|
+
return e && t ? /* @__PURE__ */ P("span", {
|
|
161
|
+
className: "inline-flex items-center gap-1 rounded-full bg-status-success-bg-subtle px-2 py-1 text-xs font-medium text-status-success-text",
|
|
162
|
+
"data-testid": `${i}-reminder`,
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ N(S, {
|
|
165
|
+
className: "h-3 w-3",
|
|
166
|
+
"aria-hidden": !0
|
|
167
|
+
}),
|
|
168
|
+
o("renewals.remind.setFor", "Reminder {{date}}", { date: a(t) }),
|
|
169
|
+
/* @__PURE__ */ N("button", {
|
|
170
|
+
type: "button",
|
|
171
|
+
disabled: s.isPending,
|
|
172
|
+
onClick: () => s.mutate(e),
|
|
173
|
+
"aria-label": o("renewals.remind.cancelAria", "Cancel the reminder for {{label}}", { label: n }),
|
|
174
|
+
className: "ml-0.5 rounded-full p-0.5 hover:bg-bg-sunken disabled:opacity-60",
|
|
175
|
+
children: /* @__PURE__ */ N(C, {
|
|
176
|
+
className: "h-3 w-3",
|
|
177
|
+
"aria-hidden": !0
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
}) : /* @__PURE__ */ P("button", {
|
|
182
|
+
type: "button",
|
|
183
|
+
onClick: r,
|
|
184
|
+
className: W,
|
|
185
|
+
"aria-label": o("renewals.remind.aria", "Remind me about {{label}}", { label: n }),
|
|
186
|
+
"data-testid": `${i}-remind`,
|
|
187
|
+
children: [/* @__PURE__ */ N(S, {
|
|
188
|
+
className: "h-3.5 w-3.5",
|
|
189
|
+
"aria-hidden": !0
|
|
190
|
+
}), o("renewals.remind.button", "Remind me")]
|
|
191
|
+
});
|
|
192
|
+
}, ne = ({ forecast: e, fmt: n }) => {
|
|
193
|
+
let r = Math.max(1, ...e.months.map((e) => e.amount));
|
|
194
|
+
return /* @__PURE__ */ N("div", {
|
|
195
|
+
className: "flex h-48 items-end gap-2 sm:gap-3",
|
|
196
|
+
role: "img",
|
|
197
|
+
"aria-label": e.months.map((e) => `${Y(e)}: ${n(e.amount)}`).join(", "),
|
|
198
|
+
"data-testid": "renewals-forecast-chart",
|
|
199
|
+
children: e.months.map((e) => /* @__PURE__ */ P("div", {
|
|
200
|
+
className: "flex h-full min-w-0 flex-1 flex-col items-center justify-end",
|
|
201
|
+
children: [
|
|
202
|
+
/* @__PURE__ */ N("span", {
|
|
203
|
+
className: "mb-1 truncate text-[11px] font-medium tabular-nums text-text-primary",
|
|
204
|
+
children: e.amount > 0 ? n(e.amount) : ""
|
|
205
|
+
}),
|
|
206
|
+
/* @__PURE__ */ N("div", {
|
|
207
|
+
className: t("w-full max-w-12 rounded-t-md", e.amount > 0 ? "bg-action-primary-bg" : "bg-bg-sunken"),
|
|
208
|
+
style: { height: `${Math.max(4, e.amount / r * 100)}%` }
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ N("span", {
|
|
211
|
+
className: "mt-2 text-xs text-text-secondary",
|
|
212
|
+
children: X(e)
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
}, e.key))
|
|
216
|
+
});
|
|
217
|
+
}, re = ({ forecast: t, onRemind: n, onCancel: r }) => {
|
|
218
|
+
let s = l(), { navigateTo: c } = e(), u = _(), [d, f] = x(null), p = t.trialsEndingSoon;
|
|
219
|
+
return /* @__PURE__ */ P("div", {
|
|
220
|
+
className: "rounded-2xl border border-status-warning-text/30 bg-status-warning-bg-subtle p-5",
|
|
221
|
+
role: "region",
|
|
222
|
+
"aria-label": s("renewals.trials.region", "Trials ending soon"),
|
|
223
|
+
"data-testid": "renewals-trials-banner",
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ P("div", {
|
|
226
|
+
className: "mb-3 flex items-start gap-3",
|
|
227
|
+
children: [/* @__PURE__ */ N(E, {
|
|
228
|
+
className: "mt-0.5 h-5 w-5 shrink-0 text-status-warning-text",
|
|
229
|
+
"aria-hidden": !0
|
|
230
|
+
}), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("h2", {
|
|
231
|
+
className: "text-sm font-semibold text-text-primary",
|
|
232
|
+
children: p.length === 1 ? s("renewals.trials.titleOne", "1 trial ends in the next {{days}} days", { days: t.trialWindowDays }) : s("renewals.trials.titleMany", "{{count}} trials end in the next {{days}} days", {
|
|
233
|
+
count: p.length,
|
|
234
|
+
days: t.trialWindowDays
|
|
235
|
+
})
|
|
236
|
+
}), /* @__PURE__ */ N("p", {
|
|
237
|
+
className: "text-xs text-text-secondary",
|
|
238
|
+
children: s("renewals.trials.subtitle", "Decide before the card is charged: convert the ones you use, cancel the rest.")
|
|
239
|
+
})] })]
|
|
240
|
+
}),
|
|
241
|
+
d && /* @__PURE__ */ N("div", {
|
|
242
|
+
className: "mb-3 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text",
|
|
243
|
+
children: d
|
|
244
|
+
}),
|
|
245
|
+
/* @__PURE__ */ N("ul", {
|
|
246
|
+
className: "divide-y divide-border-subtle rounded-xl bg-bg-surface",
|
|
247
|
+
children: p.map((e) => /* @__PURE__ */ P("li", {
|
|
248
|
+
className: "flex flex-col gap-3 p-4 sm:flex-row sm:items-center",
|
|
249
|
+
"data-testid": `renewals-trial-${e.relationshipId}`,
|
|
250
|
+
children: [/* @__PURE__ */ P("div", {
|
|
251
|
+
className: "min-w-0 flex-1",
|
|
252
|
+
children: [/* @__PURE__ */ N("button", {
|
|
253
|
+
type: "button",
|
|
254
|
+
className: U,
|
|
255
|
+
onClick: () => c(`/relationships/${e.relationshipId}`),
|
|
256
|
+
children: e.label
|
|
257
|
+
}), /* @__PURE__ */ P("p", {
|
|
258
|
+
className: "text-xs text-text-secondary",
|
|
259
|
+
children: [s("renewals.trials.endsOn", "Ends {{when}} ({{date}}), then {{amount}} {{interval}}", {
|
|
260
|
+
when: Z(s, e.daysRemaining),
|
|
261
|
+
date: a(e.trialEndsAt),
|
|
262
|
+
amount: i(e.amount, e.currency),
|
|
263
|
+
interval: o(e.interval).toLowerCase()
|
|
264
|
+
}), e.providerName ? ` · ${e.providerName}` : ""]
|
|
265
|
+
})]
|
|
266
|
+
}), /* @__PURE__ */ P("div", {
|
|
267
|
+
className: "flex flex-wrap items-center gap-2",
|
|
268
|
+
children: [
|
|
269
|
+
/* @__PURE__ */ N($, {
|
|
270
|
+
reminderId: e.reminderId,
|
|
271
|
+
reminderAt: e.reminderAt,
|
|
272
|
+
label: e.label,
|
|
273
|
+
testId: `renewals-trial-${e.relationshipId}`,
|
|
274
|
+
onRemind: () => n({
|
|
275
|
+
relationshipId: e.relationshipId,
|
|
276
|
+
label: e.label,
|
|
277
|
+
targetAt: e.trialEndsAt,
|
|
278
|
+
kind: "trial"
|
|
279
|
+
})
|
|
280
|
+
}),
|
|
281
|
+
/* @__PURE__ */ N("button", {
|
|
282
|
+
type: "button",
|
|
283
|
+
className: G,
|
|
284
|
+
disabled: u.isPending,
|
|
285
|
+
"aria-label": s("renewals.trials.convertAria", "Convert the {{label}} trial", { label: e.label }),
|
|
286
|
+
onClick: () => {
|
|
287
|
+
f(null), u.mutate({
|
|
288
|
+
id: e.relationshipId,
|
|
289
|
+
status: "ACTIVE"
|
|
290
|
+
}, { onError: (e) => f(e instanceof Error ? e.message : s("renewals.trials.convertError", "Could not convert the trial.")) });
|
|
291
|
+
},
|
|
292
|
+
children: s("renewals.trials.convert", "Convert")
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ N("button", {
|
|
295
|
+
type: "button",
|
|
296
|
+
className: W,
|
|
297
|
+
"aria-label": s("renewals.trials.cancelAria", "Cancel the {{label}} trial", { label: e.label }),
|
|
298
|
+
onClick: () => r(e),
|
|
299
|
+
children: s("renewals.trials.cancel", "Cancel")
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
})]
|
|
303
|
+
}, e.relationshipId))
|
|
304
|
+
})
|
|
305
|
+
]
|
|
306
|
+
});
|
|
307
|
+
}, ie = ({ item: t, monthKey: n, onRemind: r }) => {
|
|
308
|
+
let a = l(), { navigateTo: s } = e(), c = `renewals-row-${n}-${t.relationshipId}`;
|
|
309
|
+
return /* @__PURE__ */ P("li", {
|
|
310
|
+
className: "flex flex-col gap-3 p-4 md:flex-row md:items-center",
|
|
311
|
+
"data-testid": c,
|
|
312
|
+
children: [/* @__PURE__ */ P("div", {
|
|
313
|
+
className: "flex min-w-0 flex-1 items-start gap-3",
|
|
314
|
+
children: [/* @__PURE__ */ P("div", {
|
|
315
|
+
className: "flex w-12 shrink-0 flex-col items-center rounded-lg bg-bg-sunken py-1",
|
|
316
|
+
children: [/* @__PURE__ */ N("span", {
|
|
317
|
+
className: "text-[10px] uppercase text-text-secondary",
|
|
318
|
+
children: new Date(t.renewsAt).toLocaleDateString(void 0, { month: "short" })
|
|
319
|
+
}), /* @__PURE__ */ N("span", {
|
|
320
|
+
className: "text-base font-semibold tabular-nums text-text-primary",
|
|
321
|
+
children: new Date(t.renewsAt).getDate()
|
|
322
|
+
})]
|
|
323
|
+
}), /* @__PURE__ */ P("div", {
|
|
324
|
+
className: "min-w-0",
|
|
325
|
+
children: [
|
|
326
|
+
/* @__PURE__ */ N("button", {
|
|
327
|
+
type: "button",
|
|
328
|
+
className: U,
|
|
329
|
+
onClick: () => s(`/relationships/${t.relationshipId}`),
|
|
330
|
+
children: t.label
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ N("p", {
|
|
333
|
+
className: "text-xs text-text-secondary",
|
|
334
|
+
children: [
|
|
335
|
+
t.providerName,
|
|
336
|
+
o(t.interval),
|
|
337
|
+
Z(a, t.daysRemaining),
|
|
338
|
+
t.autoRenew ? null : a("renewals.row.noAutoRenew", "does not auto-renew"),
|
|
339
|
+
t.occurrenceCount > 1 ? a("renewals.row.occurrences", "{{count}} charges this month", { count: t.occurrenceCount }) : null
|
|
340
|
+
].filter(Boolean).join(" · ")
|
|
341
|
+
}),
|
|
342
|
+
/* @__PURE__ */ P("div", {
|
|
343
|
+
className: "mt-1 flex flex-wrap gap-1.5",
|
|
344
|
+
children: [t.status !== "ACTIVE" && /* @__PURE__ */ N("span", {
|
|
345
|
+
className: "rounded-full bg-bg-sunken px-2 py-0.5 text-[11px] font-medium text-text-secondary",
|
|
346
|
+
children: o(t.status)
|
|
347
|
+
}), t.needsReview && /* @__PURE__ */ P("span", {
|
|
348
|
+
className: "inline-flex items-center gap-1 rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-[11px] font-medium text-status-warning-text",
|
|
349
|
+
children: [/* @__PURE__ */ N(A, {
|
|
350
|
+
className: "h-3 w-3",
|
|
351
|
+
"aria-hidden": !0
|
|
352
|
+
}), t.openDecisionKind ? a("renewals.row.decision", "AI: {{kind}}", { kind: o(t.openDecisionKind) }) : a("renewals.row.lowHealth", "Low health score")]
|
|
353
|
+
})]
|
|
354
|
+
})
|
|
355
|
+
]
|
|
356
|
+
})]
|
|
357
|
+
}), /* @__PURE__ */ P("div", {
|
|
358
|
+
className: "flex flex-wrap items-center gap-2 md:justify-end",
|
|
359
|
+
children: [
|
|
360
|
+
/* @__PURE__ */ N("span", {
|
|
361
|
+
className: "mr-2 text-sm font-semibold tabular-nums text-text-primary",
|
|
362
|
+
children: i(t.amount, t.currency)
|
|
363
|
+
}),
|
|
364
|
+
/* @__PURE__ */ N($, {
|
|
365
|
+
reminderId: t.reminderId,
|
|
366
|
+
reminderAt: t.reminderAt,
|
|
367
|
+
label: t.label,
|
|
368
|
+
testId: c,
|
|
369
|
+
onRemind: () => r({
|
|
370
|
+
relationshipId: t.relationshipId,
|
|
371
|
+
label: t.label,
|
|
372
|
+
targetAt: t.renewsAt,
|
|
373
|
+
kind: "renewal"
|
|
374
|
+
})
|
|
375
|
+
}),
|
|
376
|
+
/* @__PURE__ */ P("button", {
|
|
377
|
+
type: "button",
|
|
378
|
+
onClick: () => s(t.openDecisionId ? `/decisions/${t.openDecisionId}` : `/relationships/${t.relationshipId}`),
|
|
379
|
+
className: t.needsReview ? G : W,
|
|
380
|
+
"aria-label": a("renewals.review.aria", "Review {{label}}", { label: t.label }),
|
|
381
|
+
"data-testid": `${c}-review`,
|
|
382
|
+
children: [/* @__PURE__ */ N(k, {
|
|
383
|
+
className: "h-3.5 w-3.5",
|
|
384
|
+
"aria-hidden": !0
|
|
385
|
+
}), a("renewals.review.button", "Review")]
|
|
386
|
+
})
|
|
387
|
+
]
|
|
388
|
+
})]
|
|
389
|
+
});
|
|
390
|
+
}, ae = () => {
|
|
391
|
+
let t = l(), { navigateTo: a } = e(), [o, c] = x(6), [p, m] = x(7), [g, _] = x(null), [C, k] = x(null), A = h({
|
|
392
|
+
to: b(() => K(o), [o]),
|
|
393
|
+
trialWindowDays: p
|
|
394
|
+
}), L = A.data, R = b(() => {
|
|
395
|
+
if (!L) return null;
|
|
396
|
+
let e = L.months.flatMap((e) => e.items), t = /* @__PURE__ */ new Set();
|
|
397
|
+
for (let n of e) n.reminderId && t.add(n.reminderId);
|
|
398
|
+
for (let e of L.trialsEndingSoon) e.reminderId && t.add(e.reminderId);
|
|
399
|
+
let n = y(e, Date.now(), 30);
|
|
400
|
+
return {
|
|
401
|
+
reminders: t.size,
|
|
402
|
+
next30: n,
|
|
403
|
+
review: e.filter((e) => e.needsReview).length
|
|
404
|
+
};
|
|
405
|
+
}, [L]);
|
|
406
|
+
if (A.isLoading) return /* @__PURE__ */ N(d, { label: t("renewals.loading", "Forecasting your renewals…") });
|
|
407
|
+
if (A.isError || !L || !R) return /* @__PURE__ */ N(u, {
|
|
408
|
+
message: t("renewals.error", "Could not load the renewals forecast."),
|
|
409
|
+
onRetry: () => void A.refetch()
|
|
410
|
+
});
|
|
411
|
+
let B = (e) => i(e, L.currency), H = L.months.filter((e) => e.items.length > 0), U = H.length === 0 && L.trialsEndingSoon.length === 0;
|
|
412
|
+
return /* @__PURE__ */ P(n, {
|
|
413
|
+
title: t("renewals.title", "Renewals & trials"),
|
|
414
|
+
description: t("renewals.description", "Everything that renews or ends in the coming months, with a reminder or a review one click away."),
|
|
415
|
+
actions: /* @__PURE__ */ P("div", {
|
|
416
|
+
className: "flex flex-wrap items-center gap-2",
|
|
417
|
+
children: [/* @__PURE__ */ P("label", {
|
|
418
|
+
className: "flex items-center gap-2 text-xs text-text-secondary",
|
|
419
|
+
children: [t("renewals.filters.horizon", "Forecast"), /* @__PURE__ */ N("select", {
|
|
420
|
+
value: o,
|
|
421
|
+
onChange: (e) => c(Number(e.target.value)),
|
|
422
|
+
className: V,
|
|
423
|
+
"data-testid": "renewals-horizon",
|
|
424
|
+
children: ee.map((e) => /* @__PURE__ */ N("option", {
|
|
425
|
+
value: e,
|
|
426
|
+
children: t("renewals.filters.months", "{{count}} months", { count: e })
|
|
427
|
+
}, e))
|
|
428
|
+
})]
|
|
429
|
+
}), /* @__PURE__ */ P("label", {
|
|
430
|
+
className: "flex items-center gap-2 text-xs text-text-secondary",
|
|
431
|
+
children: [t("renewals.filters.trialWindow", "Trials ending within"), /* @__PURE__ */ N("select", {
|
|
432
|
+
value: p,
|
|
433
|
+
onChange: (e) => m(Number(e.target.value)),
|
|
434
|
+
className: V,
|
|
435
|
+
"data-testid": "renewals-trial-window",
|
|
436
|
+
children: z.map((e) => /* @__PURE__ */ N("option", {
|
|
437
|
+
value: e,
|
|
438
|
+
children: t("renewals.filters.days", "{{count}} days", { count: e })
|
|
439
|
+
}, e))
|
|
440
|
+
})]
|
|
441
|
+
})]
|
|
442
|
+
}),
|
|
443
|
+
children: [
|
|
444
|
+
/* @__PURE__ */ N(I, {
|
|
445
|
+
className: "mb-2",
|
|
446
|
+
children: t("renewals.purpose", "Renewal and trial dates are where subscription money leaks. Set a reminder before anything renews, review the ones the AI has flagged, and convert or cancel trials before you are charged.")
|
|
447
|
+
}),
|
|
448
|
+
U ? /* @__PURE__ */ N(s, {
|
|
449
|
+
icon: /* @__PURE__ */ N(T, { className: "h-8 w-8" }),
|
|
450
|
+
title: t("renewals.emptyTitle", "Nothing renews in this period"),
|
|
451
|
+
description: t("renewals.emptyDescription", "Add renewal dates to your subscriptions and their renewals and trial deadlines will be forecast here."),
|
|
452
|
+
action: /* @__PURE__ */ P("button", {
|
|
453
|
+
type: "button",
|
|
454
|
+
onClick: () => a("/relationships/new"),
|
|
455
|
+
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",
|
|
456
|
+
children: [/* @__PURE__ */ N(O, {
|
|
457
|
+
className: "h-4 w-4",
|
|
458
|
+
"aria-hidden": !0
|
|
459
|
+
}), t("renewals.addSubscription", "Add a subscription")]
|
|
460
|
+
})
|
|
461
|
+
}) : /* @__PURE__ */ P(M, { children: [
|
|
462
|
+
/* @__PURE__ */ P("div", {
|
|
463
|
+
className: "grid grid-cols-2 gap-4 lg:grid-cols-4",
|
|
464
|
+
"data-testid": "renewals-kpis",
|
|
465
|
+
children: [
|
|
466
|
+
/* @__PURE__ */ N(r, {
|
|
467
|
+
icon: /* @__PURE__ */ N(j, { className: "h-5 w-5" }),
|
|
468
|
+
value: B(L.totalAmount),
|
|
469
|
+
label: t("renewals.metrics.total", "Renewing in the next {{count}} months", { count: o }),
|
|
470
|
+
featured: !0
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ N(r, {
|
|
473
|
+
icon: /* @__PURE__ */ N(w, { className: "h-5 w-5" }),
|
|
474
|
+
value: R.next30,
|
|
475
|
+
label: t("renewals.metrics.next30", "Renewals in 30 days")
|
|
476
|
+
}),
|
|
477
|
+
/* @__PURE__ */ N(r, {
|
|
478
|
+
icon: /* @__PURE__ */ N(E, { className: "h-5 w-5" }),
|
|
479
|
+
value: L.trialsEndingSoon.length,
|
|
480
|
+
label: t("renewals.metrics.trials", "Trials ending soon")
|
|
481
|
+
}),
|
|
482
|
+
/* @__PURE__ */ N(r, {
|
|
483
|
+
icon: /* @__PURE__ */ N(S, { className: "h-5 w-5" }),
|
|
484
|
+
value: R.reminders,
|
|
485
|
+
label: t("renewals.metrics.reminders", "Reminders set")
|
|
486
|
+
})
|
|
487
|
+
]
|
|
488
|
+
}),
|
|
489
|
+
L.trialsEndingSoon.length > 0 && /* @__PURE__ */ N(re, {
|
|
490
|
+
forecast: L,
|
|
491
|
+
onRemind: _,
|
|
492
|
+
onCancel: k
|
|
493
|
+
}),
|
|
494
|
+
/* @__PURE__ */ P(F, {
|
|
495
|
+
treatment: "plain",
|
|
496
|
+
className: "p-6",
|
|
497
|
+
children: [
|
|
498
|
+
/* @__PURE__ */ P("div", {
|
|
499
|
+
className: "mb-4 flex flex-wrap items-baseline justify-between gap-2",
|
|
500
|
+
children: [/* @__PURE__ */ N("h3", {
|
|
501
|
+
className: "text-sm font-semibold text-text-primary",
|
|
502
|
+
children: t("renewals.chart.title", "Renewal forecast")
|
|
503
|
+
}), /* @__PURE__ */ N("span", {
|
|
504
|
+
className: "text-xs text-text-secondary",
|
|
505
|
+
children: t("renewals.chart.summary", "{{count}} renewals · {{amount}} in {{currency}}", {
|
|
506
|
+
count: L.renewalCount,
|
|
507
|
+
amount: B(L.totalAmount),
|
|
508
|
+
currency: L.currency
|
|
509
|
+
})
|
|
510
|
+
})]
|
|
511
|
+
}),
|
|
512
|
+
/* @__PURE__ */ N(ne, {
|
|
513
|
+
forecast: L,
|
|
514
|
+
fmt: B
|
|
515
|
+
}),
|
|
516
|
+
L.otherCurrencyTotals.length > 0 && /* @__PURE__ */ N("p", {
|
|
517
|
+
className: "mt-4 text-xs text-text-secondary",
|
|
518
|
+
"data-testid": "renewals-other-currencies",
|
|
519
|
+
children: t("renewals.chart.otherCurrencies", "Also renewing in other currencies: {{list}}", { list: L.otherCurrencyTotals.map((e) => i(e.amount, e.currency)).join(", ") })
|
|
520
|
+
}),
|
|
521
|
+
L.truncated && /* @__PURE__ */ N("p", {
|
|
522
|
+
className: "mt-2 text-xs text-status-warning-text",
|
|
523
|
+
children: t("renewals.truncated", "Your portfolio is larger than one forecast covers, so these figures are partial.")
|
|
524
|
+
})
|
|
525
|
+
]
|
|
526
|
+
}),
|
|
527
|
+
/* @__PURE__ */ N(f, {
|
|
528
|
+
title: t("renewals.list.title", "Upcoming renewals"),
|
|
529
|
+
description: R.review > 0 ? t("renewals.list.reviewCount", "{{count}} need a review", { count: R.review }) : void 0,
|
|
530
|
+
children: H.length === 0 ? /* @__PURE__ */ N(F, {
|
|
531
|
+
treatment: "plain",
|
|
532
|
+
className: "p-6 text-sm text-text-secondary",
|
|
533
|
+
children: t("renewals.list.none", "No dated renewals in this period.")
|
|
534
|
+
}) : /* @__PURE__ */ N("div", {
|
|
535
|
+
className: "space-y-6",
|
|
536
|
+
children: H.map((e) => /* @__PURE__ */ P("div", {
|
|
537
|
+
"data-testid": `renewals-month-${e.key}`,
|
|
538
|
+
children: [/* @__PURE__ */ P("div", {
|
|
539
|
+
className: "mb-2 flex flex-wrap items-baseline justify-between gap-2 px-1",
|
|
540
|
+
children: [/* @__PURE__ */ N("h3", {
|
|
541
|
+
className: "text-sm font-semibold text-text-primary",
|
|
542
|
+
children: Y(e)
|
|
543
|
+
}), /* @__PURE__ */ P("span", {
|
|
544
|
+
className: "text-xs tabular-nums text-text-secondary",
|
|
545
|
+
children: [/* @__PURE__ */ N(D, {
|
|
546
|
+
className: "mr-1 inline h-3 w-3",
|
|
547
|
+
"aria-hidden": !0
|
|
548
|
+
}), t("renewals.list.monthSummary", "{{count}} renewals · {{amount}}", {
|
|
549
|
+
count: v(e.items),
|
|
550
|
+
amount: [B(e.amount)].concat(e.otherCurrencyTotals.map((e) => i(e.amount, e.currency))).join(" + ")
|
|
551
|
+
})]
|
|
552
|
+
})]
|
|
553
|
+
}), /* @__PURE__ */ N(F, {
|
|
554
|
+
treatment: "plain",
|
|
555
|
+
children: /* @__PURE__ */ N("ul", {
|
|
556
|
+
className: "divide-y divide-border-subtle",
|
|
557
|
+
children: e.items.map((t) => /* @__PURE__ */ N(ie, {
|
|
558
|
+
item: t,
|
|
559
|
+
monthKey: e.key,
|
|
560
|
+
onRemind: _
|
|
561
|
+
}, t.relationshipId))
|
|
562
|
+
})
|
|
563
|
+
})]
|
|
564
|
+
}, e.key))
|
|
565
|
+
})
|
|
566
|
+
})
|
|
567
|
+
] }),
|
|
568
|
+
g && /* @__PURE__ */ N(Q, {
|
|
569
|
+
target: g,
|
|
570
|
+
onClose: () => _(null)
|
|
571
|
+
}),
|
|
572
|
+
C && /* @__PURE__ */ N(te, {
|
|
573
|
+
trial: C,
|
|
574
|
+
onClose: () => k(null)
|
|
575
|
+
})
|
|
576
|
+
]
|
|
577
|
+
});
|
|
578
|
+
};
|
|
579
|
+
//#endregion
|
|
580
|
+
export { ae as RenewalsPage };
|
|
581
|
+
|
|
582
|
+
//# sourceMappingURL=RenewalsPage.js.map
|