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