@fluid-app/portal-sdk 0.1.1018 → 0.1.1019

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.
@@ -70,6 +70,6 @@ require("./translation-adapter-BhsWM9YE.cjs");
70
70
  require("./sidebar-51utndkK.cjs");
71
71
  require("./ScreenHeaderContext-fJKG4BUl.cjs");
72
72
  require("./use-portal-card-add-3ds-flow-DsvYRYjz.cjs");
73
- const require_SubscriptionsScreen = require("./SubscriptionsScreen-BFz8hWhS.cjs");
73
+ const require_SubscriptionsScreen = require("./SubscriptionsScreen-D8USeLnP.cjs");
74
74
  exports.SubscriptionsScreen = require_SubscriptionsScreen.SubscriptionsScreen;
75
75
  exports.subscriptionsScreenPropertySchema = require_SubscriptionsScreen.subscriptionsScreenPropertySchema;
@@ -2786,15 +2786,44 @@ function isSubscriptionCompleted(subscription) {
2786
2786
  function getSubscriptionDisplayStatus(subscription) {
2787
2787
  return isSubscriptionCompleted(subscription) ? "completed" : subscription.status;
2788
2788
  }
2789
- function hasPendingSubscriptionSkip(skips, today = /* @__PURE__ */ new Date()) {
2789
+ /**
2790
+ * Whether a booked skip has not passed yet. The server keeps a skip pending
2791
+ * through its date in the subscription's own timezone, so pass that timezone:
2792
+ * judged in UTC, a skip dated today reads as elapsed once UTC crosses
2793
+ * midnight, and Skip reappears while the server still refuses it.
2794
+ * Without a timezone (or with one Intl rejects) "today" is the UTC date.
2795
+ */
2796
+ function hasPendingSubscriptionSkip(skips, today = /* @__PURE__ */ new Date(), timeZone) {
2790
2797
  if (!skips?.length) return false;
2791
- const todayUtc = Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
2798
+ const todayUtc = calendarDayUtc(today, timeZone);
2792
2799
  return skips.some((skip) => {
2793
2800
  if (skip.unskipped_at != null) return false;
2794
2801
  const skippedDate = /* @__PURE__ */ new Date(`${skip.skipped_date.slice(0, 10)}T00:00:00Z`);
2795
2802
  return !Number.isNaN(skippedDate.getTime()) && skippedDate.getTime() >= todayUtc;
2796
2803
  });
2797
2804
  }
2805
+ const dayFormatters = /* @__PURE__ */ new Map();
2806
+ function dayFormatter(timeZone) {
2807
+ let formatter = dayFormatters.get(timeZone);
2808
+ if (!formatter) {
2809
+ formatter = new Intl.DateTimeFormat("en-US", {
2810
+ timeZone,
2811
+ year: "numeric",
2812
+ month: "numeric",
2813
+ day: "numeric"
2814
+ });
2815
+ dayFormatters.set(timeZone, formatter);
2816
+ }
2817
+ return formatter;
2818
+ }
2819
+ function calendarDayUtc(today, timeZone) {
2820
+ if (timeZone) try {
2821
+ const parts = dayFormatter(timeZone).formatToParts(today);
2822
+ const part = (type) => Number(parts.find((p) => p.type === type)?.value);
2823
+ return Date.UTC(part("year"), part("month") - 1, part("day"));
2824
+ } catch {}
2825
+ return Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
2826
+ }
2798
2827
  function getSubscriptionActionPolicy(subscription) {
2799
2828
  const status = getSubscriptionDisplayStatus({
2800
2829
  status: subscription.status,
@@ -3105,7 +3134,7 @@ function mapDetailSubscription(bff) {
3105
3134
  last_failed_at: bff.last_failed_at ?? null,
3106
3135
  next_retry_at: bff.next_retry_at ?? null,
3107
3136
  decline_count: bff.decline_count ?? null,
3108
- skipped_count: 0,
3137
+ skipped_count: bff.skipped_count ?? 0,
3109
3138
  max_skips: null,
3110
3139
  cancelled_at: null,
3111
3140
  created_at: bff.created_at ?? "",
@@ -3243,7 +3272,13 @@ function mapDetailSubscription(bff) {
3243
3272
  id: 0,
3244
3273
  name: ""
3245
3274
  },
3246
- subscription_skips: [],
3275
+ subscription_skips: bff.pending_skip_date ? [{
3276
+ id: 0,
3277
+ skipped_date: bff.pending_skip_date,
3278
+ reason: null,
3279
+ created_at: "",
3280
+ updated_at: ""
3281
+ }] : [],
3247
3282
  orders: [],
3248
3283
  bundled_items: bff.bundled_items ? bff.bundled_items.map((item) => ({
3249
3284
  quantity: item.quantity ?? 0,
@@ -8125,7 +8160,7 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
8125
8160
  allowSkipping: subscription.subscription_plan.allow_skipping,
8126
8161
  maxSkips: subscription.subscription_plan.max_skips,
8127
8162
  skippedCount: subscription.skipped_count,
8128
- hasPendingSkip: hasPendingSubscriptionSkip(subscription.subscription_skips),
8163
+ hasPendingSkip: hasPendingSubscriptionSkip(subscription.subscription_skips, /* @__PURE__ */ new Date(), subscription.timezone),
8129
8164
  canChangePaymentMethod: true,
8130
8165
  canWaiveFailedCycle,
8131
8166
  isWaiverPreviewLoading
@@ -10022,4 +10057,4 @@ const subscriptionsScreenPropertySchema = {
10022
10057
  //#endregion
10023
10058
  export { subscriptionsScreenPropertySchema as n, SubscriptionsScreen as t };
10024
10059
 
10025
- //# sourceMappingURL=SubscriptionsScreen-DElhGnvm.mjs.map
10060
+ //# sourceMappingURL=SubscriptionsScreen-B8RVPoyD.mjs.map