@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.
Files changed (62) hide show
  1. package/dist/{FluidProvider-kEtG78-R.mjs → FluidProvider-5TV1VHtq.mjs} +2 -2
  2. package/dist/{FluidProvider-kEtG78-R.mjs.map → FluidProvider-5TV1VHtq.mjs.map} +1 -1
  3. package/dist/{FluidProvider-DgZSqdB4.cjs → FluidProvider-DP-sbNiR.cjs} +2 -2
  4. package/dist/{FluidProvider-DgZSqdB4.cjs.map → FluidProvider-DP-sbNiR.cjs.map} +1 -1
  5. package/dist/{MessagingScreen-B5F4cJL9.mjs → MessagingScreen-BSksI6Nw.mjs} +2 -2
  6. package/dist/{MessagingScreen-B5F4cJL9.mjs.map → MessagingScreen-BSksI6Nw.mjs.map} +1 -1
  7. package/dist/{MessagingScreen-BZNsf1M6.cjs → MessagingScreen-CXAzx8Ra.cjs} +2 -2
  8. package/dist/{MessagingScreen-Rr8rNnDM.cjs → MessagingScreen-D2G4zfez.cjs} +2 -2
  9. package/dist/{MessagingScreen-Rr8rNnDM.cjs.map → MessagingScreen-D2G4zfez.cjs.map} +1 -1
  10. package/dist/{OrdersScreen-Vcd072vf.cjs → OrdersScreen-CGvcgmLz.cjs} +1 -1
  11. package/dist/{OrdersScreen-CpU_Y_qI.cjs → OrdersScreen-Cx7xpzDk.cjs} +2 -2
  12. package/dist/{OrdersScreen-CpU_Y_qI.cjs.map → OrdersScreen-Cx7xpzDk.cjs.map} +1 -1
  13. package/dist/{OrdersScreen-jvCpiDDt.mjs → OrdersScreen-D4pe5mLs.mjs} +2 -2
  14. package/dist/{OrdersScreen-jvCpiDDt.mjs.map → OrdersScreen-D4pe5mLs.mjs.map} +1 -1
  15. package/dist/{PortalContentApiProvider-DqAbDYgq.cjs → PortalContentApiProvider-C5WzWC3k.cjs} +671 -765
  16. package/dist/PortalContentApiProvider-C5WzWC3k.cjs.map +1 -0
  17. package/dist/{PortalContentApiProvider-DxCHKK04.mjs → PortalContentApiProvider-CAa1jYwz.mjs} +671 -765
  18. package/dist/PortalContentApiProvider-CAa1jYwz.mjs.map +1 -0
  19. package/dist/{PortalProductsApiProvider-DaQUq6vq.cjs → PortalProductsApiProvider-Ca1oeTtJ.cjs} +2 -2
  20. package/dist/{PortalProductsApiProvider-DaQUq6vq.cjs.map → PortalProductsApiProvider-Ca1oeTtJ.cjs.map} +1 -1
  21. package/dist/{PortalProductsApiProvider-Y_4IQZBP.mjs → PortalProductsApiProvider-DHni3Y1V.mjs} +2 -2
  22. package/dist/{PortalProductsApiProvider-Y_4IQZBP.mjs.map → PortalProductsApiProvider-DHni3Y1V.mjs.map} +1 -1
  23. package/dist/{ProductsScreen-BQ4pOdSM.cjs → ProductsScreen-BZG_hkqN.cjs} +3 -3
  24. package/dist/{ProductsScreen-BQ4pOdSM.cjs.map → ProductsScreen-BZG_hkqN.cjs.map} +1 -1
  25. package/dist/{ProductsScreen-BXVezV86.mjs → ProductsScreen-DNXJ6Pml.mjs} +3 -3
  26. package/dist/{ProductsScreen-BXVezV86.mjs.map → ProductsScreen-DNXJ6Pml.mjs.map} +1 -1
  27. package/dist/{ProductsScreen-CwuS5xwA.cjs → ProductsScreen-DfKQAJ8t.cjs} +3 -3
  28. package/dist/{ProductsScreen-BuYB8ARn.mjs → ProductsScreen-dbTX6T_M.mjs} +3 -3
  29. package/dist/{ProfileScreen-BXyMS54d.cjs → ProfileScreen-CBwwNrKI.cjs} +2 -2
  30. package/dist/{ProfileScreen-AEC-nP75.mjs → ProfileScreen-Mb6dPLPo.mjs} +2 -2
  31. package/dist/{ProfileScreen-AEC-nP75.mjs.map → ProfileScreen-Mb6dPLPo.mjs.map} +1 -1
  32. package/dist/{ProfileScreen-BwB62fMh.cjs → ProfileScreen-Xym_39QW.cjs} +2 -2
  33. package/dist/{ProfileScreen-BwB62fMh.cjs.map → ProfileScreen-Xym_39QW.cjs.map} +1 -1
  34. package/dist/{ShareablesScreen-iI_TDe30.cjs → ShareablesScreen-B-q3ovAv.cjs} +3 -3
  35. package/dist/{ShareablesScreen-BncSEvDU.mjs → ShareablesScreen-Be0YXQ2y.mjs} +3 -3
  36. package/dist/{ShareablesScreen-BncSEvDU.mjs.map → ShareablesScreen-Be0YXQ2y.mjs.map} +1 -1
  37. package/dist/{ShareablesScreen-BRLq4OJS.mjs → ShareablesScreen-CpFuhYs5.mjs} +3 -3
  38. package/dist/{ShareablesScreen-DooJX53H.cjs → ShareablesScreen-vk_JZ-_9.cjs} +3 -3
  39. package/dist/{ShareablesScreen-DooJX53H.cjs.map → ShareablesScreen-vk_JZ-_9.cjs.map} +1 -1
  40. package/dist/{ShopScreen-B-D-upOl.cjs → ShopScreen-B92DRQkQ.cjs} +3 -3
  41. package/dist/{ShopScreen-B-D-upOl.cjs.map → ShopScreen-B92DRQkQ.cjs.map} +1 -1
  42. package/dist/{ShopScreen-Ja1W8IMs.mjs → ShopScreen-BOd8LD3L.mjs} +3 -3
  43. package/dist/{ShopScreen-Ja1W8IMs.mjs.map → ShopScreen-BOd8LD3L.mjs.map} +1 -1
  44. package/dist/{ShopScreen-CzPTkvqY.cjs → ShopScreen-BRN3JY4l.cjs} +3 -3
  45. package/dist/{SubscriptionsScreen-e2lCfnL0.cjs → SubscriptionsScreen-CQQPtSbM.cjs} +1 -1
  46. package/dist/{SubscriptionsScreen-COOAJ8r5.mjs → SubscriptionsScreen-CuP9OfBI.mjs} +94 -11
  47. package/dist/SubscriptionsScreen-CuP9OfBI.mjs.map +1 -0
  48. package/dist/{SubscriptionsScreen-Cx6u1tDv.cjs → SubscriptionsScreen-YUtsF_Eq.cjs} +92 -9
  49. package/dist/SubscriptionsScreen-YUtsF_Eq.cjs.map +1 -0
  50. package/dist/index.cjs +24 -24
  51. package/dist/index.mjs +24 -24
  52. package/dist/{portal_tenant-VLrtyCZ3.mjs → portal_tenant-Mu12SQA1.mjs} +2 -2
  53. package/dist/portal_tenant-Mu12SQA1.mjs.map +1 -0
  54. package/dist/{portal_tenant-DMF89PmN.cjs → portal_tenant-dfv03Fyi.cjs} +2 -2
  55. package/dist/portal_tenant-dfv03Fyi.cjs.map +1 -0
  56. package/package.json +13 -13
  57. package/dist/PortalContentApiProvider-DqAbDYgq.cjs.map +0 -1
  58. package/dist/PortalContentApiProvider-DxCHKK04.mjs.map +0 -1
  59. package/dist/SubscriptionsScreen-COOAJ8r5.mjs.map +0 -1
  60. package/dist/SubscriptionsScreen-Cx6u1tDv.cjs.map +0 -1
  61. package/dist/portal_tenant-DMF89PmN.cjs.map +0 -1
  62. package/dist/portal_tenant-VLrtyCZ3.mjs.map +0 -1
@@ -1,14 +1,14 @@
1
1
  import { r as __exportAll } from "./es-DmEK0Umf.mjs";
2
- import { C as subscriptions_skip, S as subscriptions_show, _ as subscriptions_cancel, b as subscriptions_reactivate, v as subscriptions_list, w as subscriptions_update, x as subscriptions_resume, y as subscriptions_pause } from "./portal_tenant-VLrtyCZ3.mjs";
2
+ import { C as subscriptions_skip, S as subscriptions_show, _ as subscriptions_cancel, b as subscriptions_reactivate, v as subscriptions_list, w as subscriptions_update, x as subscriptions_resume, y as subscriptions_pause } from "./portal_tenant-Mu12SQA1.mjs";
3
3
  import { n as usePortalTenantClient } from "./PortalTenantClientProvider-4ZmY6hac.mjs";
4
- import { $t as startOfWeek, Bt as longFormatters, C as Skeleton, Cn as AlertDialogFooter, En as Button, Ht as getWeekYear, It as format, K as Label, Lt as isProtectedDayOfYearToken, Pn as cn$1, Qt as startOfISOWeek, Rt as isProtectedWeekYearToken, Sn as AlertDialogDescription, Tn as AlertDialogTitle, Ut as getISOWeek, Vt as getWeek, Wt as enUS, Zt as getTimezoneOffsetInMilliseconds, a as ToggleGroup, an as millisecondsInHour, b as fluidToast, bn as AlertDialogCancel, cn as Breadcrumb, ct as DialogFooter, d as Table$1, dn as BreadcrumbList, en as getDefaultOptions$1, f as TableBody, fn as BreadcrumbPage, ft as DialogTitle, g as TableRow, h as TableHeader, ht as PopoverTrigger, in as constructFrom, it as Dialog, jt as Calendar$1, ln as BreadcrumbItem, lt as DialogHeader, mt as PopoverContent, nn as addDays, o as ToggleGroupItem, on as millisecondsInMinute, ot as DialogContent, p as TableCell, pn as BreadcrumbSeparator, pt as Popover, rn as toDate, sn as millisecondsInSecond, un as BreadcrumbLink, vn as AlertDialog, wn as AlertDialogHeader, xn as AlertDialogContent, yn as AlertDialogAction, zt as warnOrThrowProtectedError } from "./src-BEx23d86.mjs";
4
+ import { $t as startOfWeek, Bt as longFormatters, C as Skeleton, Cn as AlertDialogFooter, En as Button, Ht as getWeekYear, It as format, K as Label, L as Input, Lt as isProtectedDayOfYearToken, Pn as cn$1, Qt as startOfISOWeek, Rt as isProtectedWeekYearToken, Sn as AlertDialogDescription, Tn as AlertDialogTitle, Ut as getISOWeek, Vt as getWeek, Wt as enUS, Zt as getTimezoneOffsetInMilliseconds, a as ToggleGroup, an as millisecondsInHour, b as fluidToast, bn as AlertDialogCancel, cn as Breadcrumb, ct as DialogFooter, d as Table$1, dn as BreadcrumbList, en as getDefaultOptions$1, f as TableBody, fn as BreadcrumbPage, ft as DialogTitle, g as TableRow, h as TableHeader, ht as PopoverTrigger, in as constructFrom, it as Dialog, jt as Calendar$1, ln as BreadcrumbItem, lt as DialogHeader, mt as PopoverContent, nn as addDays, o as ToggleGroupItem, on as millisecondsInMinute, ot as DialogContent, p as TableCell, pn as BreadcrumbSeparator, pt as Popover, rn as toDate, sn as millisecondsInSecond, un as BreadcrumbLink, vn as AlertDialog, wn as AlertDialogHeader, xn as AlertDialogContent, yn as AlertDialogAction, zt as warnOrThrowProtectedError } from "./src-BEx23d86.mjs";
5
5
  import { r as useScreenHeaderBreadcrumbs } from "./ScreenHeaderContext-FYyYk97y.mjs";
6
6
  import { t as useAccount } from "./use-account-B16Tor2Q.mjs";
7
7
  import { n as useAppNavigation } from "./AppNavigationContext-BW3lSpfT.mjs";
8
8
  import { t as SearchSort } from "./SearchSort-TmuNOCwA.mjs";
9
9
  import { t as InfiniteScrollSentinel } from "./InfiniteScrollSentinel-BnPwh0Hr.mjs";
10
10
  import { r as TableColumn } from "./order-status-badge-BfOyK_Yi.mjs";
11
- import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
11
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
12
12
  import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
13
13
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
14
14
  import { CalendarIcon, Pause, Play, RotateCcw, SkipForward, XCircle } from "lucide-react";
@@ -2205,6 +2205,20 @@ function useReactivateSubscription(options) {
2205
2205
  });
2206
2206
  }
2207
2207
  //#endregion
2208
+ //#region ../../subscriptions/core/src/hooks/use-update-subscription-info.ts
2209
+ function useUpdateSubscriptionInfo(options) {
2210
+ const api = useSubscriptionsApi();
2211
+ const queryClient = useQueryClient();
2212
+ return useMutation({
2213
+ mutationFn: (params) => api.updateSubscriptionInfo(params.subscriptionToken, params.body),
2214
+ onSuccess: () => {
2215
+ queryClient.invalidateQueries({ queryKey: subscriptionsKeys.all });
2216
+ options?.onSuccess?.();
2217
+ },
2218
+ onError: options?.onError
2219
+ });
2220
+ }
2221
+ //#endregion
2208
2222
  //#region ../../subscriptions/core/src/utils/subscription-helpers.ts
2209
2223
  function formatSubscriptionFrequency(frequency) {
2210
2224
  if (frequency === "day") return "Daily";
@@ -2615,7 +2629,10 @@ function createPortalSubscriptionsAdapter(client) {
2615
2629
  return mapSubscriptionDetail(await subscriptions_reactivate(client, subscriptionToken));
2616
2630
  },
2617
2631
  updateSubscriptionInfo: async (subscriptionToken, body) => {
2618
- return mapSubscriptionDetail(await subscriptions_update(client, subscriptionToken, { subscription: { payment_method_id: body.payment_method_id } }));
2632
+ const subscription = {};
2633
+ if (body.payment_method_id != null) subscription.payment_method_id = body.payment_method_id;
2634
+ if (body.quantity != null) subscription.quantity = body.quantity;
2635
+ return mapSubscriptionDetail(await subscriptions_update(client, subscriptionToken, { subscription }));
2619
2636
  }
2620
2637
  };
2621
2638
  }
@@ -3429,11 +3446,12 @@ function SubscriptionDetailSkeleton() {
3429
3446
  })]
3430
3447
  });
3431
3448
  }
3432
- function SubscriptionItemsSection({ subscription }) {
3449
+ function SubscriptionItemsSection({ subscription, displayQuantity, canEditQuantity = false, onQuantityChange, isUpdatingQuantity = false }) {
3433
3450
  const variant = subscription.variant;
3434
3451
  const product = variant?.product;
3435
- const quantity = subscription.quantity;
3452
+ const quantity = displayQuantity ?? subscription.quantity;
3436
3453
  const totalPrice = formatCurrency(subscription.price * quantity);
3454
+ const quantityInputId = `subscription-${subscription.subscription_token}-quantity`;
3437
3455
  const discount = subscription.original_price != null ? subscription.original_price - subscription.price : 0;
3438
3456
  const subtotal = discount > 0 ? formatCurrency(subscription.original_price * quantity) : totalPrice;
3439
3457
  return /* @__PURE__ */ jsx("section", {
@@ -3474,9 +3492,9 @@ function SubscriptionItemsSection({ subscription }) {
3474
3492
  }),
3475
3493
  /* @__PURE__ */ jsx("div", {
3476
3494
  className: "py-6",
3477
- children: /* @__PURE__ */ jsx("div", {
3495
+ children: /* @__PURE__ */ jsxs("div", {
3478
3496
  className: "flex flex-row items-center space-x-4",
3479
- children: /* @__PURE__ */ jsxs("div", {
3497
+ children: [/* @__PURE__ */ jsxs("div", {
3480
3498
  className: "flex min-w-0 flex-1 flex-row space-x-4",
3481
3499
  children: [/* @__PURE__ */ jsx("div", {
3482
3500
  className: "relative shrink-0",
@@ -3514,7 +3532,28 @@ function SubscriptionItemsSection({ subscription }) {
3514
3532
  }) })
3515
3533
  ]
3516
3534
  })]
3517
- })
3535
+ }), canEditQuantity && onQuantityChange && /* @__PURE__ */ jsxs("div", {
3536
+ className: "flex shrink-0 flex-col items-center",
3537
+ children: [/* @__PURE__ */ jsx("label", {
3538
+ htmlFor: quantityInputId,
3539
+ className: "text-muted-foreground mb-1 text-xs",
3540
+ children: "Quantity"
3541
+ }), /* @__PURE__ */ jsx(Input, {
3542
+ id: quantityInputId,
3543
+ type: "number",
3544
+ min: 1,
3545
+ step: 1,
3546
+ value: quantity || "",
3547
+ onChange: (e) => {
3548
+ if (!e.target.value) return;
3549
+ const next = parseInt(e.target.value, 10);
3550
+ if (Number.isFinite(next) && next > 0) onQuantityChange(next);
3551
+ },
3552
+ disabled: isUpdatingQuantity,
3553
+ className: cn$1("border-border bg-background h-10 w-16 border text-center", isUpdatingQuantity && "cursor-not-allowed opacity-50"),
3554
+ "aria-label": "Quantity"
3555
+ })]
3556
+ })]
3518
3557
  })
3519
3558
  }),
3520
3559
  /* @__PURE__ */ jsxs("div", {
@@ -3814,6 +3853,44 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
3814
3853
  onSuccess: () => onSuccess?.("Subscription reactivated"),
3815
3854
  onError: (err) => onMutationError?.("Failed to reactivate subscription", err)
3816
3855
  });
3856
+ const [pendingQuantity, setPendingQuantity] = useState(null);
3857
+ const quantityDebounceRef = useRef(null);
3858
+ const quantityMutation = useUpdateSubscriptionInfo({
3859
+ onSuccess: () => {
3860
+ onSuccess?.("Quantity updated");
3861
+ },
3862
+ onError: (err) => {
3863
+ setPendingQuantity(null);
3864
+ onMutationError?.("Failed to update quantity", err);
3865
+ }
3866
+ });
3867
+ const serverQuantity = data?.subscription.quantity;
3868
+ useEffect(() => {
3869
+ if (pendingQuantity != null && serverQuantity === pendingQuantity) setPendingQuantity(null);
3870
+ }, [pendingQuantity, serverQuantity]);
3871
+ useEffect(() => () => {
3872
+ if (quantityDebounceRef.current) clearTimeout(quantityDebounceRef.current);
3873
+ }, []);
3874
+ const quantityMutate = quantityMutation.mutate;
3875
+ const handleQuantityChange = useCallback((next) => {
3876
+ const clamped = Math.max(1, next);
3877
+ setPendingQuantity(clamped);
3878
+ if (quantityDebounceRef.current) clearTimeout(quantityDebounceRef.current);
3879
+ quantityDebounceRef.current = setTimeout(() => {
3880
+ if (clamped === data?.subscription.quantity) {
3881
+ setPendingQuantity(null);
3882
+ return;
3883
+ }
3884
+ quantityMutate({
3885
+ subscriptionToken: token,
3886
+ body: { quantity: clamped }
3887
+ });
3888
+ }, 500);
3889
+ }, [
3890
+ data?.subscription.quantity,
3891
+ quantityMutate,
3892
+ token
3893
+ ]);
3817
3894
  const onErrorRef = useRef(onError);
3818
3895
  onErrorRef.current = onError;
3819
3896
  const onNotFoundRef = useRef(onNotFound);
@@ -3878,7 +3955,13 @@ function SubscriptionDetail({ token, onNotFound, onError, onSuccess, onMutationE
3878
3955
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3879
3956
  /* @__PURE__ */ jsxs("div", {
3880
3957
  className: "flex flex-col lg:grid lg:grid-cols-8",
3881
- children: [/* @__PURE__ */ jsx(SubscriptionItemsSection, { subscription }), /* @__PURE__ */ jsx(SubscriptionManagementSection, {
3958
+ children: [/* @__PURE__ */ jsx(SubscriptionItemsSection, {
3959
+ subscription,
3960
+ displayQuantity: pendingQuantity ?? void 0,
3961
+ canEditQuantity: isActive,
3962
+ onQuantityChange: handleQuantityChange,
3963
+ isUpdatingQuantity: quantityMutation.isPending
3964
+ }), /* @__PURE__ */ jsx(SubscriptionManagementSection, {
3882
3965
  subscription,
3883
3966
  isActive,
3884
3967
  isPaused,
@@ -4026,4 +4109,4 @@ const subscriptionsScreenPropertySchema = {
4026
4109
  //#endregion
4027
4110
  export { SubscriptionsScreen_exports as n, subscriptionsScreenPropertySchema as r, SubscriptionsScreen as t };
4028
4111
 
4029
- //# sourceMappingURL=SubscriptionsScreen-COOAJ8r5.mjs.map
4112
+ //# sourceMappingURL=SubscriptionsScreen-CuP9OfBI.mjs.map