@fluid-app/portal-sdk 0.1.253 → 0.1.255

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 (211) hide show
  1. package/dist/{AddressAutocompleteInput-Dy5sL54V.mjs → AddressAutocompleteInput-Dg-75n-K.mjs} +9 -12
  2. package/dist/AddressAutocompleteInput-Dg-75n-K.mjs.map +1 -0
  3. package/dist/{AddressAutocompleteInput-eO2ZMNvX.cjs → AddressAutocompleteInput-W2jWPYoJ.cjs} +26 -11
  4. package/dist/AddressAutocompleteInput-W2jWPYoJ.cjs.map +1 -0
  5. package/dist/{ContactsScreen-9gyQNZY-.cjs → ContactsScreen-BC5P7RD1.cjs} +2 -2
  6. package/dist/{ContactsScreen-B9I61v6-.cjs → ContactsScreen-BTBszjeo.cjs} +22 -22
  7. package/dist/{ContactsScreen-B9I61v6-.cjs.map → ContactsScreen-BTBszjeo.cjs.map} +1 -1
  8. package/dist/{ContactsScreen-gMBovFil.mjs → ContactsScreen-CYl6fWtE.mjs} +22 -22
  9. package/dist/{ContactsScreen-gMBovFil.mjs.map → ContactsScreen-CYl6fWtE.mjs.map} +1 -1
  10. package/dist/{FluidProvider-Can6hW1d.mjs → FluidProvider-B58aBJhk.mjs} +4 -5
  11. package/dist/{FluidProvider-Can6hW1d.mjs.map → FluidProvider-B58aBJhk.mjs.map} +1 -1
  12. package/dist/{FluidProvider-BLri8EGR.cjs → FluidProvider-IFbNov8P.cjs} +3 -10
  13. package/dist/{FluidProvider-BLri8EGR.cjs.map → FluidProvider-IFbNov8P.cjs.map} +1 -1
  14. package/dist/{MessagingScreen-CTjDMhpI.mjs → MessagingScreen-BU7xPuff.mjs} +2 -2
  15. package/dist/{MessagingScreen-CLnVhFC5.cjs → MessagingScreen-BohdQMST.cjs} +2 -2
  16. package/dist/{MessagingScreen-BqmMhGDq.mjs → MessagingScreen-CKE4KsvW.mjs} +2 -2
  17. package/dist/{MessagingScreen-BqmMhGDq.mjs.map → MessagingScreen-CKE4KsvW.mjs.map} +1 -1
  18. package/dist/{MessagingScreen-CLcsshRX.cjs → MessagingScreen-CrTcbztO.cjs} +2 -2
  19. package/dist/{MessagingScreen-CLcsshRX.cjs.map → MessagingScreen-CrTcbztO.cjs.map} +1 -1
  20. package/dist/{ProfileScreen-6nDSJ8F0.mjs → ProfileScreen-D42NNNqT.mjs} +3 -3
  21. package/dist/{ProfileScreen-DvWpS_uG.mjs → ProfileScreen-Dvq3SfmI.mjs} +3 -3
  22. package/dist/{ProfileScreen-DvWpS_uG.mjs.map → ProfileScreen-Dvq3SfmI.mjs.map} +1 -1
  23. package/dist/{ProfileScreen-Ckh4xGkq.cjs → ProfileScreen-LL3z9-cx.cjs} +3 -3
  24. package/dist/{ProfileScreen-Ckh4xGkq.cjs.map → ProfileScreen-LL3z9-cx.cjs.map} +1 -1
  25. package/dist/{ProfileScreen-0fVNXPBY.cjs → ProfileScreen-dU8ZM8eY.cjs} +3 -3
  26. package/dist/{ShopScreen-Cdxvxph7.cjs → ShopScreen-C4z4aB8f.cjs} +3 -3
  27. package/dist/{ShopScreen-Cdxvxph7.cjs.map → ShopScreen-C4z4aB8f.cjs.map} +1 -1
  28. package/dist/{ShopScreen-C5IVlT_r.cjs → ShopScreen-CrRI83Xk.cjs} +3 -3
  29. package/dist/{ShopScreen-CvefnY1H.mjs → ShopScreen-DXzBm27P.mjs} +3 -3
  30. package/dist/{ShopScreen-CvefnY1H.mjs.map → ShopScreen-DXzBm27P.mjs.map} +1 -1
  31. package/dist/{ShopScreen-Dyy0Yi2Q.mjs → ShopScreen-kuA8cWVc.mjs} +3 -3
  32. package/dist/{SubscriptionsScreen-ByoOMsky.cjs → SubscriptionsScreen-Bm8Ncl1e.cjs} +624 -166
  33. package/dist/SubscriptionsScreen-Bm8Ncl1e.cjs.map +1 -0
  34. package/dist/{SubscriptionsScreen-Y4UgpC1Y.mjs → SubscriptionsScreen-CsNE6gik.mjs} +627 -169
  35. package/dist/SubscriptionsScreen-CsNE6gik.mjs.map +1 -0
  36. package/dist/{SubscriptionsScreen-GCZYPM8-.cjs → SubscriptionsScreen-ztgglvXe.cjs} +2 -2
  37. package/dist/de-C_Zyp0-8.mjs +55 -0
  38. package/dist/de-C_Zyp0-8.mjs.map +1 -0
  39. package/dist/de-DeRNmEET.cjs +61 -0
  40. package/dist/de-DeRNmEET.cjs.map +1 -0
  41. package/dist/el-BD_oG0S8.cjs +61 -0
  42. package/dist/el-BD_oG0S8.cjs.map +1 -0
  43. package/dist/el-DR5yE3hc.mjs +55 -0
  44. package/dist/el-DR5yE3hc.mjs.map +1 -0
  45. package/dist/es-BBPaROwb.mjs +55 -0
  46. package/dist/es-BBPaROwb.mjs.map +1 -0
  47. package/dist/es-Bb_shBOb.cjs +61 -0
  48. package/dist/es-Bb_shBOb.cjs.map +1 -0
  49. package/dist/fr-BetvW17a.mjs +55 -0
  50. package/dist/fr-BetvW17a.mjs.map +1 -0
  51. package/dist/fr-Cah7_RPB.cjs +61 -0
  52. package/dist/fr-Cah7_RPB.cjs.map +1 -0
  53. package/dist/he-D3kODvf8.mjs +55 -0
  54. package/dist/he-D3kODvf8.mjs.map +1 -0
  55. package/dist/he-gYOd_7Xx.cjs +61 -0
  56. package/dist/he-gYOd_7Xx.cjs.map +1 -0
  57. package/dist/hu-C68EBfmm.mjs +55 -0
  58. package/dist/hu-C68EBfmm.mjs.map +1 -0
  59. package/dist/hu-Cn5739bo.cjs +61 -0
  60. package/dist/hu-Cn5739bo.cjs.map +1 -0
  61. package/dist/id-BH2K_Gbr.cjs +61 -0
  62. package/dist/id-BH2K_Gbr.cjs.map +1 -0
  63. package/dist/id-Bt8m325E.mjs +55 -0
  64. package/dist/id-Bt8m325E.mjs.map +1 -0
  65. package/dist/index.cjs +22 -58
  66. package/dist/index.cjs.map +1 -1
  67. package/dist/index.mjs +23 -59
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/it-BqtPjHii.cjs +61 -0
  70. package/dist/it-BqtPjHii.cjs.map +1 -0
  71. package/dist/it-WF3n2-Dh.mjs +55 -0
  72. package/dist/it-WF3n2-Dh.mjs.map +1 -0
  73. package/dist/ja-D6Gu5dFq.cjs +61 -0
  74. package/dist/ja-D6Gu5dFq.cjs.map +1 -0
  75. package/dist/ja-DwJ0vZjy.mjs +55 -0
  76. package/dist/ja-DwJ0vZjy.mjs.map +1 -0
  77. package/dist/ko-BdbrLr2D.mjs +55 -0
  78. package/dist/ko-BdbrLr2D.mjs.map +1 -0
  79. package/dist/ko-Dl2fBpWC.cjs +61 -0
  80. package/dist/ko-Dl2fBpWC.cjs.map +1 -0
  81. package/dist/nl-CA5o2t0S.cjs +61 -0
  82. package/dist/nl-CA5o2t0S.cjs.map +1 -0
  83. package/dist/nl-CUiqH5zZ.mjs +55 -0
  84. package/dist/nl-CUiqH5zZ.mjs.map +1 -0
  85. package/dist/pl-IbyEkNiD.mjs +55 -0
  86. package/dist/pl-IbyEkNiD.mjs.map +1 -0
  87. package/dist/pl-WlQv3-yq.cjs +61 -0
  88. package/dist/pl-WlQv3-yq.cjs.map +1 -0
  89. package/dist/pt-BhhvO4Qw.mjs +55 -0
  90. package/dist/pt-BhhvO4Qw.mjs.map +1 -0
  91. package/dist/pt-Cuoe77sP.cjs +61 -0
  92. package/dist/pt-Cuoe77sP.cjs.map +1 -0
  93. package/dist/ro-DIrwj2Mc.cjs +61 -0
  94. package/dist/ro-DIrwj2Mc.cjs.map +1 -0
  95. package/dist/ro-GgbW8Cux.mjs +55 -0
  96. package/dist/ro-GgbW8Cux.mjs.map +1 -0
  97. package/dist/ru-BC9x5NIp.mjs +55 -0
  98. package/dist/ru-BC9x5NIp.mjs.map +1 -0
  99. package/dist/ru-DCHj3W_N.cjs +61 -0
  100. package/dist/ru-DCHj3W_N.cjs.map +1 -0
  101. package/dist/{static-dict-adapter-Bxrw9FK5.cjs → static-dict-adapter-BLfRl80i.cjs} +1 -2
  102. package/dist/static-dict-adapter-BLfRl80i.cjs.map +1 -0
  103. package/dist/{static-dict-adapter-Bc5RtEkZ.mjs → static-dict-adapter-CdbsRyE-.mjs} +1 -2
  104. package/dist/static-dict-adapter-CdbsRyE-.mjs.map +1 -0
  105. package/dist/th-C2DeNJoD.mjs +55 -0
  106. package/dist/th-C2DeNJoD.mjs.map +1 -0
  107. package/dist/th-CebgyxgZ.cjs +61 -0
  108. package/dist/th-CebgyxgZ.cjs.map +1 -0
  109. package/dist/tl-CxY_bq4K.mjs +55 -0
  110. package/dist/tl-CxY_bq4K.mjs.map +1 -0
  111. package/dist/tl-DlFV8z30.cjs +61 -0
  112. package/dist/tl-DlFV8z30.cjs.map +1 -0
  113. package/dist/tr-Dj-KyRbz.cjs +61 -0
  114. package/dist/tr-Dj-KyRbz.cjs.map +1 -0
  115. package/dist/tr-DjrNAJD7.mjs +55 -0
  116. package/dist/tr-DjrNAJD7.mjs.map +1 -0
  117. package/dist/zh_CN-BE-GTtuO.mjs +55 -0
  118. package/dist/zh_CN-BE-GTtuO.mjs.map +1 -0
  119. package/dist/zh_CN-s2Jm_Dbu.cjs +61 -0
  120. package/dist/zh_CN-s2Jm_Dbu.cjs.map +1 -0
  121. package/dist/zh_TW-CR1xJCr6.mjs +55 -0
  122. package/dist/zh_TW-CR1xJCr6.mjs.map +1 -0
  123. package/dist/zh_TW-t10xPnCU.cjs +61 -0
  124. package/dist/zh_TW-t10xPnCU.cjs.map +1 -0
  125. package/package.json +14 -14
  126. package/dist/AddressAutocompleteInput-Dy5sL54V.mjs.map +0 -1
  127. package/dist/AddressAutocompleteInput-eO2ZMNvX.cjs.map +0 -1
  128. package/dist/SubscriptionsScreen-ByoOMsky.cjs.map +0 -1
  129. package/dist/SubscriptionsScreen-Y4UgpC1Y.mjs.map +0 -1
  130. package/dist/de-69v-QMl3.mjs +0 -6
  131. package/dist/de-69v-QMl3.mjs.map +0 -1
  132. package/dist/de-CvBkoR8P.cjs +0 -12
  133. package/dist/de-CvBkoR8P.cjs.map +0 -1
  134. package/dist/el-CP3qYmjt.cjs +0 -12
  135. package/dist/el-CP3qYmjt.cjs.map +0 -1
  136. package/dist/el-moRf_431.mjs +0 -6
  137. package/dist/el-moRf_431.mjs.map +0 -1
  138. package/dist/es-BAjIJqb8.mjs +0 -6
  139. package/dist/es-BAjIJqb8.mjs.map +0 -1
  140. package/dist/es-DdHDXWW1.cjs +0 -12
  141. package/dist/es-DdHDXWW1.cjs.map +0 -1
  142. package/dist/fr-B6rL2HtM.mjs +0 -6
  143. package/dist/fr-B6rL2HtM.mjs.map +0 -1
  144. package/dist/fr-wZG7Wsps.cjs +0 -12
  145. package/dist/fr-wZG7Wsps.cjs.map +0 -1
  146. package/dist/he-B5y3gSwp.mjs +0 -6
  147. package/dist/he-B5y3gSwp.mjs.map +0 -1
  148. package/dist/he-C_xAhEyE.cjs +0 -12
  149. package/dist/he-C_xAhEyE.cjs.map +0 -1
  150. package/dist/hu-BYzcu3lh.mjs +0 -6
  151. package/dist/hu-BYzcu3lh.mjs.map +0 -1
  152. package/dist/hu-CttQPNpi.cjs +0 -12
  153. package/dist/hu-CttQPNpi.cjs.map +0 -1
  154. package/dist/id-D_R-JS-K.mjs +0 -6
  155. package/dist/id-D_R-JS-K.mjs.map +0 -1
  156. package/dist/id-iykEHp5z.cjs +0 -12
  157. package/dist/id-iykEHp5z.cjs.map +0 -1
  158. package/dist/it-BM8H-5lK.mjs +0 -6
  159. package/dist/it-BM8H-5lK.mjs.map +0 -1
  160. package/dist/it-aOan3LJA.cjs +0 -12
  161. package/dist/it-aOan3LJA.cjs.map +0 -1
  162. package/dist/ja-DJwh8O25.cjs +0 -12
  163. package/dist/ja-DJwh8O25.cjs.map +0 -1
  164. package/dist/ja-uq5fuZ2n.mjs +0 -6
  165. package/dist/ja-uq5fuZ2n.mjs.map +0 -1
  166. package/dist/ko-BrOveybS.cjs +0 -12
  167. package/dist/ko-BrOveybS.cjs.map +0 -1
  168. package/dist/ko-DCZTj-Cn.mjs +0 -6
  169. package/dist/ko-DCZTj-Cn.mjs.map +0 -1
  170. package/dist/nl-BOJJj-wO.mjs +0 -6
  171. package/dist/nl-BOJJj-wO.mjs.map +0 -1
  172. package/dist/nl-CwVoaQ7l.cjs +0 -12
  173. package/dist/nl-CwVoaQ7l.cjs.map +0 -1
  174. package/dist/pl-Cjublhfj.mjs +0 -6
  175. package/dist/pl-Cjublhfj.mjs.map +0 -1
  176. package/dist/pl-CxlPZSW0.cjs +0 -12
  177. package/dist/pl-CxlPZSW0.cjs.map +0 -1
  178. package/dist/pt-DIdr0upI.cjs +0 -12
  179. package/dist/pt-DIdr0upI.cjs.map +0 -1
  180. package/dist/pt-Dj1-G3ee.mjs +0 -6
  181. package/dist/pt-Dj1-G3ee.mjs.map +0 -1
  182. package/dist/ro-94vihNFf.mjs +0 -6
  183. package/dist/ro-94vihNFf.mjs.map +0 -1
  184. package/dist/ro-B_Do9sPB.cjs +0 -12
  185. package/dist/ro-B_Do9sPB.cjs.map +0 -1
  186. package/dist/ru-CeRancbh.cjs +0 -12
  187. package/dist/ru-CeRancbh.cjs.map +0 -1
  188. package/dist/ru-DoATiIwu.mjs +0 -6
  189. package/dist/ru-DoATiIwu.mjs.map +0 -1
  190. package/dist/static-dict-adapter-Bc5RtEkZ.mjs.map +0 -1
  191. package/dist/static-dict-adapter-Bxrw9FK5.cjs.map +0 -1
  192. package/dist/th-B43cNBU0.cjs +0 -12
  193. package/dist/th-B43cNBU0.cjs.map +0 -1
  194. package/dist/th-YR02xDFQ.mjs +0 -6
  195. package/dist/th-YR02xDFQ.mjs.map +0 -1
  196. package/dist/tl-CHqst9js.cjs +0 -12
  197. package/dist/tl-CHqst9js.cjs.map +0 -1
  198. package/dist/tl-RXmEp0_X.mjs +0 -6
  199. package/dist/tl-RXmEp0_X.mjs.map +0 -1
  200. package/dist/tr-BuEAVG9I.mjs +0 -6
  201. package/dist/tr-BuEAVG9I.mjs.map +0 -1
  202. package/dist/tr-DYe4JMxj.cjs +0 -12
  203. package/dist/tr-DYe4JMxj.cjs.map +0 -1
  204. package/dist/zh_CN-CUeI99z0.cjs +0 -12
  205. package/dist/zh_CN-CUeI99z0.cjs.map +0 -1
  206. package/dist/zh_CN-NCLMiB-i.mjs +0 -6
  207. package/dist/zh_CN-NCLMiB-i.mjs.map +0 -1
  208. package/dist/zh_TW-CgTn_SV4.cjs +0 -12
  209. package/dist/zh_TW-CgTn_SV4.cjs.map +0 -1
  210. package/dist/zh_TW-CtEmIukX.mjs +0 -6
  211. package/dist/zh_TW-CtEmIukX.mjs.map +0 -1
@@ -3,18 +3,18 @@ import { i as usePayApi } from "./api-context-3GmfqvIB.mjs";
3
3
  import { n as useCountriesApi } from "./countries-api-context-CMh13cfX.mjs";
4
4
  import { C as subscriptions_reactivate, D as subscriptions_update, E as subscriptions_skip, S as subscriptions_pause, T as subscriptions_show, b as subscriptions_cancel, w as subscriptions_resume, x as subscriptions_list } from "./portal_tenant-Q3x7ALaZ.mjs";
5
5
  import { n as usePortalTenantClient } from "./PortalTenantClientProvider-4ZmY6hac.mjs";
6
- import { A as Select, Bt as warnOrThrowProtectedError, C as Skeleton, Cn as AlertDialogContent, Dn as AlertDialogTitle, En as AlertDialogHeader, Gt as enUS, Ht as getWeek, In as cn$1, It as isAfter, K as Label, L as Input, Lt as format, M as SelectItem, Mn as AccordionContent, Mt as Calendar$1, N as SelectTrigger, Nn as AccordionItem, On as Button, P as SelectValue, Pn as AccordionTrigger, Rt as isProtectedDayOfYearToken, Sn as AlertDialogCancel, Tn as AlertDialogFooter, Ut as getWeekYear, Vt as longFormatters, Wt as getISOWeek, Xt as addWeeks, Yt as addYears, a as ToggleGroup, an as addDays, b as fluidToast, bn as AlertDialog, cn as millisecondsInHour, ct as DialogFooter, d as Table$1, dn as Breadcrumb, en as getTimezoneOffsetInMilliseconds, f as TableBody, fn as BreadcrumbItem, ft as DialogTitle, g as TableRow, gn as BreadcrumbSeparator, h as TableHeader, hn as BreadcrumbPage, ht as PopoverTrigger, in as addMonths, it as Dialog, j as SelectContent, jn as Accordion, ln as millisecondsInMinute, lt as DialogHeader, mn as BreadcrumbList, mt as PopoverContent, nn as startOfWeek, o as ToggleGroupItem, on as toDate, ot as DialogContent, p as TableCell, pn as BreadcrumbLink, pt as Popover, rn as getDefaultOptions$1, sn as constructFrom, tn as startOfISOWeek, un as millisecondsInSecond, wn as AlertDialogDescription, zt as isProtectedWeekYearToken } from "./src-C2-FdDaD.mjs";
6
+ import { A as Select, Bt as warnOrThrowProtectedError, C as Skeleton, Cn as AlertDialogContent, Dn as AlertDialogTitle, En as AlertDialogHeader, Gt as enUS, Ht as getWeek, In as cn$1, It as isAfter, K as Label, L as Input, Lt as format, M as SelectItem, Mt as Calendar$1, N as SelectTrigger, On as Button, P as SelectValue, Rt as isProtectedDayOfYearToken, Sn as AlertDialogCancel, Tn as AlertDialogFooter, Ut as getWeekYear, Vt as longFormatters, Wt as getISOWeek, Xt as addWeeks, Yt as addYears, a as ToggleGroup, an as addDays, b as fluidToast, bn as AlertDialog, cn as millisecondsInHour, ct as DialogFooter, d as Table$1, dn as Breadcrumb, en as getTimezoneOffsetInMilliseconds, f as TableBody, fn as BreadcrumbItem, ft as DialogTitle, g as TableRow, gn as BreadcrumbSeparator, h as TableHeader, hn as BreadcrumbPage, ht as PopoverTrigger, in as addMonths, it as Dialog, j as SelectContent, ln as millisecondsInMinute, lt as DialogHeader, mn as BreadcrumbList, mt as PopoverContent, nn as startOfWeek, o as ToggleGroupItem, on as toDate, ot as DialogContent, p as TableCell, pn as BreadcrumbLink, pt as Popover, rn as getDefaultOptions$1, sn as constructFrom, tn as startOfISOWeek, un as millisecondsInSecond, wn as AlertDialogDescription, zt as isProtectedWeekYearToken } from "./src-C2-FdDaD.mjs";
7
7
  import { r as useScreenHeaderBreadcrumbs } from "./ScreenHeaderContext-kG_zh0zW.mjs";
8
8
  import { n as payKeys, r as storeKeys } from "./query-keys-xJy_fapN.mjs";
9
9
  import { t as useAccount } from "./use-account-CBMPhhs7.mjs";
10
10
  import { n as useAppNavigation } from "./AppNavigationContext-Dvc0yoZF.mjs";
11
- import { f as PaymentIcon, h as FluidPayCoreProvider, i as CreditCardFormDialog, m as getCardExpiry, n as createFluidPayApiAdapter, p as getCardDisplayName, r as mapToFluidPayPaymentMethod, t as AddressAutocompleteInput } from "./AddressAutocompleteInput-Dy5sL54V.mjs";
11
+ import { _ as EllipsesDropdown, a as AddressFormDialog, f as EditPaymentMethodDialog, g as ConfirmActionDialog, h as getCardExpiry, i as CreditCardFormDialog, m as getCardDisplayName, n as createFluidPayApiAdapter, p as PaymentIcon, r as mapToFluidPayPaymentMethod, t as AddressAutocompleteInput, v as FluidPayCoreProvider, y as ProfileUIProvider } from "./AddressAutocompleteInput-Dg-75n-K.mjs";
12
12
  import { i as InfiniteScrollSentinel, r as TableColumn } from "./order-status-badge-z-_tAqHq.mjs";
13
13
  import { t as SearchSort } from "./SearchSort-RMqZCtu4.mjs";
14
- import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
14
+ import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
15
15
  import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
16
16
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
- import { CalendarDays, CalendarIcon, ChevronLeft, ChevronRight, Pause, Play, RotateCcw, SkipForward, XCircle } from "lucide-react";
17
+ import { CalendarDays, CalendarIcon, ChevronDown, ChevronLeft, ChevronRight, Pause, Play, RotateCcw, SkipForward, XCircle } from "lucide-react";
18
18
  import { clsx } from "clsx";
19
19
  import { twMerge } from "tailwind-merge";
20
20
  //#region ../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDefaultOptions.js
@@ -2645,6 +2645,7 @@ function createPortalSubscriptionsAdapter(client) {
2645
2645
  const subscription = {};
2646
2646
  if (body.payment_method_id != null) subscription.payment_method_id = body.payment_method_id;
2647
2647
  if (body.quantity != null) subscription.quantity = body.quantity;
2648
+ if (body.address_id != null) subscription.address_id = body.address_id;
2648
2649
  if (body.next_bill_date != null) subscription.next_bill_date = body.next_bill_date;
2649
2650
  return mapSubscriptionDetail(await subscriptions_update(client, subscriptionToken, { subscription }));
2650
2651
  }
@@ -4003,7 +4004,7 @@ function SubscriptionManagementSection({ subscription, isActive, isPaused, isCan
4003
4004
  /* @__PURE__ */ jsxs("div", {
4004
4005
  className: "pt-2",
4005
4006
  children: [/* @__PURE__ */ jsx("h3", {
4006
- className: "text-foreground text-sm/6 font-semibold",
4007
+ className: "text-foreground mb-4 text-sm/6 font-semibold",
4007
4008
  children: "Payment & Shipping"
4008
4009
  }), /* @__PURE__ */ jsxs("div", {
4009
4010
  className: "flex flex-col",
@@ -4403,136 +4404,119 @@ function SubscriptionDetailScreen$1({ token, onNavigateToList, onNavigateToSubsc
4403
4404
  * (accordion, collapsed summary, list, add button), with rows that
4404
4405
  * commit a selection through onSelectPaymentMethod when clicked.
4405
4406
  */
4406
- function SelectablePaymentMethodDropdown({ title, displayPaymentMethod, paymentMethodList, selectedPaymentMethodId, onSelectPaymentMethod, onAddPaymentMethodClick, addPaymentMethodLabel = "+ Add a payment method", showAddButton = true, isLoading = false, isPending = false, className = "" }) {
4407
- const [paymentsValue, setPaymentsValue] = useState("");
4408
- const renderPaymentMethod = (paymentMethod) => {
4409
- const expiry = getCardExpiry(paymentMethod);
4410
- return /* @__PURE__ */ jsxs("div", {
4411
- className: "flex flex-row items-center space-x-2",
4412
- children: [/* @__PURE__ */ jsx("div", {
4413
- className: "flex h-6 w-10 flex-shrink-0 items-center justify-center",
4414
- children: /* @__PURE__ */ jsx(PaymentIcon, {
4415
- logoUrl: paymentMethod.details.logo_url,
4416
- brand: paymentMethod.details.card_type,
4417
- alt: paymentMethod.details.card_type ?? "Payment Method"
4418
- })
4419
- }), /* @__PURE__ */ jsxs("div", {
4420
- className: "flex flex-col",
4421
- children: [/* @__PURE__ */ jsx("div", {
4422
- className: "text-foreground flex items-center text-sm font-medium capitalize",
4423
- children: getCardDisplayName(paymentMethod)
4424
- }), expiry && /* @__PURE__ */ jsx("div", {
4425
- className: "text-muted-foreground text-sm",
4426
- children: expiry
4427
- })]
4428
- })]
4429
- });
4430
- };
4407
+ function SelectablePaymentMethodDropdown({ title, displayPaymentMethod, paymentMethodList, selectedPaymentMethodId, onSelectPaymentMethod, onAddPaymentMethodClick, onEditPaymentMethod, onDeletePaymentMethod, onMakeDefaultPaymentMethod, addPaymentMethodLabel = "+ Add a payment method", showAddButton = true, isLoading = false, isPending = false, className = "" }) {
4408
+ const [isOpen, setIsOpen] = useState(false);
4409
+ const sectionId = useId();
4410
+ const collapsedExpiry = displayPaymentMethod ? getCardExpiry(displayPaymentMethod) : null;
4431
4411
  return /* @__PURE__ */ jsxs("div", {
4432
4412
  className: cn$1("border-border mb-6 border-b pb-4", className),
4433
- children: [/* @__PURE__ */ jsx(Accordion, {
4434
- type: "single",
4435
- collapsible: true,
4436
- value: paymentsValue,
4437
- onValueChange: setPaymentsValue,
4438
- className: "w-full",
4439
- children: /* @__PURE__ */ jsxs(AccordionItem, {
4440
- value: "payment_methods",
4441
- className: "border-b-0",
4442
- children: [
4443
- /* @__PURE__ */ jsxs("div", {
4444
- className: "flex flex-row items-center justify-between",
4445
- children: [/* @__PURE__ */ jsx("div", {
4446
- className: "text-muted-foreground mt-4 mb-1 text-sm",
4447
- children: title
4448
- }), /* @__PURE__ */ jsx(AccordionTrigger, { className: "m-0 ml-2 flex h-auto min-h-0 w-auto py-0 hover:no-underline" })]
4449
- }),
4450
- !paymentsValue && isLoading ? /* @__PURE__ */ jsxs("div", {
4451
- className: "mb-2 flex w-full flex-row items-center space-x-2",
4452
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-10" }), /* @__PURE__ */ jsxs("div", {
4453
- className: "flex flex-col space-y-1",
4454
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-32" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })]
4455
- })]
4456
- }) : !paymentsValue && displayPaymentMethod && /* @__PURE__ */ jsx("div", {
4457
- className: "mb-2 flex w-full cursor-pointer flex-col",
4458
- onClick: () => setPaymentsValue("payment_methods"),
4459
- children: renderPaymentMethod(displayPaymentMethod)
4460
- }),
4461
- /* @__PURE__ */ jsx(AccordionContent, {
4462
- className: "max-h-[400px] overflow-y-auto px-0.5 pt-2 pb-1",
4463
- children: /* @__PURE__ */ jsx("div", {
4464
- className: "mt-2 flex flex-col justify-between space-y-4",
4465
- children: isLoading ? /* @__PURE__ */ jsx(Fragment$1, { children: [1, 2].map((i) => /* @__PURE__ */ jsx("div", {
4466
- className: "bg-muted items-center rounded p-3",
4467
- children: /* @__PURE__ */ jsxs("div", {
4468
- className: "flex flex-row items-center space-x-2",
4469
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-10" }), /* @__PURE__ */ jsxs("div", {
4470
- className: "flex flex-col space-y-1",
4471
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-32" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })]
4472
- })]
4473
- })
4474
- }, `skeleton-${i}`)) }) : paymentMethodList.map((paymentMethod) => {
4475
- const isSelected = selectedPaymentMethodId === paymentMethod.id;
4476
- const expiry = getCardExpiry(paymentMethod);
4477
- return /* @__PURE__ */ jsxs("button", {
4478
- type: "button",
4479
- "aria-pressed": isSelected,
4480
- disabled: isPending,
4481
- onClick: () => onSelectPaymentMethod(paymentMethod),
4482
- className: cn$1("bg-card text-card-foreground ring-border flex min-h-[48px] w-full flex-row items-center justify-between space-x-2 rounded p-3 text-left ring-1 transition-opacity", "not-disabled:cursor-pointer disabled:cursor-not-allowed", {
4483
- "opacity-60 hover:opacity-100": !isSelected,
4484
- "ring-primary z-10 opacity-100": isSelected
4485
- }),
4486
- children: [/* @__PURE__ */ jsxs("div", {
4487
- className: "flex flex-row items-center space-x-3",
4488
- children: [
4489
- /* @__PURE__ */ jsx("span", {
4490
- "aria-hidden": true,
4491
- className: cn$1("flex h-4 w-4 shrink-0 items-center justify-center rounded-full border", isSelected ? "border-primary" : "border-input"),
4492
- children: isSelected && /* @__PURE__ */ jsx("span", { className: "bg-primary h-2 w-2 rounded-full" })
4493
- }),
4494
- /* @__PURE__ */ jsx("div", {
4495
- className: "flex h-6 w-10 flex-shrink-0 items-center justify-center",
4496
- children: /* @__PURE__ */ jsx(PaymentIcon, {
4497
- logoUrl: paymentMethod.details.logo_url,
4498
- brand: paymentMethod.details.card_type,
4499
- alt: paymentMethod.details.card_type ?? "Payment Method"
4500
- })
4501
- }),
4502
- /* @__PURE__ */ jsxs("div", {
4503
- className: "flex flex-col",
4504
- children: [/* @__PURE__ */ jsx("div", {
4505
- className: "text-card-foreground flex items-center text-sm font-medium capitalize",
4506
- children: getCardDisplayName(paymentMethod)
4507
- }), expiry && /* @__PURE__ */ jsx("div", {
4508
- className: "text-muted-foreground text-sm",
4509
- children: expiry
4510
- })]
4511
- })
4512
- ]
4513
- }), paymentMethod.default && /* @__PURE__ */ jsx("p", {
4514
- className: "bg-secondary text-secondary-foreground rounded px-2 py-0.5 text-xs font-medium",
4515
- children: "Default"
4516
- })]
4517
- }, paymentMethod.id);
4518
- })
4519
- })
4413
+ children: [
4414
+ /* @__PURE__ */ jsxs("button", {
4415
+ type: "button",
4416
+ "aria-expanded": isOpen,
4417
+ "aria-controls": sectionId,
4418
+ onClick: () => setIsOpen((prev) => !prev),
4419
+ className: "flex w-full flex-row items-center justify-between",
4420
+ children: [/* @__PURE__ */ jsx("span", {
4421
+ className: "text-muted-foreground text-sm",
4422
+ children: title
4423
+ }), /* @__PURE__ */ jsx(ChevronDown, { className: cn$1("text-muted-foreground h-4 w-4 transition-transform duration-200", isOpen && "rotate-180") })]
4424
+ }),
4425
+ !isOpen && displayPaymentMethod && /* @__PURE__ */ jsxs("button", {
4426
+ type: "button",
4427
+ onClick: () => setIsOpen(true),
4428
+ className: "mt-1 mb-2 flex w-full cursor-pointer flex-row items-center gap-3 text-left",
4429
+ children: [/* @__PURE__ */ jsx("div", {
4430
+ className: "flex h-6 w-10 flex-shrink-0 items-center justify-center",
4431
+ children: /* @__PURE__ */ jsx(PaymentIcon, {
4432
+ logoUrl: displayPaymentMethod.details.logo_url,
4433
+ brand: displayPaymentMethod.details.card_type,
4434
+ alt: displayPaymentMethod.details.card_type ?? "Payment Method"
4520
4435
  })
4521
- ]
4436
+ }), /* @__PURE__ */ jsxs("div", {
4437
+ className: "flex min-w-0 flex-col",
4438
+ children: [/* @__PURE__ */ jsx("span", {
4439
+ className: "text-foreground text-sm font-medium capitalize",
4440
+ children: getCardDisplayName(displayPaymentMethod)
4441
+ }), collapsedExpiry && /* @__PURE__ */ jsx("span", {
4442
+ className: "text-muted-foreground text-sm",
4443
+ children: collapsedExpiry
4444
+ })]
4445
+ })]
4446
+ }),
4447
+ isOpen && /* @__PURE__ */ jsx("div", {
4448
+ id: sectionId,
4449
+ className: "mt-5 flex max-h-[400px] flex-col space-y-4 overflow-y-auto pr-0.5",
4450
+ children: isLoading ? /* @__PURE__ */ jsx(Fragment$1, { children: [1, 2].map((i) => /* @__PURE__ */ jsxs("div", {
4451
+ className: "bg-muted flex flex-row items-center space-x-2 rounded-sm p-3",
4452
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-10" }), /* @__PURE__ */ jsxs("div", {
4453
+ className: "flex flex-col space-y-1",
4454
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-32" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })]
4455
+ })]
4456
+ }, `skeleton-${i}`)) }) : paymentMethodList.map((paymentMethod) => {
4457
+ const isSelected = selectedPaymentMethodId === paymentMethod.id;
4458
+ const expiry = getCardExpiry(paymentMethod);
4459
+ return /* @__PURE__ */ jsxs("button", {
4460
+ type: "button",
4461
+ "aria-pressed": isSelected,
4462
+ disabled: isPending,
4463
+ onClick: () => onSelectPaymentMethod(paymentMethod),
4464
+ className: cn$1("text-foreground flex w-full flex-row items-center justify-between gap-3 rounded-sm p-3 text-left transition-colors", "not-disabled:cursor-pointer disabled:cursor-not-allowed disabled:opacity-60", isSelected ? "bg-background border-border border" : "bg-muted hover:bg-muted/80 border border-transparent"),
4465
+ children: [/* @__PURE__ */ jsxs("div", {
4466
+ className: "flex min-w-0 flex-row items-center gap-3",
4467
+ children: [/* @__PURE__ */ jsx("div", {
4468
+ className: "flex h-6 w-10 flex-shrink-0 items-center justify-center",
4469
+ children: /* @__PURE__ */ jsx(PaymentIcon, {
4470
+ logoUrl: paymentMethod.details.logo_url,
4471
+ brand: paymentMethod.details.card_type,
4472
+ alt: paymentMethod.details.card_type ?? "Payment Method"
4473
+ })
4474
+ }), /* @__PURE__ */ jsxs("div", {
4475
+ className: "flex min-w-0 flex-col",
4476
+ children: [/* @__PURE__ */ jsx("span", {
4477
+ className: "text-foreground text-sm font-medium capitalize",
4478
+ children: getCardDisplayName(paymentMethod)
4479
+ }), expiry && /* @__PURE__ */ jsx("span", {
4480
+ className: "text-muted-foreground text-sm",
4481
+ children: expiry
4482
+ })]
4483
+ })]
4484
+ }), /* @__PURE__ */ jsxs("div", {
4485
+ className: "flex shrink-0 flex-row items-center gap-2",
4486
+ children: [paymentMethod.default && /* @__PURE__ */ jsx("span", {
4487
+ className: "bg-primary text-primary-foreground rounded px-2 py-0.5 text-xs font-medium",
4488
+ children: "Default"
4489
+ }), (onEditPaymentMethod || onDeletePaymentMethod || onMakeDefaultPaymentMethod) && /* @__PURE__ */ jsx("span", {
4490
+ onClick: (e) => e.stopPropagation(),
4491
+ onKeyDown: (e) => e.stopPropagation(),
4492
+ children: /* @__PURE__ */ jsx(EllipsesDropdown, {
4493
+ onEdit: onEditPaymentMethod ? () => onEditPaymentMethod(paymentMethod) : void 0,
4494
+ onDelete: onDeletePaymentMethod ? () => onDeletePaymentMethod(paymentMethod) : void 0,
4495
+ onMakeDefault: !paymentMethod.default && onMakeDefaultPaymentMethod ? () => onMakeDefaultPaymentMethod(paymentMethod) : void 0
4496
+ })
4497
+ })]
4498
+ })]
4499
+ }, paymentMethod.id);
4500
+ })
4501
+ }),
4502
+ showAddButton && /* @__PURE__ */ jsx("button", {
4503
+ type: "button",
4504
+ disabled: isPending,
4505
+ className: "text-foreground mt-3 text-left text-sm disabled:cursor-not-allowed disabled:opacity-60",
4506
+ onClick: onAddPaymentMethodClick,
4507
+ children: addPaymentMethodLabel
4522
4508
  })
4523
- }), showAddButton && /* @__PURE__ */ jsx("button", {
4524
- type: "button",
4525
- disabled: isPending,
4526
- className: cn$1("text-foreground text-left text-sm disabled:cursor-not-allowed disabled:opacity-60", paymentsValue ? "mt-4" : "mt-3"),
4527
- onClick: onAddPaymentMethodClick,
4528
- children: addPaymentMethodLabel
4529
- })]
4509
+ ]
4530
4510
  });
4531
4511
  }
4532
4512
  //#endregion
4533
4513
  //#region src/subscriptions/PortalSubscriptionPaymentMethodSection.tsx
4534
- const t = (key) => ({
4514
+ const t$1 = (key) => ({
4535
4515
  add_credit_card: "Add Credit Card",
4516
+ edit_card: "Card Details",
4517
+ delete_credit_card: "Delete Credit Card",
4518
+ delete_credit_card_message: "Are you sure you want to delete this payment method? This action cannot be undone.",
4519
+ delete: "Delete",
4536
4520
  save_card: "Save Card",
4537
4521
  securing: "Loading secure form...",
4538
4522
  cancel: "Cancel",
@@ -4580,6 +4564,9 @@ function PortalSubscriptionPaymentMethodSection({ paymentMethod: currentPaymentM
4580
4564
  const queryClient = useQueryClient();
4581
4565
  const fluidPayShim = useMemo(() => createFluidPayApiAdapter(payApi), [payApi]);
4582
4566
  const [isAddDialogOpen, setIsAddDialogOpen] = useState(false);
4567
+ const [editingPaymentMethod, setEditingPaymentMethod] = useState(null);
4568
+ const [deletingPaymentMethod, setDeletingPaymentMethod] = useState(null);
4569
+ const [deleteError, setDeleteError] = useState(void 0);
4583
4570
  const { data: paymentMethods = [], isLoading: isLoadingMethods } = useQuery({
4584
4571
  queryKey: payKeys.paymentMethods.list(),
4585
4572
  queryFn: async () => {
@@ -4590,7 +4577,7 @@ function PortalSubscriptionPaymentMethodSection({ paymentMethod: currentPaymentM
4590
4577
  const { data: countriesData } = useQuery({
4591
4578
  queryKey: storeKeys.countries(),
4592
4579
  queryFn: () => countriesApi.listCountries(),
4593
- enabled: isAddDialogOpen
4580
+ enabled: isAddDialogOpen || editingPaymentMethod !== null
4594
4581
  });
4595
4582
  const countryOptions = useMemo(() => [...countriesData?.countries ?? []].map((c) => ({
4596
4583
  iso: c.code,
@@ -4615,49 +4602,513 @@ function PortalSubscriptionPaymentMethodSection({ paymentMethod: currentPaymentM
4615
4602
  },
4616
4603
  onError: (err) => onError?.("Failed to add payment method", err)
4617
4604
  });
4618
- return /* @__PURE__ */ jsxs(FluidPayCoreProvider, {
4619
- api: fluidPayShim,
4620
- children: [/* @__PURE__ */ jsx(SelectablePaymentMethodDropdown, {
4621
- title: "Payment Method",
4622
- displayPaymentMethod: paymentMethods.find((pm) => pm.id === currentPaymentMethod.id) ?? subscriptionPaymentMethodToFluidPay(currentPaymentMethod),
4623
- paymentMethodList: paymentMethods,
4624
- onAddPaymentMethodClick: () => setIsAddDialogOpen(true),
4625
- addPaymentMethodLabel: "+ Add Payment Method",
4626
- showAddButton: true,
4627
- isLoading: isLoadingMethods,
4628
- isPending: updateSubscription.isPending || addCardMutation.isPending,
4629
- selectedPaymentMethodId: currentPaymentMethod.id,
4630
- onSelectPaymentMethod: (pm) => {
4631
- if (pm.id === currentPaymentMethod.id) return;
4632
- updateSubscription.mutate({
4633
- subscriptionToken,
4634
- body: { payment_method_id: pm.id }
4635
- });
4605
+ const updatePaymentMethodMutation = useMutation({
4606
+ mutationFn: ({ paymentMethodId, data }) => payApi.updatePaymentMethod(paymentMethodId, { payment_method: {
4607
+ default: data.set_as_default,
4608
+ billing_address: {
4609
+ name: data.billing_address.name,
4610
+ street1: data.billing_address.address1,
4611
+ street2: data.billing_address.address2 ?? null,
4612
+ city: data.billing_address.city,
4613
+ state: data.billing_address.state,
4614
+ zip: data.billing_address.zip,
4615
+ country: data.billing_address.country_code
4636
4616
  }
4637
- }), /* @__PURE__ */ jsx(CreditCardFormDialog, {
4638
- isOpen: isAddDialogOpen,
4639
- onClose: () => setIsAddDialogOpen(false),
4640
- t,
4641
- onSubmit: async (data) => {
4642
- try {
4643
- await addCardMutation.mutateAsync(data);
4644
- setIsAddDialogOpen(false);
4645
- } catch {}
4646
- },
4647
- isSubmitting: addCardMutation.isPending,
4648
- countries: countryOptions,
4649
- jwt: "",
4650
- renderAddressAutocomplete: ({ control, setValue, countryCode }) => /* @__PURE__ */ jsx(AddressAutocompleteInput, {
4651
- control,
4652
- setValue,
4653
- countryIso: countryCode,
4654
- addressLineField: "address1",
4655
- cityField: "city",
4656
- stateField: "state",
4657
- postalCodeField: "zip",
4658
- placeholder: t("address_line_1")
4617
+ } }),
4618
+ onSuccess: async () => {
4619
+ await queryClient.invalidateQueries({ queryKey: payKeys.paymentMethods.all });
4620
+ onSuccess?.("Payment method updated");
4621
+ },
4622
+ onError: (err) => onError?.("Failed to update payment method", err)
4623
+ });
4624
+ const deletePaymentMethodMutation = useMutation({
4625
+ mutationFn: (paymentMethodId) => payApi.deletePaymentMethod(paymentMethodId),
4626
+ onSuccess: async () => {
4627
+ await queryClient.invalidateQueries({ queryKey: payKeys.paymentMethods.all });
4628
+ onSuccess?.("Payment method deleted");
4629
+ }
4630
+ });
4631
+ const makeDefaultPaymentMethodMutation = useMutation({
4632
+ mutationFn: (pm) => {
4633
+ const body = { payment_method: { default: true } };
4634
+ if (pm.billing_address) body.payment_method.billing_address = {
4635
+ name: pm.billing_address.name,
4636
+ street1: pm.billing_address.address1 ?? "",
4637
+ street2: pm.billing_address.address2 ?? null,
4638
+ city: pm.billing_address.city ?? "",
4639
+ state: pm.billing_address.state ?? "",
4640
+ zip: pm.billing_address.zip ?? "",
4641
+ country: pm.billing_address.country_code ?? ""
4642
+ };
4643
+ return payApi.updatePaymentMethod(pm.id, body);
4644
+ },
4645
+ onSuccess: async () => {
4646
+ await queryClient.invalidateQueries({ queryKey: payKeys.paymentMethods.all });
4647
+ onSuccess?.("Default payment method updated");
4648
+ },
4649
+ onError: (err) => onError?.("Failed to update default payment method", err)
4650
+ });
4651
+ const displayed = paymentMethods.find((pm) => pm.id === currentPaymentMethod.id) ?? subscriptionPaymentMethodToFluidPay(currentPaymentMethod);
4652
+ const handleConfirmDelete = async () => {
4653
+ if (!deletingPaymentMethod) return;
4654
+ setDeleteError(void 0);
4655
+ try {
4656
+ await deletePaymentMethodMutation.mutateAsync(deletingPaymentMethod.id);
4657
+ setDeletingPaymentMethod(null);
4658
+ } catch (err) {
4659
+ setDeleteError(err instanceof Error ? err.message : "We were unable to delete this payment method. Please try again.");
4660
+ }
4661
+ };
4662
+ return /* @__PURE__ */ jsx(FluidPayCoreProvider, {
4663
+ api: fluidPayShim,
4664
+ children: /* @__PURE__ */ jsxs(ProfileUIProvider, {
4665
+ t: t$1,
4666
+ children: [
4667
+ /* @__PURE__ */ jsx(SelectablePaymentMethodDropdown, {
4668
+ title: "Payment Method",
4669
+ displayPaymentMethod: displayed,
4670
+ paymentMethodList: paymentMethods,
4671
+ onAddPaymentMethodClick: () => setIsAddDialogOpen(true),
4672
+ addPaymentMethodLabel: "+ Add Payment Method",
4673
+ showAddButton: true,
4674
+ isLoading: isLoadingMethods,
4675
+ isPending: updateSubscription.isPending || addCardMutation.isPending || updatePaymentMethodMutation.isPending || makeDefaultPaymentMethodMutation.isPending,
4676
+ selectedPaymentMethodId: currentPaymentMethod.id,
4677
+ onSelectPaymentMethod: (pm) => {
4678
+ if (pm.id === currentPaymentMethod.id) return;
4679
+ updateSubscription.mutate({
4680
+ subscriptionToken,
4681
+ body: { payment_method_id: pm.id }
4682
+ });
4683
+ },
4684
+ onEditPaymentMethod: (pm) => setEditingPaymentMethod(pm),
4685
+ onDeletePaymentMethod: (pm) => {
4686
+ setDeleteError(void 0);
4687
+ setDeletingPaymentMethod(pm);
4688
+ },
4689
+ onMakeDefaultPaymentMethod: (pm) => makeDefaultPaymentMethodMutation.mutate(pm)
4690
+ }),
4691
+ /* @__PURE__ */ jsx(CreditCardFormDialog, {
4692
+ isOpen: isAddDialogOpen,
4693
+ onClose: () => setIsAddDialogOpen(false),
4694
+ t: t$1,
4695
+ onSubmit: async (data) => {
4696
+ try {
4697
+ await addCardMutation.mutateAsync(data);
4698
+ setIsAddDialogOpen(false);
4699
+ } catch {}
4700
+ },
4701
+ isSubmitting: addCardMutation.isPending,
4702
+ countries: countryOptions,
4703
+ jwt: "",
4704
+ renderAddressAutocomplete: ({ control, setValue, countryCode }) => /* @__PURE__ */ jsx(AddressAutocompleteInput, {
4705
+ control,
4706
+ setValue,
4707
+ countryIso: countryCode,
4708
+ addressLineField: "address1",
4709
+ cityField: "city",
4710
+ stateField: "state",
4711
+ postalCodeField: "zip",
4712
+ placeholder: t$1("address_line_1")
4713
+ })
4714
+ }),
4715
+ /* @__PURE__ */ jsx(EditPaymentMethodDialog, {
4716
+ isOpen: editingPaymentMethod !== null,
4717
+ paymentMethod: editingPaymentMethod,
4718
+ billingAddress: editingPaymentMethod?.billing_address ?? null,
4719
+ onClose: () => setEditingPaymentMethod(null),
4720
+ onSubmit: async (data) => {
4721
+ if (!editingPaymentMethod) return;
4722
+ try {
4723
+ await updatePaymentMethodMutation.mutateAsync({
4724
+ paymentMethodId: editingPaymentMethod.id,
4725
+ data
4726
+ });
4727
+ setEditingPaymentMethod(null);
4728
+ } catch {}
4729
+ },
4730
+ isSubmitting: updatePaymentMethodMutation.isPending,
4731
+ countries: countryOptions
4732
+ }),
4733
+ /* @__PURE__ */ jsx(ConfirmActionDialog, {
4734
+ title: t$1("delete_credit_card"),
4735
+ description: t$1("delete_credit_card_message"),
4736
+ actionText: t$1("delete"),
4737
+ openDialog: deletingPaymentMethod !== null,
4738
+ setOpenDialog: (open) => {
4739
+ if (!open) {
4740
+ setDeletingPaymentMethod(null);
4741
+ setDeleteError(void 0);
4742
+ }
4743
+ },
4744
+ onAction: handleConfirmDelete,
4745
+ errorMsg: deleteError,
4746
+ isLoading: deletePaymentMethodMutation.isPending
4747
+ })
4748
+ ]
4749
+ })
4750
+ });
4751
+ }
4752
+ //#endregion
4753
+ //#region src/subscriptions/SelectableAddressDropdown.tsx
4754
+ function formatLine1(address) {
4755
+ return [address.address1, address.address2].filter(Boolean).join(", ");
4756
+ }
4757
+ function formatCityStateZip(address) {
4758
+ return [[address.city, address.state].filter(Boolean).join(", "), address.postal_code].filter(Boolean).join(" ");
4759
+ }
4760
+ /**
4761
+ * Selectable variant of profile-ui's AddressDropdown, mirroring
4762
+ * SelectablePaymentMethodDropdown. Flat layout (no Card wrapper) so it
4763
+ * sits inline next to the payment method dropdown in the subscription
4764
+ * detail's Payment & Shipping section.
4765
+ */
4766
+ function SelectableAddressDropdown({ title, displayAddress, addressList, selectedAddressId, onSelectAddress, onAddAddressClick, onEditAddress, onDeleteAddress, onMakeDefaultAddress, addAddressLabel = "+ Add an Address", showAddButton = true, isLoading = false, isPending = false, className = "" }) {
4767
+ const [isOpen, setIsOpen] = useState(false);
4768
+ const sectionId = useId();
4769
+ return /* @__PURE__ */ jsxs("div", {
4770
+ className: cn$1("border-border mb-6 border-b pb-4", className),
4771
+ children: [
4772
+ /* @__PURE__ */ jsxs("button", {
4773
+ type: "button",
4774
+ "aria-expanded": isOpen,
4775
+ "aria-controls": sectionId,
4776
+ onClick: () => setIsOpen((prev) => !prev),
4777
+ className: "flex w-full flex-row items-center justify-between",
4778
+ children: [/* @__PURE__ */ jsx("span", {
4779
+ className: "text-muted-foreground text-sm",
4780
+ children: title
4781
+ }), /* @__PURE__ */ jsx(ChevronDown, { className: cn$1("text-muted-foreground h-4 w-4 transition-transform duration-200", isOpen && "rotate-180") })]
4782
+ }),
4783
+ !isOpen && displayAddress && /* @__PURE__ */ jsxs("button", {
4784
+ type: "button",
4785
+ onClick: () => setIsOpen(true),
4786
+ className: "mt-1 mb-2 flex w-full cursor-pointer flex-col text-left",
4787
+ children: [/* @__PURE__ */ jsxs("span", {
4788
+ className: "text-foreground text-sm font-medium",
4789
+ children: [
4790
+ displayAddress.name,
4791
+ displayAddress.name && displayAddress.address1 ? ", " : "",
4792
+ displayAddress.address1
4793
+ ]
4794
+ }), /* @__PURE__ */ jsx("span", {
4795
+ className: "text-muted-foreground text-sm",
4796
+ children: formatCityStateZip(displayAddress)
4797
+ })]
4798
+ }),
4799
+ isOpen && /* @__PURE__ */ jsx("div", {
4800
+ id: sectionId,
4801
+ className: "mt-5 flex max-h-[400px] flex-col space-y-4 overflow-y-auto pr-0.5",
4802
+ children: isLoading ? /* @__PURE__ */ jsx(Fragment$1, { children: [1, 2].map((i) => /* @__PURE__ */ jsxs("div", {
4803
+ className: "bg-muted rounded-sm p-3",
4804
+ children: [
4805
+ /* @__PURE__ */ jsx(Skeleton, { className: "mb-1 h-4 w-32" }),
4806
+ /* @__PURE__ */ jsx(Skeleton, { className: "mb-1 h-4 w-48" }),
4807
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-40" })
4808
+ ]
4809
+ }, `skeleton-${i}`)) }) : addressList.map((address) => {
4810
+ const isSelected = selectedAddressId === address.id;
4811
+ return /* @__PURE__ */ jsxs("button", {
4812
+ type: "button",
4813
+ "aria-pressed": isSelected,
4814
+ disabled: isPending,
4815
+ onClick: () => onSelectAddress(address),
4816
+ className: cn$1("text-foreground flex w-full flex-row items-center justify-between gap-3 rounded-sm p-3 text-left transition-colors", "not-disabled:cursor-pointer disabled:cursor-not-allowed disabled:opacity-60", isSelected ? "bg-background border-border border" : "bg-muted hover:bg-muted/80 border border-transparent"),
4817
+ children: [/* @__PURE__ */ jsxs("div", {
4818
+ className: "flex min-w-0 flex-col",
4819
+ children: [
4820
+ /* @__PURE__ */ jsx("span", {
4821
+ className: "text-foreground text-sm font-medium",
4822
+ children: address.name
4823
+ }),
4824
+ /* @__PURE__ */ jsx("span", {
4825
+ className: "text-muted-foreground text-sm",
4826
+ children: formatLine1(address)
4827
+ }),
4828
+ /* @__PURE__ */ jsx("span", {
4829
+ className: "text-muted-foreground text-sm",
4830
+ children: formatCityStateZip(address)
4831
+ })
4832
+ ]
4833
+ }), /* @__PURE__ */ jsxs("div", {
4834
+ className: "flex shrink-0 flex-row items-center gap-2",
4835
+ children: [address.default && /* @__PURE__ */ jsx("span", {
4836
+ className: "bg-primary text-primary-foreground rounded px-2 py-0.5 text-xs font-medium",
4837
+ children: "Default"
4838
+ }), (onEditAddress || onDeleteAddress || onMakeDefaultAddress) && /* @__PURE__ */ jsx("span", {
4839
+ onClick: (e) => e.stopPropagation(),
4840
+ onKeyDown: (e) => e.stopPropagation(),
4841
+ children: /* @__PURE__ */ jsx(EllipsesDropdown, {
4842
+ onEdit: onEditAddress ? () => onEditAddress(address) : void 0,
4843
+ onDelete: onDeleteAddress ? () => onDeleteAddress(address) : void 0,
4844
+ onMakeDefault: !address.default && onMakeDefaultAddress ? () => onMakeDefaultAddress(address) : void 0
4845
+ })
4846
+ })]
4847
+ })]
4848
+ }, address.id);
4849
+ })
4850
+ }),
4851
+ showAddButton && /* @__PURE__ */ jsx("button", {
4852
+ type: "button",
4853
+ disabled: isPending,
4854
+ className: "text-foreground mt-3 text-left text-sm disabled:cursor-not-allowed disabled:opacity-60",
4855
+ onClick: onAddAddressClick,
4856
+ children: addAddressLabel
4659
4857
  })
4660
- })]
4858
+ ]
4859
+ });
4860
+ }
4861
+ //#endregion
4862
+ //#region src/subscriptions/PortalSubscriptionShippingAddressSection.tsx
4863
+ const t = (key) => ({
4864
+ add_an_address: "Add an Address",
4865
+ add_address: "Add Address",
4866
+ edit_address: "Edit Address",
4867
+ delete_address: "Delete Address",
4868
+ delete_address_message: "Are you sure you want to delete this address? This action cannot be undone.",
4869
+ delete: "Delete",
4870
+ cancel: "Cancel",
4871
+ country: "Country",
4872
+ name: "Name",
4873
+ address_line_1: "Address Line 1",
4874
+ address_line_2: "Address Line 2",
4875
+ city: "City",
4876
+ state: "State",
4877
+ province: "Province",
4878
+ zip_code: "Zip Code",
4879
+ postal_code: "Postal Code",
4880
+ select_state: "Select state",
4881
+ select_an_option: "Select an option",
4882
+ set_as_default_address: "Set as default address",
4883
+ save_address: "Save Address"
4884
+ })[key] ?? key.split("_").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
4885
+ function composeAddressName(firstName, lastName) {
4886
+ const combined = `${firstName} ${lastName}`.trim();
4887
+ return combined.length > 0 ? combined : null;
4888
+ }
4889
+ function mapToFluidPayAddress(raw) {
4890
+ return {
4891
+ id: raw.id,
4892
+ address1: raw.street1,
4893
+ address2: raw.street2,
4894
+ city: raw.city,
4895
+ country_code: raw.country,
4896
+ default: raw.default,
4897
+ name: raw.name,
4898
+ postal_code: raw.zip,
4899
+ state: raw.state,
4900
+ subdivision_code: null
4901
+ };
4902
+ }
4903
+ function subscriptionAddressToFluidPay(raw) {
4904
+ if (!raw) return null;
4905
+ return {
4906
+ id: raw.id,
4907
+ address1: raw.address1,
4908
+ address2: raw.address2,
4909
+ city: raw.city,
4910
+ country_code: raw.country_code,
4911
+ default: raw.default,
4912
+ name: raw.name,
4913
+ postal_code: raw.postal_code,
4914
+ state: raw.state,
4915
+ subdivision_code: raw.subdivision_code
4916
+ };
4917
+ }
4918
+ function PortalSubscriptionShippingAddressSection({ address: currentAddress, subscriptionToken, onSuccess, onError }) {
4919
+ const payApi = usePayApi();
4920
+ const queryClient = useQueryClient();
4921
+ const fluidPayShim = useMemo(() => createFluidPayApiAdapter(payApi), [payApi]);
4922
+ const [isFormDialogOpen, setIsFormDialogOpen] = useState(false);
4923
+ const [editingAddress, setEditingAddress] = useState(null);
4924
+ const [deletingAddress, setDeletingAddress] = useState(null);
4925
+ const [deleteError, setDeleteError] = useState(void 0);
4926
+ const { data: addresses = [], isLoading } = useQuery({
4927
+ queryKey: payKeys.addresses.list(),
4928
+ queryFn: async () => {
4929
+ return (await payApi.fetchAddresses()).addresses.map(mapToFluidPayAddress);
4930
+ }
4931
+ });
4932
+ const countriesApi = useCountriesApi();
4933
+ const { data: countriesData } = useQuery({
4934
+ queryKey: storeKeys.countries(),
4935
+ queryFn: () => countriesApi.listCountries(),
4936
+ enabled: isFormDialogOpen
4937
+ });
4938
+ const countryOptions = useMemo(() => [...countriesData?.countries ?? []].map((c) => ({
4939
+ iso: c.code,
4940
+ name: c.name
4941
+ })).sort((a, b) => a.name.localeCompare(b.name)), [countriesData]);
4942
+ const statesByCountry = useMemo(() => {
4943
+ const map = /* @__PURE__ */ new Map();
4944
+ for (const c of countriesData?.countries ?? []) map.set(c.code, c.states.map((s) => ({
4945
+ name: s.name,
4946
+ isoCode: s.code
4947
+ })));
4948
+ return map;
4949
+ }, [countriesData]);
4950
+ const fetchStatesFromCountries = useCallback((countryCode) => Promise.resolve(statesByCountry.get(countryCode) ?? []), [statesByCountry]);
4951
+ const updateSubscription = useUpdateSubscriptionInfo({
4952
+ onSuccess: () => {
4953
+ onSuccess?.("Shipping address updated");
4954
+ queryClient.invalidateQueries({ queryKey: subscriptionsKeys.detail(subscriptionToken) });
4955
+ },
4956
+ onError: (err) => onError?.("Failed to update shipping address", err)
4957
+ });
4958
+ const createAddressMutation = useMutation({
4959
+ mutationFn: (body) => payApi.createAddress({ address: {
4960
+ name: composeAddressName(body.address.first_name, body.address.last_name),
4961
+ street1: body.address.address1,
4962
+ street2: body.address.address2,
4963
+ city: body.address.city,
4964
+ state: body.address.state,
4965
+ zip: body.address.postal_code,
4966
+ country: body.address.country_code,
4967
+ default: body.address.default
4968
+ } }),
4969
+ onSuccess: () => {
4970
+ queryClient.invalidateQueries({ queryKey: payKeys.addresses.all });
4971
+ onSuccess?.("Address added");
4972
+ },
4973
+ onError: (err) => onError?.("Failed to add address", err)
4974
+ });
4975
+ const updateAddressMutation = useMutation({
4976
+ mutationFn: ({ addressId, body }) => payApi.updateAddress(addressId, { address: {
4977
+ name: composeAddressName(body.address.first_name, body.address.last_name),
4978
+ street1: body.address.address1,
4979
+ street2: body.address.address2,
4980
+ city: body.address.city,
4981
+ state: body.address.state,
4982
+ zip: body.address.postal_code,
4983
+ country: body.address.country_code,
4984
+ default: body.address.default
4985
+ } }),
4986
+ onSuccess: () => {
4987
+ queryClient.invalidateQueries({ queryKey: payKeys.addresses.all });
4988
+ onSuccess?.("Address updated");
4989
+ },
4990
+ onError: (err) => onError?.("Failed to update address", err)
4991
+ });
4992
+ const deleteAddressMutation = useMutation({
4993
+ mutationFn: (addressId) => payApi.deleteAddress(addressId),
4994
+ onSuccess: () => {
4995
+ queryClient.invalidateQueries({ queryKey: payKeys.addresses.all });
4996
+ onSuccess?.("Address deleted");
4997
+ }
4998
+ });
4999
+ const makeDefaultAddressMutation = useMutation({
5000
+ mutationFn: (address) => payApi.updateAddress(address.id, { address: {
5001
+ name: address.name ?? null,
5002
+ street1: address.address1 ?? "",
5003
+ street2: address.address2,
5004
+ city: address.city ?? "",
5005
+ state: address.state ?? "",
5006
+ zip: address.postal_code ?? "",
5007
+ country: address.country_code ?? "",
5008
+ default: true
5009
+ } }),
5010
+ onSuccess: () => {
5011
+ queryClient.invalidateQueries({ queryKey: payKeys.addresses.all });
5012
+ onSuccess?.("Default address updated");
5013
+ },
5014
+ onError: (err) => onError?.("Failed to update default address", err)
5015
+ });
5016
+ const displayed = addresses.find((a) => a.id === currentAddress?.id) ?? subscriptionAddressToFluidPay(currentAddress);
5017
+ const handleCloseFormDialog = () => {
5018
+ setIsFormDialogOpen(false);
5019
+ setEditingAddress(null);
5020
+ };
5021
+ const handleConfirmDelete = async () => {
5022
+ if (!deletingAddress) return;
5023
+ setDeleteError(void 0);
5024
+ try {
5025
+ await deleteAddressMutation.mutateAsync(deletingAddress.id);
5026
+ setDeletingAddress(null);
5027
+ } catch (err) {
5028
+ setDeleteError(err instanceof Error ? err.message : "We were unable to delete this address. Please try again.");
5029
+ }
5030
+ };
5031
+ return /* @__PURE__ */ jsx(FluidPayCoreProvider, {
5032
+ api: fluidPayShim,
5033
+ children: /* @__PURE__ */ jsxs(ProfileUIProvider, {
5034
+ t,
5035
+ children: [
5036
+ /* @__PURE__ */ jsx(SelectableAddressDropdown, {
5037
+ title: "Shipping Address",
5038
+ displayAddress: displayed,
5039
+ addressList: addresses,
5040
+ selectedAddressId: currentAddress?.id ?? 0,
5041
+ onSelectAddress: (addr) => {
5042
+ if (addr.id === currentAddress?.id) return;
5043
+ updateSubscription.mutate({
5044
+ subscriptionToken,
5045
+ body: { address_id: addr.id }
5046
+ });
5047
+ },
5048
+ onAddAddressClick: () => {
5049
+ setEditingAddress(null);
5050
+ setIsFormDialogOpen(true);
5051
+ },
5052
+ onEditAddress: (addr) => {
5053
+ setEditingAddress(addr);
5054
+ setIsFormDialogOpen(true);
5055
+ },
5056
+ onDeleteAddress: (addr) => {
5057
+ setDeleteError(void 0);
5058
+ setDeletingAddress(addr);
5059
+ },
5060
+ onMakeDefaultAddress: (addr) => makeDefaultAddressMutation.mutate(addr),
5061
+ addAddressLabel: "+ Add an address",
5062
+ showAddButton: true,
5063
+ isLoading,
5064
+ isPending: updateSubscription.isPending || createAddressMutation.isPending || updateAddressMutation.isPending || makeDefaultAddressMutation.isPending
5065
+ }),
5066
+ /* @__PURE__ */ jsx(AddressFormDialog, {
5067
+ isOpen: isFormDialogOpen,
5068
+ onClose: handleCloseFormDialog,
5069
+ selectedAddress: editingAddress,
5070
+ t,
5071
+ onSubmit: async (data) => {
5072
+ try {
5073
+ if (editingAddress) await updateAddressMutation.mutateAsync({
5074
+ addressId: editingAddress.id,
5075
+ body: data
5076
+ });
5077
+ else await createAddressMutation.mutateAsync(data);
5078
+ handleCloseFormDialog();
5079
+ } catch {}
5080
+ },
5081
+ isSubmitting: createAddressMutation.isPending || updateAddressMutation.isPending,
5082
+ countries: countryOptions,
5083
+ fetchStates: fetchStatesFromCountries,
5084
+ renderAddressAutocomplete: ({ control, setValue, countryCode }) => /* @__PURE__ */ jsx(AddressAutocompleteInput, {
5085
+ control,
5086
+ setValue,
5087
+ countryIso: countryCode,
5088
+ addressLineField: "address1",
5089
+ cityField: "city",
5090
+ stateField: "state",
5091
+ postalCodeField: "postal_code",
5092
+ placeholder: t("address_line_1")
5093
+ })
5094
+ }),
5095
+ /* @__PURE__ */ jsx(ConfirmActionDialog, {
5096
+ title: t("delete_address"),
5097
+ description: t("delete_address_message"),
5098
+ actionText: t("delete"),
5099
+ openDialog: deletingAddress !== null,
5100
+ setOpenDialog: (open) => {
5101
+ if (!open) {
5102
+ setDeletingAddress(null);
5103
+ setDeleteError(void 0);
5104
+ }
5105
+ },
5106
+ onAction: handleConfirmDelete,
5107
+ errorMsg: deleteError,
5108
+ isLoading: deleteAddressMutation.isPending
5109
+ })
5110
+ ]
5111
+ })
4661
5112
  });
4662
5113
  }
4663
5114
  //#endregion
@@ -4687,6 +5138,13 @@ function SubscriptionDetailScreen({ token, onToast }) {
4687
5138
  onError: (message, err) => {
4688
5139
  onToast(`${message}: ${err instanceof Error ? err.message : "An error occurred"}`, "error");
4689
5140
  }
5141
+ }),
5142
+ renderShippingAddress: (ctx) => /* @__PURE__ */ jsx(PortalSubscriptionShippingAddressSection, {
5143
+ ...ctx,
5144
+ onSuccess: (message) => onToast(message, "success"),
5145
+ onError: (message, err) => {
5146
+ onToast(`${message}: ${err instanceof Error ? err.message : "An error occurred"}`, "error");
5147
+ }
4690
5148
  })
4691
5149
  });
4692
5150
  }
@@ -4737,4 +5195,4 @@ const subscriptionsScreenPropertySchema = {
4737
5195
  //#endregion
4738
5196
  export { SubscriptionsScreen_exports as n, subscriptionsScreenPropertySchema as r, SubscriptionsScreen as t };
4739
5197
 
4740
- //# sourceMappingURL=SubscriptionsScreen-Y4UgpC1Y.mjs.map
5198
+ //# sourceMappingURL=SubscriptionsScreen-CsNE6gik.mjs.map