@fluid-app/portal-sdk 0.1.1219 → 0.1.1220

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-B2E8epKq.cjs");
70
70
  require("./sidebar-BTwncyT-.cjs");
71
71
  require("./ScreenHeaderContext-fJKG4BUl.cjs");
72
72
  require("./use-portal-card-add-3ds-flow-H2gDb3lf.cjs");
73
- const require_SubscriptionsScreen = require("./SubscriptionsScreen-CRnrYD8h.cjs");
73
+ const require_SubscriptionsScreen = require("./SubscriptionsScreen-DtIxSeAE.cjs");
74
74
  exports.SubscriptionsScreen = require_SubscriptionsScreen.SubscriptionsScreen;
75
75
  exports.subscriptionsScreenPropertySchema = require_SubscriptionsScreen.subscriptionsScreenPropertySchema;
@@ -6740,10 +6740,14 @@ function PauseSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, err
6740
6740
  }
6741
6741
  //#endregion
6742
6742
  //#region ../../subscriptions/ui/src/components/resume-subscription-dialog.tsx
6743
- function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, errorMessage, defaultNextBillDate, presentation = "dialog", blackoutDays }) {
6743
+ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, errorMessage, defaultNextBillDate, currentNextBillDate, currentLastBillDate, timezone, presentation = "dialog", blackoutDays }) {
6744
6744
  const { t, locale } = useSubscriptionsTranslation();
6745
6745
  const [selectedDate, setSelectedDate] = useState(void 0);
6746
6746
  const [calendarOpen, setCalendarOpen] = useState(false);
6747
+ const [confirmingEarlyOrder, setConfirmingEarlyOrder] = useState(false);
6748
+ useEffect(() => {
6749
+ if (!open) setConfirmingEarlyOrder(false);
6750
+ }, [open]);
6747
6751
  const [popoverContainer, setPopoverContainer] = useState(null);
6748
6752
  const today = /* @__PURE__ */ new Date();
6749
6753
  today.setHours(0, 0, 0, 0);
@@ -6754,13 +6758,22 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6754
6758
  const clamped = seeded < minDate ? minDate : seeded;
6755
6759
  setSelectedDate(isBlackoutDay(clamped, blackoutDays) ? void 0 : clamped);
6756
6760
  }, [open, defaultNextBillDate]);
6761
+ const selectedDayIso = selectedDate ? format(selectedDate, "yyyy-MM-dd") : "";
6762
+ const scheduledDayIso = currentNextBillDate ? calendarDayIso(currentNextBillDate, timezone) : "";
6763
+ const lastOrderDayIso = currentLastBillDate ? calendarDayIso(currentLastBillDate, timezone) : "";
6764
+ const placesEarlyOrder = selectedDayIso !== "" && scheduledDayIso !== "" && selectedDayIso < scheduledDayIso;
6757
6765
  const handleConfirm = () => {
6758
- if (!selectedDate) return;
6759
- onConfirm(format(selectedDate, "yyyy-MM-dd"));
6766
+ if (!selectedDayIso) return;
6767
+ if (placesEarlyOrder && !confirmingEarlyOrder) {
6768
+ setConfirmingEarlyOrder(true);
6769
+ return;
6770
+ }
6771
+ onConfirm(selectedDayIso);
6760
6772
  };
6761
6773
  const handleDismiss = (next) => {
6762
6774
  if (!next) {
6763
6775
  setSelectedDate(void 0);
6776
+ setConfirmingEarlyOrder(false);
6764
6777
  setCalendarOpen(false);
6765
6778
  }
6766
6779
  onOpenChange(next);
@@ -6775,7 +6788,21 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6775
6788
  children: [
6776
6789
  /* @__PURE__ */ jsx("div", {
6777
6790
  className: "space-y-4",
6778
- children: /* @__PURE__ */ jsxs("div", {
6791
+ children: confirmingEarlyOrder && selectedDayIso !== "" ? /* @__PURE__ */ jsxs("div", {
6792
+ className: "space-y-3",
6793
+ role: "alert",
6794
+ children: [/* @__PURE__ */ jsx("p", {
6795
+ className: "text-foreground text-sm font-medium",
6796
+ children: t("bill_date_early_order_confirm_title", { date: formatLongDate$1(parseIsoDate(selectedDayIso), locale) })
6797
+ }), /* @__PURE__ */ jsxs("div", {
6798
+ className: "text-muted-foreground space-y-1 text-sm",
6799
+ children: [
6800
+ lastOrderDayIso !== "" && /* @__PURE__ */ jsx("p", { children: t("bill_date_early_order_confirm_last_placed", { date: formatLongDate$1(parseIsoDate(lastOrderDayIso), locale) }) }),
6801
+ scheduledDayIso !== "" && /* @__PURE__ */ jsx("p", { children: t("bill_date_early_order_confirm_next_scheduled", { date: formatLongDate$1(parseIsoDate(scheduledDayIso), locale) }) }),
6802
+ /* @__PURE__ */ jsx("p", { children: t("bill_date_early_order_confirm_consequence", { date: formatLongDate$1(parseIsoDate(selectedDayIso), locale) }) })
6803
+ ]
6804
+ })]
6805
+ }) : /* @__PURE__ */ jsxs("div", {
6779
6806
  className: "space-y-2",
6780
6807
  children: [
6781
6808
  /* @__PURE__ */ jsx(Label, {
@@ -6803,6 +6830,7 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6803
6830
  selected: selectedDate,
6804
6831
  onSelect: (date) => {
6805
6832
  setSelectedDate(date);
6833
+ setConfirmingEarlyOrder(false);
6806
6834
  setCalendarOpen(false);
6807
6835
  },
6808
6836
  disabled: (date) => date < minDate || isBlackoutDay(date, blackoutDays),
@@ -6839,9 +6867,20 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6839
6867
  className: "text-destructive text-left text-sm",
6840
6868
  children: errorMessage
6841
6869
  }),
6842
- /* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsxs("div", {
6870
+ /* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsx("div", {
6843
6871
  className: "flex w-full flex-row justify-between gap-x-2",
6844
- children: [/* @__PURE__ */ jsx(Button, {
6872
+ children: confirmingEarlyOrder ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
6873
+ className: "bg-muted text-foreground ring-border hover:bg-muted/80 h-10 min-w-[70px] rounded p-3 ring-1",
6874
+ onClick: () => setConfirmingEarlyOrder(false),
6875
+ disabled: isLoading,
6876
+ children: t("bill_date_early_order_keep")
6877
+ }), /* @__PURE__ */ jsx(Button, {
6878
+ type: "button",
6879
+ className: "bg-primary text-primary-foreground h-10 min-w-[70px] rounded p-3 hover:opacity-90 disabled:opacity-50",
6880
+ onClick: handleConfirm,
6881
+ disabled: isLoading,
6882
+ children: isLoading ? /* @__PURE__ */ jsx("div", { className: "border-primary-foreground size-5 animate-spin rounded-full border-4 border-t-4 border-t-transparent" }) : t("bill_date_early_order_place", { date: formatMediumDate(parseIsoDate(selectedDayIso), locale) })
6883
+ })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
6845
6884
  className: "bg-muted text-foreground ring-border hover:bg-muted/80 h-10 min-w-[70px] rounded p-3 ring-1",
6846
6885
  onClick: () => handleDismiss(false),
6847
6886
  children: t("resume_dialog_cancel")
@@ -6851,7 +6890,7 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6851
6890
  onClick: handleConfirm,
6852
6891
  disabled: !selectedDate || isLoading,
6853
6892
  children: isLoading ? /* @__PURE__ */ jsx("div", { className: "border-primary-foreground size-5 animate-spin rounded-full border-4 border-t-4 border-t-transparent" }) : t("resume_dialog_action")
6854
- })]
6893
+ })] })
6855
6894
  }) })
6856
6895
  ]
6857
6896
  });
@@ -8596,7 +8635,10 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
8596
8635
  isLoading: resumeMutation.isPending,
8597
8636
  errorMessage: resumeMutation.isError ? t("generic_error") : void 0,
8598
8637
  blackoutDays: subscription.blackout_days,
8599
- defaultNextBillDate: calculateNextBillDate(plan.billing_interval, plan.billing_interval_unit)
8638
+ defaultNextBillDate: calculateNextBillDate(plan.billing_interval, plan.billing_interval_unit),
8639
+ currentNextBillDate: subscription.next_bill_date,
8640
+ currentLastBillDate: subscription.last_bill_date,
8641
+ timezone: subscription.timezone
8600
8642
  }),
8601
8643
  /* @__PURE__ */ jsx(FailedCycleWaiverDialog, {
8602
8644
  open: waiverDialogToken === token,
@@ -10582,4 +10624,4 @@ const subscriptionsScreenPropertySchema = {
10582
10624
  //#endregion
10583
10625
  export { subscriptionsScreenPropertySchema as n, SubscriptionsScreen as t };
10584
10626
 
10585
- //# sourceMappingURL=SubscriptionsScreen-B0g_o0v1.mjs.map
10627
+ //# sourceMappingURL=SubscriptionsScreen-C0gkZIka.mjs.map