@fluid-app/portal-sdk 0.1.1254 → 0.1.1256
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-0zJvMW3L.cjs → SubscriptionsScreen-Cl4wCwAq.cjs} +61 -14
- package/dist/SubscriptionsScreen-Cl4wCwAq.cjs.map +1 -0
- package/dist/{SubscriptionsScreen-SqGmmFg-.mjs → SubscriptionsScreen-DmMIoY3B.mjs} +1 -1
- package/dist/{SubscriptionsScreen-BIiCb34E.cjs → SubscriptionsScreen-DsIb7GOH.cjs} +1 -1
- package/dist/{SubscriptionsScreen-DdVt_D0C.mjs → SubscriptionsScreen-yah2TAvw.mjs} +61 -14
- package/dist/SubscriptionsScreen-yah2TAvw.mjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/SubscriptionsScreen-0zJvMW3L.cjs.map +0 -1
- package/dist/SubscriptionsScreen-DdVt_D0C.mjs.map +0 -1
|
@@ -3677,6 +3677,7 @@ function createPortalBundlesAdapter(client) {
|
|
|
3677
3677
|
};
|
|
3678
3678
|
if (params.address_id !== void 0) bundle.address_id = params.address_id;
|
|
3679
3679
|
if (params.volume_rep_id !== void 0) bundle.volume_rep_id = params.volume_rep_id;
|
|
3680
|
+
if (params.confirm_early_order !== void 0) bundle.confirm_early_order = params.confirm_early_order;
|
|
3680
3681
|
if (params.timezone !== void 0) bundle.timezone = params.timezone;
|
|
3681
3682
|
const bff = (await require_prop_types.subscriptionBundlesCreate({
|
|
3682
3683
|
client,
|
|
@@ -4030,6 +4031,24 @@ function billDateMovedNotice(pickedDate, savedDate, t, locale, timeZone) {
|
|
|
4030
4031
|
return day ? t("bill_date_moved_notice", { date: formatLongDate$1(parseIsoDate(day), locale) }) : null;
|
|
4031
4032
|
}
|
|
4032
4033
|
//#endregion
|
|
4034
|
+
//#region ../../subscriptions/core/src/utils/early-order-refusal.ts
|
|
4035
|
+
/**
|
|
4036
|
+
* Reads an `early_order_confirmation_required` refusal from a thrown API
|
|
4037
|
+
* error, or null for any other error. The client asks the shopper, then
|
|
4038
|
+
* repeats the write with `confirm_early_order`. Structural, so packages that
|
|
4039
|
+
* cannot import an API client can read it.
|
|
4040
|
+
*/
|
|
4041
|
+
function readEarlyOrderRefusal(error) {
|
|
4042
|
+
if (typeof error !== "object" || error === null) return null;
|
|
4043
|
+
const { body } = error;
|
|
4044
|
+
const meta = body?.meta;
|
|
4045
|
+
if (meta?.code !== "early_order_confirmation_required" || typeof meta.scheduled_date !== "string") return null;
|
|
4046
|
+
return {
|
|
4047
|
+
scheduledDate: meta.scheduled_date,
|
|
4048
|
+
lastBillDate: typeof meta.last_bill_date === "string" ? meta.last_bill_date : null
|
|
4049
|
+
};
|
|
4050
|
+
}
|
|
4051
|
+
//#endregion
|
|
4033
4052
|
//#region src/subscriptions/subscription-card-add-success.ts
|
|
4034
4053
|
/**
|
|
4035
4054
|
* Build the subscription create-payment-method onSuccess handler. On
|
|
@@ -5618,6 +5637,7 @@ function BundleSubscriptionsDrawer({ open, onOpenChange, subscriptions: subscrip
|
|
|
5618
5637
|
const { t, locale } = useSubscriptionsTranslation();
|
|
5619
5638
|
const { isMobile } = require_sidebar.useSidebar();
|
|
5620
5639
|
const [confirmingEarlyOrder, setConfirmingEarlyOrder] = (0, react.useState)(false);
|
|
5640
|
+
const [earlyOrderRefusal, setEarlyOrderRefusal] = (0, react.useState)(null);
|
|
5621
5641
|
const form = useBundleForm({
|
|
5622
5642
|
subscriptions: subscriptionList,
|
|
5623
5643
|
addresses,
|
|
@@ -5627,6 +5647,7 @@ function BundleSubscriptionsDrawer({ open, onOpenChange, subscriptions: subscrip
|
|
|
5627
5647
|
});
|
|
5628
5648
|
const handleClose = () => {
|
|
5629
5649
|
setConfirmingEarlyOrder(false);
|
|
5650
|
+
setEarlyOrderRefusal(null);
|
|
5630
5651
|
onOpenChange(false);
|
|
5631
5652
|
};
|
|
5632
5653
|
const handleNext = () => {
|
|
@@ -5642,7 +5663,7 @@ function BundleSubscriptionsDrawer({ open, onOpenChange, subscriptions: subscrip
|
|
|
5642
5663
|
const scheduledDay = member.next_bill_date ? calendarDayIso(member.next_bill_date) : "";
|
|
5643
5664
|
return selectedDayIso !== "" && scheduledDay !== "" && scheduledDay > selectedDayIso;
|
|
5644
5665
|
});
|
|
5645
|
-
const earliestAffectedDay = affectedMembers.map((member) => calendarDayIso(member.next_bill_date)).sort()[0] ?? "";
|
|
5666
|
+
const earliestAffectedDay = earlyOrderRefusal?.scheduledDate ?? affectedMembers.map((member) => calendarDayIso(member.next_bill_date)).sort()[0] ?? "";
|
|
5646
5667
|
const formatConfirmDay = (iso, style) => {
|
|
5647
5668
|
const [year, month, day] = iso.slice(0, 10).split("-").map(Number);
|
|
5648
5669
|
return new Intl.DateTimeFormat(locale, { dateStyle: style }).format(new Date(year ?? 1970, (month ?? 1) - 1, day ?? 1));
|
|
@@ -5653,12 +5674,20 @@ function BundleSubscriptionsDrawer({ open, onOpenChange, subscriptions: subscrip
|
|
|
5653
5674
|
setConfirmingEarlyOrder(true);
|
|
5654
5675
|
return;
|
|
5655
5676
|
}
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5677
|
+
try {
|
|
5678
|
+
await onSubmit({
|
|
5679
|
+
subscription_tokens: Array.from(form.selectedTokens),
|
|
5680
|
+
next_bill_date: form.formattedDate,
|
|
5681
|
+
address_id: form.selectedAddressId,
|
|
5682
|
+
payment_method_id: form.selectedPaymentMethodId,
|
|
5683
|
+
confirm_early_order: confirmingEarlyOrder
|
|
5684
|
+
});
|
|
5685
|
+
} catch (error) {
|
|
5686
|
+
const refusal = readEarlyOrderRefusal(error);
|
|
5687
|
+
if (!refusal) throw error;
|
|
5688
|
+
setEarlyOrderRefusal(refusal);
|
|
5689
|
+
setConfirmingEarlyOrder(true);
|
|
5690
|
+
}
|
|
5662
5691
|
};
|
|
5663
5692
|
const canLeaveStep1 = form.canProceedFromStep1 && !isLoadingSubscriptions;
|
|
5664
5693
|
const nextDisabled = form.step === 1 && !canLeaveStep1 || form.step === 2 && !form.canProceedFromStep2 || form.step === 3 && !form.canProceedFromStep3;
|
|
@@ -6001,10 +6030,15 @@ function SubscriptionsListScreenInner({ customerId, isLoadingCustomer, onToast }
|
|
|
6001
6030
|
subscription_tokens: params.subscription_tokens,
|
|
6002
6031
|
next_bill_date: params.next_bill_date,
|
|
6003
6032
|
address_id: params.address_id,
|
|
6033
|
+
confirm_early_order: params.confirm_early_order,
|
|
6004
6034
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
6005
6035
|
});
|
|
6006
6036
|
movedNotice = billDateMovedNotice(params.next_bill_date, bundle.next_bill_date, t, locale);
|
|
6007
6037
|
} catch (err) {
|
|
6038
|
+
if (readEarlyOrderRefusal(err)) {
|
|
6039
|
+
setIsBundling(false);
|
|
6040
|
+
throw err;
|
|
6041
|
+
}
|
|
6008
6042
|
const message = (require_fetch_client.isApiError(err) && err.status >= 400 && err.status < 500 ? err.message : void 0) ?? t("bundle_failed");
|
|
6009
6043
|
onToast?.(message, "error");
|
|
6010
6044
|
setIsBundling(false);
|
|
@@ -6987,6 +7021,7 @@ function EditBillDateDialog({ open, onOpenChange, onConfirm, isLoading, errorMes
|
|
|
6987
7021
|
const [selectedDate, setSelectedDate] = (0, react.useState)(void 0);
|
|
6988
7022
|
const [calendarOpen, setCalendarOpen] = (0, react.useState)(false);
|
|
6989
7023
|
const [confirmingEarlyOrder, setConfirmingEarlyOrder] = (0, react.useState)(false);
|
|
7024
|
+
const [earlyOrderRefusal, setEarlyOrderRefusal] = (0, react.useState)(null);
|
|
6990
7025
|
const [popoverContainer, setPopoverContainer] = (0, react.useState)(null);
|
|
6991
7026
|
const today = /* @__PURE__ */ new Date();
|
|
6992
7027
|
today.setHours(0, 0, 0, 0);
|
|
@@ -7049,13 +7084,23 @@ function EditBillDateDialog({ open, onOpenChange, onConfirm, isLoading, errorMes
|
|
|
7049
7084
|
setSelectedDate(isBlackoutDay(seeded, blackoutDays) ? void 0 : seeded);
|
|
7050
7085
|
} else setSelectedDate(void 0);
|
|
7051
7086
|
}, [open, currentNextBillDate]);
|
|
7052
|
-
const
|
|
7053
|
-
const
|
|
7087
|
+
const scheduledDate = earlyOrderRefusal?.scheduledDate ?? currentNextBillDate;
|
|
7088
|
+
const lastBillDate = earlyOrderRefusal ? earlyOrderRefusal.lastBillDate : currentLastBillDate;
|
|
7089
|
+
const scheduledDayIso = scheduledDate ? calendarDayIso(scheduledDate, timezone) : "";
|
|
7090
|
+
const lastOrderDayIso = lastBillDate ? calendarDayIso(lastBillDate, timezone) : "";
|
|
7054
7091
|
const selectedDayIso = selectedDate ? require_isAfter.format(selectedDate, "yyyy-MM-dd") : "";
|
|
7055
7092
|
const placesEarlyOrder = confirmEarlyOrder && selectedDayIso !== "" && scheduledDayIso !== "" && selectedDayIso < scheduledDayIso;
|
|
7056
|
-
const submitDate = () => {
|
|
7093
|
+
const submitDate = async () => {
|
|
7057
7094
|
if (!selectedDayIso) return;
|
|
7058
|
-
|
|
7095
|
+
try {
|
|
7096
|
+
await onConfirm(selectedDayIso, placesEarlyOrder);
|
|
7097
|
+
} catch (error) {
|
|
7098
|
+
const refusal = readEarlyOrderRefusal(error);
|
|
7099
|
+
if (refusal) {
|
|
7100
|
+
setEarlyOrderRefusal(refusal);
|
|
7101
|
+
setConfirmingEarlyOrder(true);
|
|
7102
|
+
}
|
|
7103
|
+
}
|
|
7059
7104
|
};
|
|
7060
7105
|
const handleConfirm = () => {
|
|
7061
7106
|
if (!selectedDayIso) return;
|
|
@@ -7069,6 +7114,7 @@ function EditBillDateDialog({ open, onOpenChange, onConfirm, isLoading, errorMes
|
|
|
7069
7114
|
if (!next) {
|
|
7070
7115
|
setSelectedDate(void 0);
|
|
7071
7116
|
setConfirmingEarlyOrder(false);
|
|
7117
|
+
setEarlyOrderRefusal(null);
|
|
7072
7118
|
setCalendarOpen(false);
|
|
7073
7119
|
}
|
|
7074
7120
|
onOpenChange(next);
|
|
@@ -8446,6 +8492,7 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
8446
8492
|
onError: (err, { subscriptionToken }) => {
|
|
8447
8493
|
if (latestSubscriptionTokenRef.current !== subscriptionToken) return;
|
|
8448
8494
|
setPendingNextBillDate(null);
|
|
8495
|
+
if (readEarlyOrderRefusal(err)) return;
|
|
8449
8496
|
onMutationError?.(t("failed_to_update_bill_date"), err);
|
|
8450
8497
|
}
|
|
8451
8498
|
});
|
|
@@ -8657,7 +8704,7 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
8657
8704
|
},
|
|
8658
8705
|
onConfirm: (nextBillDate, placesEarlyOrder) => {
|
|
8659
8706
|
setPendingNextBillDate(nextBillDate);
|
|
8660
|
-
editBillDateMutation.
|
|
8707
|
+
return editBillDateMutation.mutateAsync({
|
|
8661
8708
|
subscriptionToken: token,
|
|
8662
8709
|
body: {
|
|
8663
8710
|
next_bill_date: nextBillDate,
|
|
@@ -8666,7 +8713,7 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
8666
8713
|
});
|
|
8667
8714
|
},
|
|
8668
8715
|
isLoading: editBillDateMutation.isPending,
|
|
8669
|
-
errorMessage: editBillDateMutation.isError ? t("bill_date_error") : void 0,
|
|
8716
|
+
errorMessage: editBillDateMutation.isError && !readEarlyOrderRefusal(editBillDateMutation.error) ? t("bill_date_error") : void 0,
|
|
8670
8717
|
blackoutDays: subscription.blackout_days,
|
|
8671
8718
|
currentNextBillDate: subscription.next_bill_date,
|
|
8672
8719
|
currentLastBillDate: subscription.last_bill_date,
|
|
@@ -10701,4 +10748,4 @@ Object.defineProperty(exports, "subscriptionsScreenPropertySchema", {
|
|
|
10701
10748
|
}
|
|
10702
10749
|
});
|
|
10703
10750
|
|
|
10704
|
-
//# sourceMappingURL=SubscriptionsScreen-
|
|
10751
|
+
//# sourceMappingURL=SubscriptionsScreen-Cl4wCwAq.cjs.map
|