@fluid-app/portal-sdk 0.1.1219 → 0.1.1221

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.
@@ -6802,10 +6802,14 @@ function PauseSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, err
6802
6802
  }
6803
6803
  //#endregion
6804
6804
  //#region ../../subscriptions/ui/src/components/resume-subscription-dialog.tsx
6805
- function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, errorMessage, defaultNextBillDate, presentation = "dialog", blackoutDays }) {
6805
+ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, errorMessage, defaultNextBillDate, currentNextBillDate, currentLastBillDate, timezone, presentation = "dialog", blackoutDays }) {
6806
6806
  const { t, locale } = useSubscriptionsTranslation();
6807
6807
  const [selectedDate, setSelectedDate] = (0, react.useState)(void 0);
6808
6808
  const [calendarOpen, setCalendarOpen] = (0, react.useState)(false);
6809
+ const [confirmingEarlyOrder, setConfirmingEarlyOrder] = (0, react.useState)(false);
6810
+ (0, react.useEffect)(() => {
6811
+ if (!open) setConfirmingEarlyOrder(false);
6812
+ }, [open]);
6809
6813
  const [popoverContainer, setPopoverContainer] = (0, react.useState)(null);
6810
6814
  const today = /* @__PURE__ */ new Date();
6811
6815
  today.setHours(0, 0, 0, 0);
@@ -6816,13 +6820,22 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6816
6820
  const clamped = seeded < minDate ? minDate : seeded;
6817
6821
  setSelectedDate(isBlackoutDay(clamped, blackoutDays) ? void 0 : clamped);
6818
6822
  }, [open, defaultNextBillDate]);
6823
+ const selectedDayIso = selectedDate ? require_isAfter.format(selectedDate, "yyyy-MM-dd") : "";
6824
+ const scheduledDayIso = currentNextBillDate ? calendarDayIso(currentNextBillDate, timezone) : "";
6825
+ const lastOrderDayIso = currentLastBillDate ? calendarDayIso(currentLastBillDate, timezone) : "";
6826
+ const placesEarlyOrder = selectedDayIso !== "" && scheduledDayIso !== "" && selectedDayIso < scheduledDayIso;
6819
6827
  const handleConfirm = () => {
6820
- if (!selectedDate) return;
6821
- onConfirm(require_isAfter.format(selectedDate, "yyyy-MM-dd"));
6828
+ if (!selectedDayIso) return;
6829
+ if (placesEarlyOrder && !confirmingEarlyOrder) {
6830
+ setConfirmingEarlyOrder(true);
6831
+ return;
6832
+ }
6833
+ onConfirm(selectedDayIso);
6822
6834
  };
6823
6835
  const handleDismiss = (next) => {
6824
6836
  if (!next) {
6825
6837
  setSelectedDate(void 0);
6838
+ setConfirmingEarlyOrder(false);
6826
6839
  setCalendarOpen(false);
6827
6840
  }
6828
6841
  onOpenChange(next);
@@ -6837,7 +6850,21 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6837
6850
  children: [
6838
6851
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6839
6852
  className: "space-y-4",
6840
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6853
+ children: confirmingEarlyOrder && selectedDayIso !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6854
+ className: "space-y-3",
6855
+ role: "alert",
6856
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6857
+ className: "text-foreground text-sm font-medium",
6858
+ children: t("bill_date_early_order_confirm_title", { date: formatLongDate$1(parseIsoDate(selectedDayIso), locale) })
6859
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6860
+ className: "text-muted-foreground space-y-1 text-sm",
6861
+ children: [
6862
+ lastOrderDayIso !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("bill_date_early_order_confirm_last_placed", { date: formatLongDate$1(parseIsoDate(lastOrderDayIso), locale) }) }),
6863
+ scheduledDayIso !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("bill_date_early_order_confirm_next_scheduled", { date: formatLongDate$1(parseIsoDate(scheduledDayIso), locale) }) }),
6864
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("bill_date_early_order_confirm_consequence", { date: formatLongDate$1(parseIsoDate(selectedDayIso), locale) }) })
6865
+ ]
6866
+ })]
6867
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6841
6868
  className: "space-y-2",
6842
6869
  children: [
6843
6870
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Label, {
@@ -6865,6 +6892,7 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6865
6892
  selected: selectedDate,
6866
6893
  onSelect: (date) => {
6867
6894
  setSelectedDate(date);
6895
+ setConfirmingEarlyOrder(false);
6868
6896
  setCalendarOpen(false);
6869
6897
  },
6870
6898
  disabled: (date) => date < minDate || isBlackoutDay(date, blackoutDays),
@@ -6901,9 +6929,20 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6901
6929
  className: "text-destructive text-left text-sm",
6902
6930
  children: errorMessage
6903
6931
  }),
6904
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DialogFooter, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6932
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DialogFooter, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6905
6933
  className: "flex w-full flex-row justify-between gap-x-2",
6906
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
6934
+ children: confirmingEarlyOrder ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
6935
+ className: "bg-muted text-foreground ring-border hover:bg-muted/80 h-10 min-w-[70px] rounded p-3 ring-1",
6936
+ onClick: () => setConfirmingEarlyOrder(false),
6937
+ disabled: isLoading,
6938
+ children: t("bill_date_early_order_keep")
6939
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
6940
+ type: "button",
6941
+ className: "bg-primary text-primary-foreground h-10 min-w-[70px] rounded p-3 hover:opacity-90 disabled:opacity-50",
6942
+ onClick: handleConfirm,
6943
+ disabled: isLoading,
6944
+ children: isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.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) })
6945
+ })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
6907
6946
  className: "bg-muted text-foreground ring-border hover:bg-muted/80 h-10 min-w-[70px] rounded p-3 ring-1",
6908
6947
  onClick: () => handleDismiss(false),
6909
6948
  children: t("resume_dialog_cancel")
@@ -6913,7 +6952,7 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
6913
6952
  onClick: handleConfirm,
6914
6953
  disabled: !selectedDate || isLoading,
6915
6954
  children: isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "border-primary-foreground size-5 animate-spin rounded-full border-4 border-t-4 border-t-transparent" }) : t("resume_dialog_action")
6916
- })]
6955
+ })] })
6917
6956
  }) })
6918
6957
  ]
6919
6958
  });
@@ -8658,7 +8697,10 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
8658
8697
  isLoading: resumeMutation.isPending,
8659
8698
  errorMessage: resumeMutation.isError ? t("generic_error") : void 0,
8660
8699
  blackoutDays: subscription.blackout_days,
8661
- defaultNextBillDate: calculateNextBillDate(plan.billing_interval, plan.billing_interval_unit)
8700
+ defaultNextBillDate: calculateNextBillDate(plan.billing_interval, plan.billing_interval_unit),
8701
+ currentNextBillDate: subscription.next_bill_date,
8702
+ currentLastBillDate: subscription.last_bill_date,
8703
+ timezone: subscription.timezone
8662
8704
  }),
8663
8705
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCycleWaiverDialog, {
8664
8706
  open: waiverDialogToken === token,
@@ -10655,4 +10697,4 @@ Object.defineProperty(exports, "subscriptionsScreenPropertySchema", {
10655
10697
  }
10656
10698
  });
10657
10699
 
10658
- //# sourceMappingURL=SubscriptionsScreen-CRnrYD8h.cjs.map
10700
+ //# sourceMappingURL=SubscriptionsScreen-DtIxSeAE.cjs.map