@fluid-app/portal-sdk 0.1.206 → 0.1.207
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/{FluidProvider-kEtG78-R.mjs → FluidProvider-5TV1VHtq.mjs} +2 -2
- package/dist/{FluidProvider-kEtG78-R.mjs.map → FluidProvider-5TV1VHtq.mjs.map} +1 -1
- package/dist/{FluidProvider-DgZSqdB4.cjs → FluidProvider-DP-sbNiR.cjs} +2 -2
- package/dist/{FluidProvider-DgZSqdB4.cjs.map → FluidProvider-DP-sbNiR.cjs.map} +1 -1
- package/dist/{MessagingScreen-B5F4cJL9.mjs → MessagingScreen-BSksI6Nw.mjs} +2 -2
- package/dist/{MessagingScreen-B5F4cJL9.mjs.map → MessagingScreen-BSksI6Nw.mjs.map} +1 -1
- package/dist/{MessagingScreen-BZNsf1M6.cjs → MessagingScreen-CXAzx8Ra.cjs} +2 -2
- package/dist/{MessagingScreen-Rr8rNnDM.cjs → MessagingScreen-D2G4zfez.cjs} +2 -2
- package/dist/{MessagingScreen-Rr8rNnDM.cjs.map → MessagingScreen-D2G4zfez.cjs.map} +1 -1
- package/dist/{OrdersScreen-Vcd072vf.cjs → OrdersScreen-CGvcgmLz.cjs} +1 -1
- package/dist/{OrdersScreen-CpU_Y_qI.cjs → OrdersScreen-Cx7xpzDk.cjs} +2 -2
- package/dist/{OrdersScreen-CpU_Y_qI.cjs.map → OrdersScreen-Cx7xpzDk.cjs.map} +1 -1
- package/dist/{OrdersScreen-jvCpiDDt.mjs → OrdersScreen-D4pe5mLs.mjs} +2 -2
- package/dist/{OrdersScreen-jvCpiDDt.mjs.map → OrdersScreen-D4pe5mLs.mjs.map} +1 -1
- package/dist/{PortalContentApiProvider-DqAbDYgq.cjs → PortalContentApiProvider-C5WzWC3k.cjs} +671 -765
- package/dist/PortalContentApiProvider-C5WzWC3k.cjs.map +1 -0
- package/dist/{PortalContentApiProvider-DxCHKK04.mjs → PortalContentApiProvider-CAa1jYwz.mjs} +671 -765
- package/dist/PortalContentApiProvider-CAa1jYwz.mjs.map +1 -0
- package/dist/{PortalProductsApiProvider-DaQUq6vq.cjs → PortalProductsApiProvider-Ca1oeTtJ.cjs} +2 -2
- package/dist/{PortalProductsApiProvider-DaQUq6vq.cjs.map → PortalProductsApiProvider-Ca1oeTtJ.cjs.map} +1 -1
- package/dist/{PortalProductsApiProvider-Y_4IQZBP.mjs → PortalProductsApiProvider-DHni3Y1V.mjs} +2 -2
- package/dist/{PortalProductsApiProvider-Y_4IQZBP.mjs.map → PortalProductsApiProvider-DHni3Y1V.mjs.map} +1 -1
- package/dist/{ProductsScreen-BQ4pOdSM.cjs → ProductsScreen-BZG_hkqN.cjs} +3 -3
- package/dist/{ProductsScreen-BQ4pOdSM.cjs.map → ProductsScreen-BZG_hkqN.cjs.map} +1 -1
- package/dist/{ProductsScreen-BXVezV86.mjs → ProductsScreen-DNXJ6Pml.mjs} +3 -3
- package/dist/{ProductsScreen-BXVezV86.mjs.map → ProductsScreen-DNXJ6Pml.mjs.map} +1 -1
- package/dist/{ProductsScreen-CwuS5xwA.cjs → ProductsScreen-DfKQAJ8t.cjs} +3 -3
- package/dist/{ProductsScreen-BuYB8ARn.mjs → ProductsScreen-dbTX6T_M.mjs} +3 -3
- package/dist/{ProfileScreen-BXyMS54d.cjs → ProfileScreen-CBwwNrKI.cjs} +2 -2
- package/dist/{ProfileScreen-AEC-nP75.mjs → ProfileScreen-Mb6dPLPo.mjs} +2 -2
- package/dist/{ProfileScreen-AEC-nP75.mjs.map → ProfileScreen-Mb6dPLPo.mjs.map} +1 -1
- package/dist/{ProfileScreen-BwB62fMh.cjs → ProfileScreen-Xym_39QW.cjs} +2 -2
- package/dist/{ProfileScreen-BwB62fMh.cjs.map → ProfileScreen-Xym_39QW.cjs.map} +1 -1
- package/dist/{ShareablesScreen-iI_TDe30.cjs → ShareablesScreen-B-q3ovAv.cjs} +3 -3
- package/dist/{ShareablesScreen-BncSEvDU.mjs → ShareablesScreen-Be0YXQ2y.mjs} +3 -3
- package/dist/{ShareablesScreen-BncSEvDU.mjs.map → ShareablesScreen-Be0YXQ2y.mjs.map} +1 -1
- package/dist/{ShareablesScreen-BRLq4OJS.mjs → ShareablesScreen-CpFuhYs5.mjs} +3 -3
- package/dist/{ShareablesScreen-DooJX53H.cjs → ShareablesScreen-vk_JZ-_9.cjs} +3 -3
- package/dist/{ShareablesScreen-DooJX53H.cjs.map → ShareablesScreen-vk_JZ-_9.cjs.map} +1 -1
- package/dist/{ShopScreen-B-D-upOl.cjs → ShopScreen-B92DRQkQ.cjs} +3 -3
- package/dist/{ShopScreen-B-D-upOl.cjs.map → ShopScreen-B92DRQkQ.cjs.map} +1 -1
- package/dist/{ShopScreen-Ja1W8IMs.mjs → ShopScreen-BOd8LD3L.mjs} +3 -3
- package/dist/{ShopScreen-Ja1W8IMs.mjs.map → ShopScreen-BOd8LD3L.mjs.map} +1 -1
- package/dist/{ShopScreen-CzPTkvqY.cjs → ShopScreen-BRN3JY4l.cjs} +3 -3
- package/dist/{SubscriptionsScreen-e2lCfnL0.cjs → SubscriptionsScreen-CQQPtSbM.cjs} +1 -1
- package/dist/{SubscriptionsScreen-COOAJ8r5.mjs → SubscriptionsScreen-CuP9OfBI.mjs} +94 -11
- package/dist/SubscriptionsScreen-CuP9OfBI.mjs.map +1 -0
- package/dist/{SubscriptionsScreen-Cx6u1tDv.cjs → SubscriptionsScreen-YUtsF_Eq.cjs} +92 -9
- package/dist/SubscriptionsScreen-YUtsF_Eq.cjs.map +1 -0
- package/dist/index.cjs +24 -24
- package/dist/index.mjs +24 -24
- package/dist/{portal_tenant-VLrtyCZ3.mjs → portal_tenant-Mu12SQA1.mjs} +2 -2
- package/dist/portal_tenant-Mu12SQA1.mjs.map +1 -0
- package/dist/{portal_tenant-DMF89PmN.cjs → portal_tenant-dfv03Fyi.cjs} +2 -2
- package/dist/portal_tenant-dfv03Fyi.cjs.map +1 -0
- package/package.json +13 -13
- package/dist/PortalContentApiProvider-DqAbDYgq.cjs.map +0 -1
- package/dist/PortalContentApiProvider-DxCHKK04.mjs.map +0 -1
- package/dist/SubscriptionsScreen-COOAJ8r5.mjs.map +0 -1
- package/dist/SubscriptionsScreen-Cx6u1tDv.cjs.map +0 -1
- package/dist/portal_tenant-DMF89PmN.cjs.map +0 -1
- package/dist/portal_tenant-VLrtyCZ3.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-9hOWP6kD.cjs");
|
|
2
|
-
const require_portal_tenant = require("./portal_tenant-
|
|
2
|
+
const require_portal_tenant = require("./portal_tenant-dfv03Fyi.cjs");
|
|
3
3
|
const require_PortalTenantClientProvider = require("./PortalTenantClientProvider-CVv-4rQ9.cjs");
|
|
4
4
|
const require_src = require("./src-D57IFKXU.cjs");
|
|
5
5
|
const require_ScreenHeaderContext = require("./ScreenHeaderContext-BXgWydjB.cjs");
|
|
@@ -2206,6 +2206,20 @@ function useReactivateSubscription(options) {
|
|
|
2206
2206
|
});
|
|
2207
2207
|
}
|
|
2208
2208
|
//#endregion
|
|
2209
|
+
//#region ../../subscriptions/core/src/hooks/use-update-subscription-info.ts
|
|
2210
|
+
function useUpdateSubscriptionInfo(options) {
|
|
2211
|
+
const api = useSubscriptionsApi();
|
|
2212
|
+
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
2213
|
+
return (0, _tanstack_react_query.useMutation)({
|
|
2214
|
+
mutationFn: (params) => api.updateSubscriptionInfo(params.subscriptionToken, params.body),
|
|
2215
|
+
onSuccess: () => {
|
|
2216
|
+
queryClient.invalidateQueries({ queryKey: subscriptionsKeys.all });
|
|
2217
|
+
options?.onSuccess?.();
|
|
2218
|
+
},
|
|
2219
|
+
onError: options?.onError
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
//#endregion
|
|
2209
2223
|
//#region ../../subscriptions/core/src/utils/subscription-helpers.ts
|
|
2210
2224
|
function formatSubscriptionFrequency(frequency) {
|
|
2211
2225
|
if (frequency === "day") return "Daily";
|
|
@@ -2616,7 +2630,10 @@ function createPortalSubscriptionsAdapter(client) {
|
|
|
2616
2630
|
return mapSubscriptionDetail(await require_portal_tenant.subscriptions_reactivate(client, subscriptionToken));
|
|
2617
2631
|
},
|
|
2618
2632
|
updateSubscriptionInfo: async (subscriptionToken, body) => {
|
|
2619
|
-
|
|
2633
|
+
const subscription = {};
|
|
2634
|
+
if (body.payment_method_id != null) subscription.payment_method_id = body.payment_method_id;
|
|
2635
|
+
if (body.quantity != null) subscription.quantity = body.quantity;
|
|
2636
|
+
return mapSubscriptionDetail(await require_portal_tenant.subscriptions_update(client, subscriptionToken, { subscription }));
|
|
2620
2637
|
}
|
|
2621
2638
|
};
|
|
2622
2639
|
}
|
|
@@ -3430,11 +3447,12 @@ function SubscriptionDetailSkeleton() {
|
|
|
3430
3447
|
})]
|
|
3431
3448
|
});
|
|
3432
3449
|
}
|
|
3433
|
-
function SubscriptionItemsSection({ subscription }) {
|
|
3450
|
+
function SubscriptionItemsSection({ subscription, displayQuantity, canEditQuantity = false, onQuantityChange, isUpdatingQuantity = false }) {
|
|
3434
3451
|
const variant = subscription.variant;
|
|
3435
3452
|
const product = variant?.product;
|
|
3436
|
-
const quantity = subscription.quantity;
|
|
3453
|
+
const quantity = displayQuantity ?? subscription.quantity;
|
|
3437
3454
|
const totalPrice = formatCurrency(subscription.price * quantity);
|
|
3455
|
+
const quantityInputId = `subscription-${subscription.subscription_token}-quantity`;
|
|
3438
3456
|
const discount = subscription.original_price != null ? subscription.original_price - subscription.price : 0;
|
|
3439
3457
|
const subtotal = discount > 0 ? formatCurrency(subscription.original_price * quantity) : totalPrice;
|
|
3440
3458
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
@@ -3475,9 +3493,9 @@ function SubscriptionItemsSection({ subscription }) {
|
|
|
3475
3493
|
}),
|
|
3476
3494
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3477
3495
|
className: "py-6",
|
|
3478
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
3496
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3479
3497
|
className: "flex flex-row items-center space-x-4",
|
|
3480
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3498
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3481
3499
|
className: "flex min-w-0 flex-1 flex-row space-x-4",
|
|
3482
3500
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3483
3501
|
className: "relative shrink-0",
|
|
@@ -3515,7 +3533,28 @@ function SubscriptionItemsSection({ subscription }) {
|
|
|
3515
3533
|
}) })
|
|
3516
3534
|
]
|
|
3517
3535
|
})]
|
|
3518
|
-
})
|
|
3536
|
+
}), canEditQuantity && onQuantityChange && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3537
|
+
className: "flex shrink-0 flex-col items-center",
|
|
3538
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
3539
|
+
htmlFor: quantityInputId,
|
|
3540
|
+
className: "text-muted-foreground mb-1 text-xs",
|
|
3541
|
+
children: "Quantity"
|
|
3542
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Input, {
|
|
3543
|
+
id: quantityInputId,
|
|
3544
|
+
type: "number",
|
|
3545
|
+
min: 1,
|
|
3546
|
+
step: 1,
|
|
3547
|
+
value: quantity || "",
|
|
3548
|
+
onChange: (e) => {
|
|
3549
|
+
if (!e.target.value) return;
|
|
3550
|
+
const next = parseInt(e.target.value, 10);
|
|
3551
|
+
if (Number.isFinite(next) && next > 0) onQuantityChange(next);
|
|
3552
|
+
},
|
|
3553
|
+
disabled: isUpdatingQuantity,
|
|
3554
|
+
className: require_src.cn("border-border bg-background h-10 w-16 border text-center", isUpdatingQuantity && "cursor-not-allowed opacity-50"),
|
|
3555
|
+
"aria-label": "Quantity"
|
|
3556
|
+
})]
|
|
3557
|
+
})]
|
|
3519
3558
|
})
|
|
3520
3559
|
}),
|
|
3521
3560
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3815,6 +3854,44 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
3815
3854
|
onSuccess: () => onSuccess?.("Subscription reactivated"),
|
|
3816
3855
|
onError: (err) => onMutationError?.("Failed to reactivate subscription", err)
|
|
3817
3856
|
});
|
|
3857
|
+
const [pendingQuantity, setPendingQuantity] = (0, react.useState)(null);
|
|
3858
|
+
const quantityDebounceRef = (0, react.useRef)(null);
|
|
3859
|
+
const quantityMutation = useUpdateSubscriptionInfo({
|
|
3860
|
+
onSuccess: () => {
|
|
3861
|
+
onSuccess?.("Quantity updated");
|
|
3862
|
+
},
|
|
3863
|
+
onError: (err) => {
|
|
3864
|
+
setPendingQuantity(null);
|
|
3865
|
+
onMutationError?.("Failed to update quantity", err);
|
|
3866
|
+
}
|
|
3867
|
+
});
|
|
3868
|
+
const serverQuantity = data?.subscription.quantity;
|
|
3869
|
+
(0, react.useEffect)(() => {
|
|
3870
|
+
if (pendingQuantity != null && serverQuantity === pendingQuantity) setPendingQuantity(null);
|
|
3871
|
+
}, [pendingQuantity, serverQuantity]);
|
|
3872
|
+
(0, react.useEffect)(() => () => {
|
|
3873
|
+
if (quantityDebounceRef.current) clearTimeout(quantityDebounceRef.current);
|
|
3874
|
+
}, []);
|
|
3875
|
+
const quantityMutate = quantityMutation.mutate;
|
|
3876
|
+
const handleQuantityChange = (0, react.useCallback)((next) => {
|
|
3877
|
+
const clamped = Math.max(1, next);
|
|
3878
|
+
setPendingQuantity(clamped);
|
|
3879
|
+
if (quantityDebounceRef.current) clearTimeout(quantityDebounceRef.current);
|
|
3880
|
+
quantityDebounceRef.current = setTimeout(() => {
|
|
3881
|
+
if (clamped === data?.subscription.quantity) {
|
|
3882
|
+
setPendingQuantity(null);
|
|
3883
|
+
return;
|
|
3884
|
+
}
|
|
3885
|
+
quantityMutate({
|
|
3886
|
+
subscriptionToken: token,
|
|
3887
|
+
body: { quantity: clamped }
|
|
3888
|
+
});
|
|
3889
|
+
}, 500);
|
|
3890
|
+
}, [
|
|
3891
|
+
data?.subscription.quantity,
|
|
3892
|
+
quantityMutate,
|
|
3893
|
+
token
|
|
3894
|
+
]);
|
|
3818
3895
|
const onErrorRef = (0, react.useRef)(onError);
|
|
3819
3896
|
onErrorRef.current = onError;
|
|
3820
3897
|
const onNotFoundRef = (0, react.useRef)(onNotFound);
|
|
@@ -3879,7 +3956,13 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
|
|
|
3879
3956
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3880
3957
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3881
3958
|
className: "flex flex-col lg:grid lg:grid-cols-8",
|
|
3882
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubscriptionItemsSection, {
|
|
3959
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubscriptionItemsSection, {
|
|
3960
|
+
subscription,
|
|
3961
|
+
displayQuantity: pendingQuantity ?? void 0,
|
|
3962
|
+
canEditQuantity: isActive,
|
|
3963
|
+
onQuantityChange: handleQuantityChange,
|
|
3964
|
+
isUpdatingQuantity: quantityMutation.isPending
|
|
3965
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubscriptionManagementSection, {
|
|
3883
3966
|
subscription,
|
|
3884
3967
|
isActive,
|
|
3885
3968
|
isPaused,
|
|
@@ -4034,4 +4117,4 @@ Object.defineProperty(exports, "subscriptionsScreenPropertySchema", {
|
|
|
4034
4117
|
}
|
|
4035
4118
|
});
|
|
4036
4119
|
|
|
4037
|
-
//# sourceMappingURL=SubscriptionsScreen-
|
|
4120
|
+
//# sourceMappingURL=SubscriptionsScreen-YUtsF_Eq.cjs.map
|