@fluid-app/portal-sdk 0.1.1279 → 0.1.1281
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/dist/{SubscriptionsScreen-Cl4wCwAq.cjs → SubscriptionsScreen-B5ZjeypU.cjs} +87 -30
- package/dist/SubscriptionsScreen-B5ZjeypU.cjs.map +1 -0
- package/dist/{SubscriptionsScreen-DsIb7GOH.cjs → SubscriptionsScreen-CRBSa32I.cjs} +1 -1
- package/dist/{SubscriptionsScreen-DmMIoY3B.mjs → SubscriptionsScreen-D06zme5B.mjs} +1 -1
- package/dist/{SubscriptionsScreen-yah2TAvw.mjs → SubscriptionsScreen-D0UjahrX.mjs} +87 -30
- package/dist/SubscriptionsScreen-D0UjahrX.mjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/SubscriptionsScreen-Cl4wCwAq.cjs.map +0 -1
- package/dist/SubscriptionsScreen-yah2TAvw.mjs.map +0 -1
|
@@ -3503,6 +3503,7 @@ function createPortalSubscriptionsAdapter(client) {
|
|
|
3503
3503
|
const body = {};
|
|
3504
3504
|
if (params.nextBillDate != null) body.next_bill_date = params.nextBillDate;
|
|
3505
3505
|
if (params.numberOfOrders != null) body.number_of_orders = params.numberOfOrders;
|
|
3506
|
+
if (params.confirmEarlyOrder) body.confirm_early_order = true;
|
|
3506
3507
|
return mapSubscriptionDetail(await require_prop_types.subscriptionsPause({
|
|
3507
3508
|
client,
|
|
3508
3509
|
path: { token: subscriptionToken },
|
|
@@ -3510,11 +3511,13 @@ function createPortalSubscriptionsAdapter(client) {
|
|
|
3510
3511
|
}));
|
|
3511
3512
|
},
|
|
3512
3513
|
resumeSubscription: async (subscriptionToken, params) => {
|
|
3513
|
-
const body =
|
|
3514
|
+
const body = {};
|
|
3515
|
+
if (params.nextBillDate) body.next_bill_date = params.nextBillDate;
|
|
3516
|
+
if (params.confirmEarlyOrder) body.confirm_early_order = true;
|
|
3514
3517
|
return mapSubscriptionDetail(await require_prop_types.subscriptionsResume({
|
|
3515
3518
|
client,
|
|
3516
3519
|
path: { token: subscriptionToken },
|
|
3517
|
-
body
|
|
3520
|
+
body: Object.keys(body).length > 0 ? body : void 0
|
|
3518
3521
|
}));
|
|
3519
3522
|
},
|
|
3520
3523
|
skipSubscription: async (subscriptionToken, _params) => {
|
|
@@ -4045,7 +4048,8 @@ function readEarlyOrderRefusal(error) {
|
|
|
4045
4048
|
if (meta?.code !== "early_order_confirmation_required" || typeof meta.scheduled_date !== "string") return null;
|
|
4046
4049
|
return {
|
|
4047
4050
|
scheduledDate: meta.scheduled_date,
|
|
4048
|
-
lastBillDate: typeof meta.last_bill_date === "string" ? meta.last_bill_date : null
|
|
4051
|
+
lastBillDate: typeof meta.last_bill_date === "string" ? meta.last_bill_date : null,
|
|
4052
|
+
requestedDate: typeof meta.requested_date === "string" ? meta.requested_date : null
|
|
4049
4053
|
};
|
|
4050
4054
|
}
|
|
4051
4055
|
//#endregion
|
|
@@ -6700,26 +6704,34 @@ function PauseSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, err
|
|
|
6700
6704
|
const maxSkippableOrders = getMaxSkippableOrders(billingInterval, billingIntervalUnit, currentNextBillDate);
|
|
6701
6705
|
const orderCountOptions = Array.from({ length: maxSkippableOrders }, (_, i) => i + 1);
|
|
6702
6706
|
const calculatedResumeDate = selectedOrderCount && currentNextBillDate ? calculateResumeDate(billingInterval, billingIntervalUnit, selectedOrderCount, currentNextBillDate) : null;
|
|
6707
|
+
const [earlyOrderRefusal, setEarlyOrderRefusal] = (0, react.useState)(null);
|
|
6703
6708
|
(0, react.useEffect)(() => {
|
|
6704
6709
|
if (!open) return;
|
|
6705
6710
|
setPauseType("indefinite");
|
|
6706
6711
|
setSelectedOrderCount(null);
|
|
6712
|
+
setEarlyOrderRefusal(null);
|
|
6707
6713
|
}, [open]);
|
|
6708
|
-
const handleConfirm = () => {
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
}
|
|
6713
|
-
if (pauseType === "order_count" && selectedOrderCount) onConfirm({
|
|
6714
|
+
const handleConfirm = async () => {
|
|
6715
|
+
let selection;
|
|
6716
|
+
if (pauseType === "indefinite") selection = { type: "indefinite" };
|
|
6717
|
+
else if (pauseType === "order_count" && selectedOrderCount) selection = {
|
|
6714
6718
|
type: "order_count",
|
|
6715
6719
|
numberOfOrders: selectedOrderCount,
|
|
6716
6720
|
shownResumeDate: calculatedResumeDate ? require_isAfter.format(calculatedResumeDate, "yyyy-MM-dd") : null
|
|
6717
|
-
}
|
|
6721
|
+
};
|
|
6722
|
+
else return;
|
|
6723
|
+
try {
|
|
6724
|
+
await onConfirm(selection, earlyOrderRefusal !== null);
|
|
6725
|
+
} catch (error) {
|
|
6726
|
+
const refusal = readEarlyOrderRefusal(error);
|
|
6727
|
+
if (refusal) setEarlyOrderRefusal(refusal);
|
|
6728
|
+
}
|
|
6718
6729
|
};
|
|
6719
6730
|
const handleDismiss = (next) => {
|
|
6720
6731
|
if (!next) {
|
|
6721
6732
|
setPauseType("indefinite");
|
|
6722
6733
|
setSelectedOrderCount(null);
|
|
6734
|
+
setEarlyOrderRefusal(null);
|
|
6723
6735
|
}
|
|
6724
6736
|
onOpenChange(next);
|
|
6725
6737
|
};
|
|
@@ -6744,6 +6756,7 @@ function PauseSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, err
|
|
|
6744
6756
|
] });
|
|
6745
6757
|
})();
|
|
6746
6758
|
const isActionDisabled = pauseType === "order_count" && !selectedOrderCount;
|
|
6759
|
+
const requestedDayIso = earlyOrderRefusal ? earlyOrderRefusal.requestedDate ?? earlyOrderRefusal.scheduledDate : "";
|
|
6747
6760
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_ResponsiveDialog.ResponsiveDialog, {
|
|
6748
6761
|
open,
|
|
6749
6762
|
onOpenChange: handleDismiss,
|
|
@@ -6753,7 +6766,21 @@ function PauseSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, err
|
|
|
6753
6766
|
children: [
|
|
6754
6767
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6755
6768
|
className: "space-y-4",
|
|
6756
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6769
|
+
children: earlyOrderRefusal ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6770
|
+
className: "space-y-3",
|
|
6771
|
+
role: "alert",
|
|
6772
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
6773
|
+
className: "text-foreground text-sm font-medium",
|
|
6774
|
+
children: t("bill_date_early_order_confirm_title", { date: formatLongDate$1(parseIsoDate(requestedDayIso), locale) })
|
|
6775
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6776
|
+
className: "text-muted-foreground space-y-1 text-sm",
|
|
6777
|
+
children: [
|
|
6778
|
+
earlyOrderRefusal.lastBillDate && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("bill_date_early_order_confirm_last_placed", { date: formatLongDate$1(parseIsoDate(earlyOrderRefusal.lastBillDate), locale) }) }),
|
|
6779
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("bill_date_early_order_confirm_next_scheduled", { date: formatLongDate$1(parseIsoDate(earlyOrderRefusal.scheduledDate), locale) }) }),
|
|
6780
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("bill_date_early_order_confirm_consequence", { date: formatLongDate$1(parseIsoDate(requestedDayIso), locale) }) })
|
|
6781
|
+
]
|
|
6782
|
+
})]
|
|
6783
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6757
6784
|
className: "space-y-4",
|
|
6758
6785
|
children: [
|
|
6759
6786
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -6822,14 +6849,15 @@ function PauseSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, err
|
|
|
6822
6849
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
|
|
6823
6850
|
variant: "outline",
|
|
6824
6851
|
className: "h-10 min-w-[70px] rounded p-3",
|
|
6825
|
-
onClick: () => handleDismiss(false),
|
|
6826
|
-
|
|
6852
|
+
onClick: () => earlyOrderRefusal ? setEarlyOrderRefusal(null) : handleDismiss(false),
|
|
6853
|
+
disabled: earlyOrderRefusal !== null && isLoading,
|
|
6854
|
+
children: earlyOrderRefusal ? t("bill_date_early_order_keep") : t("pause_dialog_cancel")
|
|
6827
6855
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
|
|
6828
6856
|
type: "button",
|
|
6829
6857
|
className: "h-10 min-w-[70px] rounded p-3",
|
|
6830
6858
|
onClick: handleConfirm,
|
|
6831
6859
|
disabled: isActionDisabled || isLoading,
|
|
6832
|
-
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("pause_dialog_action")
|
|
6860
|
+
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" }) : earlyOrderRefusal ? t("bill_date_early_order_place", { date: formatMediumDate(parseIsoDate(requestedDayIso), locale) }) : t("pause_dialog_action")
|
|
6833
6861
|
})]
|
|
6834
6862
|
}) })
|
|
6835
6863
|
]
|
|
@@ -6842,8 +6870,12 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
|
|
|
6842
6870
|
const [selectedDate, setSelectedDate] = (0, react.useState)(void 0);
|
|
6843
6871
|
const [calendarOpen, setCalendarOpen] = (0, react.useState)(false);
|
|
6844
6872
|
const [confirmingEarlyOrder, setConfirmingEarlyOrder] = (0, react.useState)(false);
|
|
6873
|
+
const [earlyOrderRefusal, setEarlyOrderRefusal] = (0, react.useState)(null);
|
|
6845
6874
|
(0, react.useEffect)(() => {
|
|
6846
|
-
if (!open)
|
|
6875
|
+
if (!open) {
|
|
6876
|
+
setConfirmingEarlyOrder(false);
|
|
6877
|
+
setEarlyOrderRefusal(null);
|
|
6878
|
+
}
|
|
6847
6879
|
}, [open]);
|
|
6848
6880
|
const [popoverContainer, setPopoverContainer] = (0, react.useState)(null);
|
|
6849
6881
|
const today = /* @__PURE__ */ new Date();
|
|
@@ -6856,21 +6888,35 @@ function ResumeSubscriptionDialog({ open, onOpenChange, onConfirm, isLoading, er
|
|
|
6856
6888
|
setSelectedDate(isBlackoutDay(clamped, blackoutDays) ? void 0 : clamped);
|
|
6857
6889
|
}, [open, defaultNextBillDate]);
|
|
6858
6890
|
const selectedDayIso = selectedDate ? require_isAfter.format(selectedDate, "yyyy-MM-dd") : "";
|
|
6859
|
-
const
|
|
6860
|
-
const
|
|
6891
|
+
const scheduledDate = earlyOrderRefusal?.scheduledDate ?? currentNextBillDate;
|
|
6892
|
+
const lastBillDate = earlyOrderRefusal ? earlyOrderRefusal.lastBillDate : currentLastBillDate;
|
|
6893
|
+
const scheduledDayIso = scheduledDate ? calendarDayIso(scheduledDate, timezone) : "";
|
|
6894
|
+
const lastOrderDayIso = lastBillDate ? calendarDayIso(lastBillDate, timezone) : "";
|
|
6861
6895
|
const placesEarlyOrder = selectedDayIso !== "" && scheduledDayIso !== "" && selectedDayIso < scheduledDayIso;
|
|
6896
|
+
const submitDate = async () => {
|
|
6897
|
+
try {
|
|
6898
|
+
await onConfirm(selectedDayIso, placesEarlyOrder);
|
|
6899
|
+
} catch (error) {
|
|
6900
|
+
const refusal = readEarlyOrderRefusal(error);
|
|
6901
|
+
if (refusal) {
|
|
6902
|
+
setEarlyOrderRefusal(refusal);
|
|
6903
|
+
setConfirmingEarlyOrder(true);
|
|
6904
|
+
}
|
|
6905
|
+
}
|
|
6906
|
+
};
|
|
6862
6907
|
const handleConfirm = () => {
|
|
6863
6908
|
if (!selectedDayIso) return;
|
|
6864
6909
|
if (placesEarlyOrder && !confirmingEarlyOrder) {
|
|
6865
6910
|
setConfirmingEarlyOrder(true);
|
|
6866
6911
|
return;
|
|
6867
6912
|
}
|
|
6868
|
-
|
|
6913
|
+
submitDate();
|
|
6869
6914
|
};
|
|
6870
6915
|
const handleDismiss = (next) => {
|
|
6871
6916
|
if (!next) {
|
|
6872
6917
|
setSelectedDate(void 0);
|
|
6873
6918
|
setConfirmingEarlyOrder(false);
|
|
6919
|
+
setEarlyOrderRefusal(null);
|
|
6874
6920
|
setCalendarOpen(false);
|
|
6875
6921
|
}
|
|
6876
6922
|
onOpenChange(next);
|
|
@@ -7089,7 +7135,7 @@ function EditBillDateDialog({ open, onOpenChange, onConfirm, isLoading, errorMes
|
|
|
7089
7135
|
const scheduledDayIso = scheduledDate ? calendarDayIso(scheduledDate, timezone) : "";
|
|
7090
7136
|
const lastOrderDayIso = lastBillDate ? calendarDayIso(lastBillDate, timezone) : "";
|
|
7091
7137
|
const selectedDayIso = selectedDate ? require_isAfter.format(selectedDate, "yyyy-MM-dd") : "";
|
|
7092
|
-
const placesEarlyOrder = confirmEarlyOrder && selectedDayIso !== "" && scheduledDayIso !== "" && selectedDayIso < scheduledDayIso;
|
|
7138
|
+
const placesEarlyOrder = (confirmEarlyOrder || earlyOrderRefusal !== null) && selectedDayIso !== "" && scheduledDayIso !== "" && selectedDayIso < scheduledDayIso;
|
|
7093
7139
|
const submitDate = async () => {
|
|
7094
7140
|
if (!selectedDayIso) return;
|
|
7095
7141
|
try {
|
|
@@ -8448,11 +8494,17 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
8448
8494
|
const shownPauseResumeDateRef = (0, react.useRef)(null);
|
|
8449
8495
|
const pauseMutation = usePauseSubscription({
|
|
8450
8496
|
onSuccess: (saved, { pauseParams }) => onSuccess?.(billDateMovedNotice(pauseParams.nextBillDate ?? shownPauseResumeDateRef.current, saved.subscription.next_bill_date, t, locale, saved.subscription.timezone) ?? t("subscription_paused")),
|
|
8451
|
-
onError: (err) =>
|
|
8497
|
+
onError: (err) => {
|
|
8498
|
+
if (readEarlyOrderRefusal(err)) return;
|
|
8499
|
+
onMutationError?.(t("failed_to_pause"), err);
|
|
8500
|
+
}
|
|
8452
8501
|
});
|
|
8453
8502
|
const resumeMutation = useResumeSubscription({
|
|
8454
8503
|
onSuccess: (saved, { resumeParams }) => onSuccess?.(billDateMovedNotice(resumeParams.nextBillDate, saved.subscription.next_bill_date, t, locale, saved.subscription.timezone) ?? t("subscription_resumed")),
|
|
8455
|
-
onError: (err) =>
|
|
8504
|
+
onError: (err) => {
|
|
8505
|
+
if (readEarlyOrderRefusal(err)) return;
|
|
8506
|
+
onMutationError?.(t("failed_to_resume"), err);
|
|
8507
|
+
}
|
|
8456
8508
|
});
|
|
8457
8509
|
const skipMutation = useSkipSubscription({
|
|
8458
8510
|
onSuccess: () => onSuccess?.(t("next_billing_skipped")),
|
|
@@ -8566,24 +8618,26 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
8566
8618
|
const aggregateRecoveryDisabled = directParentRecoveryDisabled || childPaymentRecoveryDisabled || waiverMutationPending;
|
|
8567
8619
|
const paymentMethodDisabled = isSubscriptionCompleted(subscription) || directParentRecoveryDisabled || waiverMutationPending || independentParentMutationDisabled;
|
|
8568
8620
|
const isMutating = independentParentMutationDisabled || aggregateRecoveryDisabled;
|
|
8569
|
-
const handlePauseConfirm = (selection) => {
|
|
8621
|
+
const handlePauseConfirm = (selection, confirmEarlyOrder) => {
|
|
8570
8622
|
const pauseParams = { customerId };
|
|
8571
8623
|
shownPauseResumeDateRef.current = null;
|
|
8572
8624
|
if (selection.type === "order_count") {
|
|
8573
8625
|
pauseParams.numberOfOrders = selection.numberOfOrders;
|
|
8574
8626
|
shownPauseResumeDateRef.current = selection.shownResumeDate;
|
|
8575
8627
|
}
|
|
8576
|
-
|
|
8628
|
+
if (confirmEarlyOrder) pauseParams.confirmEarlyOrder = true;
|
|
8629
|
+
return pauseMutation.mutateAsync({
|
|
8577
8630
|
subscriptionToken: token,
|
|
8578
8631
|
pauseParams
|
|
8579
8632
|
}, { onSuccess: () => setShowPauseModal(false) });
|
|
8580
8633
|
};
|
|
8581
|
-
const handleResumeConfirm = (nextBillDate) => {
|
|
8582
|
-
resumeMutation.
|
|
8634
|
+
const handleResumeConfirm = (nextBillDate, placesEarlyOrder) => {
|
|
8635
|
+
return resumeMutation.mutateAsync({
|
|
8583
8636
|
subscriptionToken: token,
|
|
8584
8637
|
resumeParams: {
|
|
8585
8638
|
customerId,
|
|
8586
|
-
nextBillDate
|
|
8639
|
+
nextBillDate,
|
|
8640
|
+
...placesEarlyOrder ? { confirmEarlyOrder: true } : {}
|
|
8587
8641
|
}
|
|
8588
8642
|
}, { onSuccess: () => setShowResumeModal(false) });
|
|
8589
8643
|
};
|
|
@@ -8690,7 +8744,10 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
8690
8744
|
}
|
|
8691
8745
|
}, {
|
|
8692
8746
|
onSuccess: () => setShowCancelModal(false),
|
|
8693
|
-
onError: () =>
|
|
8747
|
+
onError: (err) => {
|
|
8748
|
+
setShowCancelModal(false);
|
|
8749
|
+
if (readEarlyOrderRefusal(err)) onMutationError?.(t("failed_to_pause"), err);
|
|
8750
|
+
}
|
|
8694
8751
|
});
|
|
8695
8752
|
},
|
|
8696
8753
|
isPending: pauseMutation.isPending
|
|
@@ -8732,7 +8789,7 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
8732
8789
|
},
|
|
8733
8790
|
onConfirm: handlePauseConfirm,
|
|
8734
8791
|
isLoading: pauseMutation.isPending,
|
|
8735
|
-
errorMessage: pauseMutation.isError ? t("generic_error") : void 0,
|
|
8792
|
+
errorMessage: pauseMutation.isError && !readEarlyOrderRefusal(pauseMutation.error) ? t("generic_error") : void 0,
|
|
8736
8793
|
currentNextBillDate: subscription.next_bill_date,
|
|
8737
8794
|
billingInterval: plan.billing_interval,
|
|
8738
8795
|
billingIntervalUnit: plan.billing_interval_unit
|
|
@@ -8746,7 +8803,7 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
8746
8803
|
},
|
|
8747
8804
|
onConfirm: handleResumeConfirm,
|
|
8748
8805
|
isLoading: resumeMutation.isPending,
|
|
8749
|
-
errorMessage: resumeMutation.isError ? t("generic_error") : void 0,
|
|
8806
|
+
errorMessage: resumeMutation.isError && !readEarlyOrderRefusal(resumeMutation.error) ? t("generic_error") : void 0,
|
|
8750
8807
|
blackoutDays: subscription.blackout_days,
|
|
8751
8808
|
defaultNextBillDate: calculateNextBillDate(plan.billing_interval, plan.billing_interval_unit),
|
|
8752
8809
|
currentNextBillDate: subscription.next_bill_date,
|
|
@@ -10748,4 +10805,4 @@ Object.defineProperty(exports, "subscriptionsScreenPropertySchema", {
|
|
|
10748
10805
|
}
|
|
10749
10806
|
});
|
|
10750
10807
|
|
|
10751
|
-
//# sourceMappingURL=SubscriptionsScreen-
|
|
10808
|
+
//# sourceMappingURL=SubscriptionsScreen-B5ZjeypU.cjs.map
|