@mesub/react 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -6
- package/dist/index.cjs +14 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -427,6 +427,14 @@ function moment(iso, now = Date.now()) {
|
|
|
427
427
|
function shortMoment(iso, now = Date.now()) {
|
|
428
428
|
return written(iso, { month: "short", day: "numeric" }, now);
|
|
429
429
|
}
|
|
430
|
+
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
431
|
+
var two = (n) => String(n).padStart(2, "0");
|
|
432
|
+
function planEnd(iso) {
|
|
433
|
+
if (!iso) return null;
|
|
434
|
+
const date = new Date(iso);
|
|
435
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
436
|
+
return `${MONTHS[date.getUTCMonth()]} ${date.getUTCDate()}, ${date.getUTCFullYear()}, ${two(date.getUTCHours())}:${two(date.getUTCMinutes())} UTC`;
|
|
437
|
+
}
|
|
430
438
|
function shortAddress(address) {
|
|
431
439
|
return `${address.slice(0, 4)}\u2026${address.slice(-4)}`;
|
|
432
440
|
}
|
|
@@ -1396,7 +1404,7 @@ function planScreen(loaded, titleId, reload, close) {
|
|
|
1396
1404
|
function stageScreen(props) {
|
|
1397
1405
|
const { view, plan, chain, titleId } = props;
|
|
1398
1406
|
const { text: price, title: exact } = briefPrice(plan);
|
|
1399
|
-
const ends =
|
|
1407
|
+
const ends = planEnd(plan.ends_at);
|
|
1400
1408
|
const single = view.name === "review" ? singleCharge(plan, view.prepared.terms.message) : view.name === "signing" || view.name === "subscribed" ? view.single : singleCharge(plan);
|
|
1401
1409
|
const every = single ? "once" : cadence(plan.period_hours);
|
|
1402
1410
|
const merchant = /* @__PURE__ */ jsx4(
|
|
@@ -1596,7 +1604,7 @@ function stageScreen(props) {
|
|
|
1596
1604
|
};
|
|
1597
1605
|
}
|
|
1598
1606
|
const nextCharge = view.single ? null : moment(view.subscription.next_charge_at);
|
|
1599
|
-
const accessUntil = view.single ? moment(view.subscription.access_until)
|
|
1607
|
+
const accessUntil = view.single ? ends ?? moment(view.subscription.access_until) : null;
|
|
1600
1608
|
const manage = manageLink(props.manageUrl, view.cancelUrl);
|
|
1601
1609
|
return {
|
|
1602
1610
|
step: "subscribed",
|
|
@@ -1717,7 +1725,7 @@ function consequence(action, subscription, planEndsAt) {
|
|
|
1717
1725
|
}
|
|
1718
1726
|
if (action === "resume") {
|
|
1719
1727
|
if (end && until && noChargeAt(Date.parse(end), planEndsAt)) {
|
|
1720
|
-
return `It runs again until ${
|
|
1728
|
+
return `It runs again until ${planEnd(planEndsAt)}, when the plan ends. Nothing more is charged.`;
|
|
1721
1729
|
}
|
|
1722
1730
|
return until ? `Charges start again on ${until}, as before.` : "Charges start again, as before.";
|
|
1723
1731
|
}
|
|
@@ -2635,9 +2643,9 @@ function SubscriptionDialog({
|
|
|
2635
2643
|
/* @__PURE__ */ jsx7("dt", { children: "Total paid" }),
|
|
2636
2644
|
/* @__PURE__ */ jsx7("dd", { title: total.title, children: total.text })
|
|
2637
2645
|
] }) : null,
|
|
2638
|
-
|
|
2646
|
+
planEnd(plan?.ends_at) ? /* @__PURE__ */ jsxs6("div", { "data-mesub-row": "", children: [
|
|
2639
2647
|
/* @__PURE__ */ jsx7("dt", { children: "Plan ends" }),
|
|
2640
|
-
/* @__PURE__ */ jsx7("dd", { children:
|
|
2648
|
+
/* @__PURE__ */ jsx7("dd", { children: planEnd(plan?.ends_at) })
|
|
2641
2649
|
] }) : null,
|
|
2642
2650
|
closeFrom(row) ? /* @__PURE__ */ jsxs6("div", { "data-mesub-row": "", children: [
|
|
2643
2651
|
/* @__PURE__ */ jsx7("dt", { children: "Close from" }),
|
|
@@ -2752,7 +2760,7 @@ function SubscriptionDialog({
|
|
|
2752
2760
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2753
2761
|
function MesubProvider({
|
|
2754
2762
|
endpoint,
|
|
2755
|
-
chain = "solana:
|
|
2763
|
+
chain = "solana:mainnet",
|
|
2756
2764
|
fetch,
|
|
2757
2765
|
theme,
|
|
2758
2766
|
manageUrl,
|