@fluid-app/portal-sdk 0.1.93 → 0.1.95

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 (84) hide show
  1. package/dist/{ContactsScreen-0h6EW-5L.cjs → ContactsScreen-BELhEJNe.cjs} +406 -426
  2. package/dist/ContactsScreen-BELhEJNe.cjs.map +1 -0
  3. package/dist/{ContactsScreen-CCvizFdr.cjs → ContactsScreen-DuTrcBkd.cjs} +4 -4
  4. package/dist/{ContactsScreen-B5mf_3YF.mjs → ContactsScreen-hJYLdIT9.mjs} +407 -427
  5. package/dist/ContactsScreen-hJYLdIT9.mjs.map +1 -0
  6. package/dist/{MessagingScreen-8myurYB8.cjs → MessagingScreen-2a1oJ9yj.cjs} +3 -3
  7. package/dist/{MessagingScreen-oGxMJtNT.mjs → MessagingScreen-B9V9dTBn.mjs} +3 -3
  8. package/dist/{MessagingScreen-CJO9b5Do.mjs → MessagingScreen-CcPPK1J6.mjs} +3 -3
  9. package/dist/{MessagingScreen-CJO9b5Do.mjs.map → MessagingScreen-CcPPK1J6.mjs.map} +1 -1
  10. package/dist/{MessagingScreen-B8u8kkH-.cjs → MessagingScreen-dJZWI4fa.cjs} +3 -3
  11. package/dist/{MessagingScreen-B8u8kkH-.cjs.map → MessagingScreen-dJZWI4fa.cjs.map} +1 -1
  12. package/dist/{OrdersScreen-DDqDubNG.cjs → OrdersScreen-DRp79-k9.cjs} +2 -2
  13. package/dist/{OrdersScreen-CRhvTsZX.mjs → OrdersScreen-hzKwBSYF.mjs} +8 -8
  14. package/dist/OrdersScreen-hzKwBSYF.mjs.map +1 -0
  15. package/dist/{OrdersScreen-DGWU9MKQ.cjs → OrdersScreen-k0x7wLRV.cjs} +8 -8
  16. package/dist/OrdersScreen-k0x7wLRV.cjs.map +1 -0
  17. package/dist/{ProductsScreen-CUQi-Rj5.mjs → ProductsScreen-B54KA40V.mjs} +3 -3
  18. package/dist/{ProductsScreen-CUQi-Rj5.mjs.map → ProductsScreen-B54KA40V.mjs.map} +1 -1
  19. package/dist/{ProductsScreen-28vbEj_q.mjs → ProductsScreen-BLHW3MHq.mjs} +5 -5
  20. package/dist/{ProductsScreen-TQGuItSe.cjs → ProductsScreen-BxNldFw6.cjs} +3 -3
  21. package/dist/{ProductsScreen-TQGuItSe.cjs.map → ProductsScreen-BxNldFw6.cjs.map} +1 -1
  22. package/dist/{ProductsScreen-BCKYCxLP.cjs → ProductsScreen-hdAragYJ.cjs} +5 -5
  23. package/dist/{ProfileScreen-CSyji2kX.mjs → ProfileScreen-Btqo-rsk.mjs} +2 -2
  24. package/dist/{ProfileScreen-CSyji2kX.mjs.map → ProfileScreen-Btqo-rsk.mjs.map} +1 -1
  25. package/dist/{ProfileScreen-C-WEgl6I.cjs → ProfileScreen-DRLPIEQT.cjs} +2 -2
  26. package/dist/{ProfileScreen-C-WEgl6I.cjs.map → ProfileScreen-DRLPIEQT.cjs.map} +1 -1
  27. package/dist/{ProfileScreen-mbsYsvbX.cjs → ProfileScreen-DtDAJ45D.cjs} +1 -1
  28. package/dist/{ShareablesScreen-DDDnyfpn.cjs → ShareablesScreen-DrAZ49Iv.cjs} +3 -3
  29. package/dist/{ShareablesScreen-DDDnyfpn.cjs.map → ShareablesScreen-DrAZ49Iv.cjs.map} +1 -1
  30. package/dist/{ShareablesScreen-Du70lYZA.cjs → ShareablesScreen-EJidIq4N.cjs} +5 -5
  31. package/dist/{ShareablesScreen-B3LWG6Vd.mjs → ShareablesScreen-UBSyLEbL.mjs} +3 -3
  32. package/dist/{ShareablesScreen-B3LWG6Vd.mjs.map → ShareablesScreen-UBSyLEbL.mjs.map} +1 -1
  33. package/dist/{ShareablesScreen-DWlRD2yD.mjs → ShareablesScreen-mJR5_fnx.mjs} +5 -5
  34. package/dist/{ShopScreen-DQzt93BK.cjs → ShopScreen-B-9Qito4.cjs} +1 -1
  35. package/dist/{ShopScreen-CWuSRymK.cjs → ShopScreen-BUri9nlR.cjs} +2 -2
  36. package/dist/{ShopScreen-CWuSRymK.cjs.map → ShopScreen-BUri9nlR.cjs.map} +1 -1
  37. package/dist/{ShopScreen-CzY8rJg9.mjs → ShopScreen-Dr44ppZ7.mjs} +2 -2
  38. package/dist/{ShopScreen-CzY8rJg9.mjs.map → ShopScreen-Dr44ppZ7.mjs.map} +1 -1
  39. package/dist/{SubscriptionsScreen-CjxanPLb.cjs → SubscriptionsScreen-BMMKqvmT.cjs} +4 -4
  40. package/dist/{SubscriptionsScreen-CjxanPLb.cjs.map → SubscriptionsScreen-BMMKqvmT.cjs.map} +1 -1
  41. package/dist/{SubscriptionsScreen-Dc4JwfWg.cjs → SubscriptionsScreen-Bi0KJRf9.cjs} +2 -2
  42. package/dist/{SubscriptionsScreen-CViYObw9.mjs → SubscriptionsScreen-DymuNO2u.mjs} +4 -4
  43. package/dist/{SubscriptionsScreen-CViYObw9.mjs.map → SubscriptionsScreen-DymuNO2u.mjs.map} +1 -1
  44. package/dist/{dist-C9vpl_rR.mjs → dist-B1HwSrso.mjs} +2 -2
  45. package/dist/{dist-C9vpl_rR.mjs.map → dist-B1HwSrso.mjs.map} +1 -1
  46. package/dist/{dist-thaj08s5.cjs → dist-BbS_7TvS.cjs} +1 -1
  47. package/dist/{dist-thaj08s5.cjs.map → dist-BbS_7TvS.cjs.map} +1 -1
  48. package/dist/{dist-CkIGP8my.mjs → dist-CMGXkSgZ.mjs} +1 -1
  49. package/dist/{dist-CkIGP8my.mjs.map → dist-CMGXkSgZ.mjs.map} +1 -1
  50. package/dist/{dist-BK4mvUPm.cjs → dist-DkYXiQQ1.cjs} +2 -2
  51. package/dist/{dist-BK4mvUPm.cjs.map → dist-DkYXiQQ1.cjs.map} +1 -1
  52. package/dist/{es-Dlib2eNY.mjs → es-1KItbbYg.mjs} +1 -1
  53. package/dist/{es-Dlib2eNY.mjs.map → es-1KItbbYg.mjs.map} +1 -1
  54. package/dist/{es-xQF-WIMq.cjs → es-BSkb3AZk.cjs} +1 -1
  55. package/dist/{es-xQF-WIMq.cjs.map → es-BSkb3AZk.cjs.map} +1 -1
  56. package/dist/index.cjs +30 -30
  57. package/dist/index.d.cts.map +1 -1
  58. package/dist/index.d.mts.map +1 -1
  59. package/dist/index.mjs +30 -30
  60. package/dist/{order-detail-06VbWJjw.cjs → order-detail-9-MS70Zm.cjs} +14 -46
  61. package/dist/order-detail-9-MS70Zm.cjs.map +1 -0
  62. package/dist/{order-detail-B5X_QRpi.mjs → order-detail-CYkWN7-L.mjs} +14 -46
  63. package/dist/order-detail-CYkWN7-L.mjs.map +1 -0
  64. package/dist/{src-CyrJPIY1.mjs → src-C7RYt83r.mjs} +4 -4
  65. package/dist/{src-CyrJPIY1.mjs.map → src-C7RYt83r.mjs.map} +1 -1
  66. package/dist/{src-t3t8YW1J.cjs → src-DdIO0lIo.cjs} +4 -4
  67. package/dist/{src-t3t8YW1J.cjs.map → src-DdIO0lIo.cjs.map} +1 -1
  68. package/dist/{use-account-clients-CaLsedpw.mjs → use-account-clients-0kFq_8i7.mjs} +46 -8
  69. package/dist/use-account-clients-0kFq_8i7.mjs.map +1 -0
  70. package/dist/{use-account-clients-CF79cijO.cjs → use-account-clients-CFfdmi36.cjs} +47 -9
  71. package/dist/use-account-clients-CFfdmi36.cjs.map +1 -0
  72. package/dist/{use-customer-account-9HqKnQx5.cjs → use-customer-account-BH-hwjbg.cjs} +2 -2
  73. package/dist/{use-customer-account-9HqKnQx5.cjs.map → use-customer-account-BH-hwjbg.cjs.map} +1 -1
  74. package/dist/{use-customer-account-CewcODTd.mjs → use-customer-account-Be70QBp3.mjs} +2 -2
  75. package/dist/{use-customer-account-CewcODTd.mjs.map → use-customer-account-Be70QBp3.mjs.map} +1 -1
  76. package/package.json +8 -7
  77. package/dist/ContactsScreen-0h6EW-5L.cjs.map +0 -1
  78. package/dist/ContactsScreen-B5mf_3YF.mjs.map +0 -1
  79. package/dist/OrdersScreen-CRhvTsZX.mjs.map +0 -1
  80. package/dist/OrdersScreen-DGWU9MKQ.cjs.map +0 -1
  81. package/dist/order-detail-06VbWJjw.cjs.map +0 -1
  82. package/dist/order-detail-B5X_QRpi.mjs.map +0 -1
  83. package/dist/use-account-clients-CF79cijO.cjs.map +0 -1
  84. package/dist/use-account-clients-CaLsedpw.mjs.map +0 -1
@@ -3,9 +3,9 @@ const require_FluidProvider = require("./FluidProvider-C27-ijsq.cjs");
3
3
  const require_parse_api_errors = require("./parse-api-errors-CAnpE2_r.cjs");
4
4
  const require_src = require("./src-DGjAAfmN.cjs");
5
5
  const require_ScreenHeaderContext = require("./ScreenHeaderContext-wrJlkhgN.cjs");
6
- const require_order_detail = require("./order-detail-06VbWJjw.cjs");
7
- const require_dist = require("./dist-thaj08s5.cjs");
8
- const require_dist$1 = require("./dist-BK4mvUPm.cjs");
6
+ const require_dist = require("./dist-BbS_7TvS.cjs");
7
+ const require_order_detail = require("./order-detail-9-MS70Zm.cjs");
8
+ const require_dist$1 = require("./dist-DkYXiQQ1.cjs");
9
9
  let react = require("react");
10
10
  react = require_chunk.__toESM(react);
11
11
  let _tanstack_react_query = require("@tanstack/react-query");
@@ -718,7 +718,7 @@ function ContactsTable({ listContacts, queryKeyPrefix, setSelectedContacts, setO
718
718
  });
719
719
  }
720
720
  //#endregion
721
- //#region ../../contacts/ui/src/shared/query-keys.ts
721
+ //#region ../../contacts/core/src/query-keys.ts
722
722
  const CONTACTS_QUERY_KEYS = {
723
723
  all: (prefix) => [prefix],
724
724
  list: (prefix) => [...CONTACTS_QUERY_KEYS.all(prefix), "list"],
@@ -728,6 +728,33 @@ const CONTACTS_QUERY_KEYS = {
728
728
  id
729
729
  ]
730
730
  };
731
+ const contactsKeys = {
732
+ activities: (contactId) => [
733
+ "portal-contacts",
734
+ "activities",
735
+ contactId
736
+ ],
737
+ tasks: (contactId) => [
738
+ "portal-contacts",
739
+ "tasks",
740
+ contactId
741
+ ],
742
+ notes: (contactId) => [
743
+ "portal-contacts",
744
+ "notes",
745
+ contactId
746
+ ],
747
+ orders: (contactId) => [
748
+ "rep-contacts",
749
+ "orders",
750
+ contactId
751
+ ],
752
+ subscriptionOrders: (contactId) => [
753
+ "rep-contacts",
754
+ "subscription-orders",
755
+ contactId
756
+ ]
757
+ };
731
758
  //#endregion
732
759
  //#region ../../contacts/ui/src/shared/components/contacts/allContacts/contactsPage.tsx
733
760
  function ContactsPage({ listContacts, deleteContacts, queryKeyPrefix, header, onEditContact, onRowClick, tableLayout }) {
@@ -1457,204 +1484,36 @@ function NotesSidebar({ notes, isLoading, onNavigateToNotes }) {
1457
1484
  });
1458
1485
  }
1459
1486
  //#endregion
1460
- //#region ../../notes/fluid-user-notes-api-client/src/namespaces/users_notes.ts
1461
- /**
1462
- * Delete a note
1463
- *
1464
- *
1465
- * @param client - Fetch client instance
1466
- * @param id - id
1467
- * @param params - params
1468
- */
1469
- async function deleteUserNote(client, id, params) {
1470
- return client.delete(`/api/users/v2025-06/notes/${id}`, { params });
1471
- }
1472
- /**
1473
- * Update a note
1474
- *
1475
- *
1476
- * @param client - Fetch client instance
1477
- * @param id - id
1478
- * @param body - body
1479
- */
1480
- async function updateUserNote(client, id, body) {
1481
- return client.patch(`/api/users/v2025-06/notes/${id}`, body);
1482
- }
1483
- //#endregion
1484
- //#region ../../contacts/fluid-user-contacts-api-client/src/namespaces/users_contacts.ts
1485
- /**
1486
- * List activities for a contact
1487
- *
1488
- *
1489
- * @param client - Fetch client instance
1490
- * @param id - id
1491
- * @param params? - params?
1492
- */
1493
- async function listUserContactActivities(client, id, params) {
1494
- return client.get(`/api/users/v2025-06/contacts/${id}/activities`, params);
1495
- }
1496
- /**
1497
- * Bulk delete contacts
1498
- *
1499
- *
1500
- * @param client - Fetch client instance
1501
- * @param body - body
1502
- */
1503
- async function bulkDeleteUserContacts(client, body) {
1504
- return client.delete(`/api/users/v2025-06/contacts/bulk_delete`, { body });
1505
- }
1506
- /**
1507
- * Create a contact
1508
- *
1509
- *
1510
- * @param client - Fetch client instance
1511
- * @param body - body
1512
- */
1513
- async function createUserContact(client, body) {
1514
- return client.post(`/api/users/v2025-06/contacts`, body);
1515
- }
1516
- /**
1517
- * List user's contacts
1518
- *
1519
- *
1520
- * @param client - Fetch client instance
1521
- * @param params? - params?
1522
- */
1523
- async function listUserContacts(client, params) {
1524
- return client.get(`/api/users/v2025-06/contacts`, params);
1525
- }
1526
- /**
1527
- * Delete a contact
1528
- *
1529
- *
1530
- * @param client - Fetch client instance
1531
- * @param id - id
1532
- */
1533
- async function deleteUserContact(client, id) {
1534
- return client.delete(`/api/users/v2025-06/contacts/${id}`);
1535
- }
1536
- /**
1537
- * Get a contact
1538
- *
1539
- *
1540
- * @param client - Fetch client instance
1541
- * @param id - id
1542
- */
1543
- async function getUserContact(client, id) {
1544
- return client.get(`/api/users/v2025-06/contacts/${id}`);
1545
- }
1546
- /**
1547
- * Update a contact
1548
- *
1549
- *
1550
- * @param client - Fetch client instance
1551
- * @param id - id
1552
- * @param body - body
1553
- */
1554
- async function updateUserContact(client, id, body) {
1555
- return client.patch(`/api/users/v2025-06/contacts/${id}`, body);
1556
- }
1557
- /**
1558
- * Create a note for a contact (deprecated)
1559
- *
1560
- *
1561
- * @param client - Fetch client instance
1562
- * @param id - id
1563
- * @param body - body
1564
- */
1565
- async function createUserContactNote(client, id, body) {
1566
- return client.post(`/api/users/v2025-06/contacts/${id}/notes`, body);
1567
- }
1568
- /**
1569
- * List notes for a contact
1570
- *
1571
- *
1572
- * @param client - Fetch client instance
1573
- * @param id - id
1574
- */
1575
- async function listUserContactNotes(client, id) {
1576
- return client.get(`/api/users/v2025-06/contacts/${id}/notes`);
1577
- }
1578
- /**
1579
- * List orders for a contact
1580
- *
1581
- *
1582
- * @param client - Fetch client instance
1583
- * @param id - id
1584
- * @param params? - params?
1585
- */
1586
- async function listUserContactOrders(client, id, params) {
1587
- return client.get(`/api/users/v2025-06/contacts/${id}/orders`, params);
1588
- }
1589
- /**
1590
- * Mark contact's activities as read
1591
- *
1592
- *
1593
- * @param client - Fetch client instance
1594
- * @param id - id
1595
- */
1596
- async function markUserContactRead(client, id) {
1597
- return client.post(`/api/users/v2025-06/contacts/${id}/read`);
1598
- }
1599
- /**
1600
- * List subscription orders for a contact
1601
- *
1602
- *
1603
- * @param client - Fetch client instance
1604
- * @param id - id
1605
- * @param params? - params?
1606
- */
1607
- async function listUserContactSubscriptionOrders(client, id, params) {
1608
- return client.get(`/api/users/v2025-06/contacts/${id}/subscription_orders`, params);
1487
+ //#region ../../contacts/core/src/contacts-api-context.ts
1488
+ const ContactsApiContext = (0, react.createContext)(null);
1489
+ const ContactsApiProvider = ContactsApiContext.Provider;
1490
+ function useContactsDomainApi() {
1491
+ const api = (0, react.useContext)(ContactsApiContext);
1492
+ if (!api) throw new Error("useContactsDomainApi must be used within a ContactsApiProvider");
1493
+ return api;
1609
1494
  }
1610
- /**
1611
- * Create a task for a contact
1612
- *
1613
- *
1614
- * @param client - Fetch client instance
1615
- * @param id - id
1616
- * @param body - body
1617
- */
1618
- async function createUserContactTask(client, id, body) {
1619
- return client.post(`/api/users/v2025-06/contacts/${id}/tasks`, body);
1495
+ function useContactsCrud() {
1496
+ return useContactsDomainApi().contacts;
1620
1497
  }
1621
- /**
1622
- * List tasks for a contact
1623
- *
1624
- *
1625
- * @param client - Fetch client instance
1626
- * @param id - id
1627
- */
1628
- async function listUserContactTasks(client, id) {
1629
- return client.get(`/api/users/v2025-06/contacts/${id}/tasks`);
1498
+ function useNotesApi() {
1499
+ return useContactsDomainApi().notes;
1630
1500
  }
1631
- //#endregion
1632
- //#region ../../contacts/ui/src/portal/hooks/notes/use-contact-notes.ts
1633
- const CONTACT_NOTES_QUERY_KEY = (contactId) => [
1634
- "portal-contacts",
1635
- "notes",
1636
- contactId
1637
- ];
1638
- function useContactNotes(client, contactId) {
1639
- return (0, _tanstack_react_query.useQuery)({
1640
- queryKey: CONTACT_NOTES_QUERY_KEY(contactId),
1641
- queryFn: () => listUserContactNotes(client, contactId),
1642
- enabled: !!contactId,
1643
- select: (data) => data.notes
1644
- });
1501
+ function useTasksApi() {
1502
+ return useContactsDomainApi().tasks;
1645
1503
  }
1646
1504
  //#endregion
1647
1505
  //#region ../../contacts/ui/src/portal/hooks/notes/use-delete-contact-note.ts
1648
- function useDeleteContactNote(client, contactId, options) {
1506
+ function useDeleteContactNote(contactId, options) {
1649
1507
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
1508
+ const api = useNotesApi();
1650
1509
  return (0, _tanstack_react_query.useMutation)({
1651
- mutationFn: (noteId) => deleteUserNote(client, noteId, { contact_id: Number(contactId) }),
1510
+ mutationFn: (noteId) => api.deleteNote(noteId, contactId),
1652
1511
  onSuccess: () => {
1653
1512
  require_src.fluidToast({
1654
1513
  title: "Note deleted",
1655
1514
  type: "success"
1656
1515
  });
1657
- queryClient.invalidateQueries({ queryKey: CONTACT_NOTES_QUERY_KEY(contactId) });
1516
+ queryClient.invalidateQueries({ queryKey: contactsKeys.notes(contactId) });
1658
1517
  options?.onSuccess?.();
1659
1518
  },
1660
1519
  onError: (error) => {
@@ -1668,19 +1527,17 @@ function useDeleteContactNote(client, contactId, options) {
1668
1527
  }
1669
1528
  //#endregion
1670
1529
  //#region ../../contacts/ui/src/portal/hooks/notes/use-create-contact-note.ts
1671
- function useCreateContactNote(client, contactId, options) {
1530
+ function useCreateContactNote(contactId, options) {
1672
1531
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
1532
+ const api = useNotesApi();
1673
1533
  return (0, _tanstack_react_query.useMutation)({
1674
- mutationFn: (input) => createUserContactNote(client, contactId, {
1675
- id: Number(contactId),
1676
- note: input
1677
- }),
1534
+ mutationFn: (input) => api.createNote(contactId, input),
1678
1535
  onSuccess: () => {
1679
1536
  require_src.fluidToast({
1680
1537
  title: "Note created",
1681
1538
  type: "success"
1682
1539
  });
1683
- queryClient.invalidateQueries({ queryKey: CONTACT_NOTES_QUERY_KEY(contactId) });
1540
+ queryClient.invalidateQueries({ queryKey: contactsKeys.notes(contactId) });
1684
1541
  options?.onSuccess?.();
1685
1542
  },
1686
1543
  onError: (error) => {
@@ -1694,20 +1551,17 @@ function useCreateContactNote(client, contactId, options) {
1694
1551
  }
1695
1552
  //#endregion
1696
1553
  //#region ../../contacts/ui/src/portal/hooks/notes/use-update-contact-note.ts
1697
- function useUpdateContactNote(client, contactId, options) {
1554
+ function useUpdateContactNote(contactId, options) {
1698
1555
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
1556
+ const api = useNotesApi();
1699
1557
  return (0, _tanstack_react_query.useMutation)({
1700
- mutationFn: ({ noteId, input }) => updateUserNote(client, noteId, {
1701
- contact_id: Number(contactId),
1702
- id: noteId,
1703
- note: input
1704
- }),
1558
+ mutationFn: ({ noteId, input }) => api.updateNote(noteId, contactId, input),
1705
1559
  onSuccess: () => {
1706
1560
  require_src.fluidToast({
1707
1561
  title: "Note updated",
1708
1562
  type: "success"
1709
1563
  });
1710
- queryClient.invalidateQueries({ queryKey: CONTACT_NOTES_QUERY_KEY(contactId) });
1564
+ queryClient.invalidateQueries({ queryKey: contactsKeys.notes(contactId) });
1711
1565
  options?.onSuccess?.();
1712
1566
  },
1713
1567
  onError: (error) => {
@@ -2223,14 +2077,13 @@ function NoteCard({ note, onEdit, onDelete }) {
2223
2077
  ]
2224
2078
  });
2225
2079
  }
2226
- function NotesList({ notes, isLoading, contactId, client, notesClient, ref }) {
2080
+ function NotesList({ notes, isLoading, contactId, ref }) {
2227
2081
  const [noteToDelete, setNoteToDelete] = (0, react.useState)(null);
2228
2082
  const [modalOpen, setModalOpen] = (0, react.useState)(false);
2229
2083
  const [editingNote, setEditingNote] = (0, react.useState)(null);
2230
- const effectiveClient = notesClient ?? client;
2231
- const deleteNote = useDeleteContactNote(effectiveClient, contactId);
2232
- const createNote = useCreateContactNote(effectiveClient, contactId, { onSuccess: () => setModalOpen(false) });
2233
- const updateNote = useUpdateContactNote(effectiveClient, contactId, { onSuccess: () => setEditingNote(null) });
2084
+ const deleteNote = useDeleteContactNote(contactId);
2085
+ const createNote = useCreateContactNote(contactId, { onSuccess: () => setModalOpen(false) });
2086
+ const updateNote = useUpdateContactNote(contactId, { onSuccess: () => setEditingNote(null) });
2234
2087
  const openCreateModal = () => {
2235
2088
  setEditingNote(null);
2236
2089
  setModalOpen(true);
@@ -2652,54 +2505,14 @@ function ActivityFeed({ activities, isLoading, onMarkRead }) {
2652
2505
  });
2653
2506
  }
2654
2507
  //#endregion
2655
- //#region ../../tasks/fluid-user-tasks-api-client/src/namespaces/users_tasks.ts
2656
- /**
2657
- * Delete a task
2658
- *
2659
- *
2660
- * @param client - Fetch client instance
2661
- * @param id - id
2662
- */
2663
- async function deleteUserTask(client, id) {
2664
- return client.delete(`/api/users/v2025-06/tasks/${id}`);
2665
- }
2666
- /**
2667
- * Update a task
2668
- *
2669
- *
2670
- * @param client - Fetch client instance
2671
- * @param id - id
2672
- * @param body - body
2673
- */
2674
- async function updateUserTask(client, id, body) {
2675
- return client.patch(`/api/users/v2025-06/tasks/${id}`, body);
2676
- }
2677
- //#endregion
2678
- //#region ../../contacts/ui/src/portal/hooks/contacts/use-contact-tasks.ts
2679
- const CONTACT_TASKS_QUERY_KEY = (contactId) => [
2680
- "portal-contacts",
2681
- "tasks",
2682
- contactId
2683
- ];
2684
- function useContactTasks(client, contactId) {
2685
- return (0, _tanstack_react_query.useQuery)({
2686
- queryKey: CONTACT_TASKS_QUERY_KEY(contactId),
2687
- queryFn: () => listUserContactTasks(client, contactId),
2688
- enabled: !!contactId,
2689
- select: (data) => data.tasks
2690
- });
2691
- }
2692
- //#endregion
2693
2508
  //#region ../../contacts/ui/src/portal/hooks/contacts/use-toggle-task-completion.ts
2694
- function useToggleTaskCompletion(client, contactId) {
2509
+ function useToggleTaskCompletion(contactId) {
2695
2510
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
2511
+ const api = useTasksApi();
2696
2512
  return (0, _tanstack_react_query.useMutation)({
2697
- mutationFn: ({ taskId, isCompleted }) => updateUserTask(client, taskId, {
2698
- id: taskId,
2699
- task: { completed_at: isCompleted ? null : (/* @__PURE__ */ new Date()).toISOString() }
2700
- }),
2513
+ mutationFn: ({ taskId, isCompleted }) => api.updateTask(taskId, { completed_at: isCompleted ? null : (/* @__PURE__ */ new Date()).toISOString() }),
2701
2514
  onSuccess: () => {
2702
- queryClient.invalidateQueries({ queryKey: CONTACT_TASKS_QUERY_KEY(contactId) });
2515
+ queryClient.invalidateQueries({ queryKey: contactsKeys.tasks(contactId) });
2703
2516
  },
2704
2517
  onError: (error) => {
2705
2518
  require_src.fluidToast({
@@ -2712,16 +2525,17 @@ function useToggleTaskCompletion(client, contactId) {
2712
2525
  }
2713
2526
  //#endregion
2714
2527
  //#region ../../contacts/ui/src/portal/hooks/contacts/use-delete-contact-task.ts
2715
- function useDeleteContactTask(client, contactId, options) {
2528
+ function useDeleteContactTask(contactId, options) {
2716
2529
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
2530
+ const api = useTasksApi();
2717
2531
  return (0, _tanstack_react_query.useMutation)({
2718
- mutationFn: (taskId) => deleteUserTask(client, taskId),
2532
+ mutationFn: (taskId) => api.deleteTask(taskId),
2719
2533
  onSuccess: () => {
2720
2534
  require_src.fluidToast({
2721
2535
  title: "Task deleted",
2722
2536
  type: "success"
2723
2537
  });
2724
- queryClient.invalidateQueries({ queryKey: CONTACT_TASKS_QUERY_KEY(contactId) });
2538
+ queryClient.invalidateQueries({ queryKey: contactsKeys.tasks(contactId) });
2725
2539
  options?.onSuccess?.();
2726
2540
  },
2727
2541
  onError: (error) => {
@@ -2735,19 +2549,17 @@ function useDeleteContactTask(client, contactId, options) {
2735
2549
  }
2736
2550
  //#endregion
2737
2551
  //#region ../../contacts/ui/src/portal/hooks/contacts/use-create-contact-task.ts
2738
- function useCreateContactTask(client, contactId, options) {
2552
+ function useCreateContactTask(contactId, options) {
2739
2553
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
2554
+ const api = useTasksApi();
2740
2555
  return (0, _tanstack_react_query.useMutation)({
2741
- mutationFn: (input) => createUserContactTask(client, contactId, {
2742
- id: Number(contactId),
2743
- task: input
2744
- }),
2556
+ mutationFn: (input) => api.createTask(contactId, input),
2745
2557
  onSuccess: () => {
2746
2558
  require_src.fluidToast({
2747
2559
  title: "Task created",
2748
2560
  type: "success"
2749
2561
  });
2750
- queryClient.invalidateQueries({ queryKey: CONTACT_TASKS_QUERY_KEY(contactId) });
2562
+ queryClient.invalidateQueries({ queryKey: contactsKeys.tasks(contactId) });
2751
2563
  options?.onSuccess?.();
2752
2564
  },
2753
2565
  onError: (error) => {
@@ -2761,19 +2573,17 @@ function useCreateContactTask(client, contactId, options) {
2761
2573
  }
2762
2574
  //#endregion
2763
2575
  //#region ../../contacts/ui/src/portal/hooks/contacts/use-update-contact-task.ts
2764
- function useUpdateContactTask(client, contactId, options) {
2576
+ function useUpdateContactTask(contactId, options) {
2765
2577
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
2578
+ const api = useTasksApi();
2766
2579
  return (0, _tanstack_react_query.useMutation)({
2767
- mutationFn: ({ taskId, input }) => updateUserTask(client, taskId, {
2768
- id: taskId,
2769
- task: input
2770
- }),
2580
+ mutationFn: ({ taskId, input }) => api.updateTask(taskId, input),
2771
2581
  onSuccess: () => {
2772
2582
  require_src.fluidToast({
2773
2583
  title: "Task updated",
2774
2584
  type: "success"
2775
2585
  });
2776
- queryClient.invalidateQueries({ queryKey: CONTACT_TASKS_QUERY_KEY(contactId) });
2586
+ queryClient.invalidateQueries({ queryKey: contactsKeys.tasks(contactId) });
2777
2587
  options?.onSuccess?.();
2778
2588
  },
2779
2589
  onError: (error) => {
@@ -2931,15 +2741,14 @@ function TaskCard({ task, toggleCompletion, onEdit, onDeleteClick }) {
2931
2741
  })
2932
2742
  });
2933
2743
  }
2934
- function TaskList({ tasks, isLoading, contactId, client, tasksClient, ref }) {
2744
+ function TaskList({ tasks, isLoading, contactId, ref }) {
2935
2745
  const [taskToDelete, setTaskToDelete] = (0, react.useState)(null);
2936
2746
  const [modalOpen, setModalOpen] = (0, react.useState)(false);
2937
2747
  const [editingTask, setEditingTask] = (0, react.useState)(null);
2938
- const effectiveClient = tasksClient ?? client;
2939
- const toggleCompletion = useToggleTaskCompletion(effectiveClient, contactId);
2940
- const deleteTask = useDeleteContactTask(effectiveClient, contactId, { onSuccess: () => setTaskToDelete(null) });
2941
- const createTask = useCreateContactTask(effectiveClient, contactId, { onSuccess: () => setModalOpen(false) });
2942
- const updateTask = useUpdateContactTask(effectiveClient, contactId, { onSuccess: () => setEditingTask(null) });
2748
+ const toggleCompletion = useToggleTaskCompletion(contactId);
2749
+ const deleteTask = useDeleteContactTask(contactId, { onSuccess: () => setTaskToDelete(null) });
2750
+ const createTask = useCreateContactTask(contactId, { onSuccess: () => setModalOpen(false) });
2751
+ const updateTask = useUpdateContactTask(contactId, { onSuccess: () => setEditingTask(null) });
2943
2752
  const openCreateModal = () => {
2944
2753
  setEditingTask(null);
2945
2754
  setModalOpen(true);
@@ -3048,29 +2857,45 @@ function TaskList({ tasks, isLoading, contactId, client, tasksClient, ref }) {
3048
2857
  }
3049
2858
  //#endregion
3050
2859
  //#region ../../contacts/ui/src/portal/hooks/contacts/use-contact-activities.ts
3051
- function useContactActivities(client, contactId, options) {
2860
+ function useContactActivities(contactId, options) {
2861
+ const api = useContactsCrud();
3052
2862
  return (0, _tanstack_react_query.useQuery)({
3053
- queryKey: [
3054
- "portal-contacts",
3055
- "activities",
3056
- contactId
3057
- ],
3058
- queryFn: () => listUserContactActivities(client, contactId),
2863
+ queryKey: contactsKeys.activities(contactId),
2864
+ queryFn: () => api.listActivities(contactId),
3059
2865
  enabled: options?.enabled !== false && !!contactId,
3060
2866
  select: (data) => data.activities
3061
2867
  });
3062
2868
  }
3063
2869
  //#endregion
2870
+ //#region ../../contacts/ui/src/portal/hooks/contacts/use-contact-tasks.ts
2871
+ function useContactTasks(contactId) {
2872
+ const api = useTasksApi();
2873
+ return (0, _tanstack_react_query.useQuery)({
2874
+ queryKey: contactsKeys.tasks(contactId),
2875
+ queryFn: () => api.listTasks(contactId),
2876
+ enabled: !!contactId,
2877
+ select: (data) => data.tasks
2878
+ });
2879
+ }
2880
+ //#endregion
2881
+ //#region ../../contacts/ui/src/portal/hooks/notes/use-contact-notes.ts
2882
+ function useContactNotes(contactId) {
2883
+ const api = useNotesApi();
2884
+ return (0, _tanstack_react_query.useQuery)({
2885
+ queryKey: contactsKeys.notes(contactId),
2886
+ queryFn: () => api.listNotes(contactId),
2887
+ enabled: !!contactId,
2888
+ select: (data) => data.notes
2889
+ });
2890
+ }
2891
+ //#endregion
3064
2892
  //#region ../../contacts/ui/src/portal/hooks/contacts/use-mark-contact-read.ts
3065
- function useMarkContactRead(client, contactId) {
2893
+ function useMarkContactRead(contactId) {
3066
2894
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
3067
- const queryKey = [
3068
- "portal-contacts",
3069
- "activities",
3070
- contactId
3071
- ];
2895
+ const api = useContactsCrud();
2896
+ const queryKey = contactsKeys.activities(contactId);
3072
2897
  return (0, _tanstack_react_query.useMutation)({
3073
- mutationFn: () => markUserContactRead(client, contactId),
2898
+ mutationFn: () => api.markRead(contactId),
3074
2899
  onMutate: () => {
3075
2900
  const previous = queryClient.getQueryData(queryKey);
3076
2901
  if (previous) {
@@ -3096,12 +2921,12 @@ function useMarkContactRead(client, contactId) {
3096
2921
  //#endregion
3097
2922
  //#region ../../contacts/ui/src/portal/components/contacts/rep-contact-detail-view.tsx
3098
2923
  const DEFAULT_COUNTRY_OPTIONS = [];
3099
- function RepContactDetailView({ contact, contactId, client, notesClient, tasksClient, countryOptions = DEFAULT_COUNTRY_OPTIONS, ordersSlot, subscriptionsSlot }) {
2924
+ function RepContactDetailView({ contact, contactId, countryOptions = DEFAULT_COUNTRY_OPTIONS, ordersSlot, subscriptionsSlot }) {
3100
2925
  const [activeTab, setActiveTab] = (0, react.useState)("activity");
3101
- const { data: activities = [], isLoading: isLoadingActivities } = useContactActivities(client, contactId);
3102
- const { data: tasks = [], isLoading: isLoadingTasks } = useContactTasks(client, contactId);
3103
- const { data: notes = [], isLoading: isLoadingNotes } = useContactNotes(client, contactId);
3104
- const markRead = useMarkContactRead(client, contactId);
2926
+ const { data: activities = [], isLoading: isLoadingActivities } = useContactActivities(contactId);
2927
+ const { data: tasks = [], isLoading: isLoadingTasks } = useContactTasks(contactId);
2928
+ const { data: notes = [], isLoading: isLoadingNotes } = useContactNotes(contactId);
2929
+ const markRead = useMarkContactRead(contactId);
3105
2930
  const hasFiredRef = (0, react.useRef)(false);
3106
2931
  const prevHasUnreadRef = (0, react.useRef)(false);
3107
2932
  const openNoteModalRef = (0, react.useRef)(null);
@@ -3221,8 +3046,6 @@ function RepContactDetailView({ contact, contactId, client, notesClient, tasksCl
3221
3046
  tasks,
3222
3047
  isLoading: isLoadingTasks,
3223
3048
  contactId,
3224
- client,
3225
- tasksClient,
3226
3049
  ref: openTaskModalRef
3227
3050
  })
3228
3051
  }),
@@ -3233,8 +3056,6 @@ function RepContactDetailView({ contact, contactId, client, notesClient, tasksCl
3233
3056
  notes,
3234
3057
  isLoading: isLoadingNotes,
3235
3058
  contactId,
3236
- client,
3237
- notesClient,
3238
3059
  ref: openNoteModalRef
3239
3060
  })
3240
3061
  }),
@@ -3325,20 +3146,16 @@ function Pagination({ currentPage, totalPages, totalCount, onPageChange }) {
3325
3146
  }
3326
3147
  //#endregion
3327
3148
  //#region ../../contacts/ui/src/portal/hooks/contacts/use-contact-orders.ts
3328
- const CONTACT_ORDERS_QUERY_KEY = (contactId) => [
3329
- "rep-contacts",
3330
- "orders",
3331
- contactId
3332
- ];
3333
- function useContactOrders(client, contactId, params) {
3149
+ function useContactOrders(contactId, params) {
3150
+ const api = useContactsCrud();
3334
3151
  return (0, _tanstack_react_query.useQuery)({
3335
3152
  queryKey: [
3336
- ...CONTACT_ORDERS_QUERY_KEY(contactId),
3153
+ ...contactsKeys.orders(contactId),
3337
3154
  params?.page,
3338
3155
  params?.per_page,
3339
3156
  params?.status
3340
3157
  ],
3341
- queryFn: () => listUserContactOrders(client, contactId, params),
3158
+ queryFn: () => api.listOrders(contactId, params),
3342
3159
  enabled: !!contactId,
3343
3160
  placeholderData: _tanstack_react_query.keepPreviousData
3344
3161
  });
@@ -3520,10 +3337,10 @@ function OrderCard({ order }) {
3520
3337
  })
3521
3338
  });
3522
3339
  }
3523
- function ContactOrdersList({ client, contactId, pageSize = 10 }) {
3340
+ function ContactOrdersList({ contactId, pageSize = 10 }) {
3524
3341
  const [page, setPage] = (0, react.useState)(1);
3525
3342
  const [statusFilter, setStatusFilter] = (0, react.useState)(null);
3526
- const { data, isLoading, isError, isFetching } = useContactOrders(client, contactId, {
3343
+ const { data, isLoading, isError, isFetching } = useContactOrders(contactId, {
3527
3344
  page,
3528
3345
  per_page: pageSize,
3529
3346
  ...statusFilter ? { status: statusFilter } : {}
@@ -3609,20 +3426,16 @@ function ContactOrdersList({ client, contactId, pageSize = 10 }) {
3609
3426
  }
3610
3427
  //#endregion
3611
3428
  //#region ../../contacts/ui/src/portal/hooks/contacts/use-contact-subscription-orders.ts
3612
- const CONTACT_SUBSCRIPTION_ORDERS_QUERY_KEY = (contactId) => [
3613
- "rep-contacts",
3614
- "subscription-orders",
3615
- contactId
3616
- ];
3617
- function useContactSubscriptionOrders(client, contactId, params) {
3429
+ function useContactSubscriptionOrders(contactId, params) {
3430
+ const api = useContactsCrud();
3618
3431
  return (0, _tanstack_react_query.useQuery)({
3619
3432
  queryKey: [
3620
- ...CONTACT_SUBSCRIPTION_ORDERS_QUERY_KEY(contactId),
3433
+ ...contactsKeys.subscriptionOrders(contactId),
3621
3434
  params?.page,
3622
3435
  params?.per_page,
3623
3436
  params?.status
3624
3437
  ],
3625
- queryFn: () => listUserContactSubscriptionOrders(client, contactId, params),
3438
+ queryFn: () => api.listSubscriptionOrders(contactId, params),
3626
3439
  enabled: !!contactId,
3627
3440
  placeholderData: _tanstack_react_query.keepPreviousData
3628
3441
  });
@@ -3775,10 +3588,10 @@ function SubscriptionCard({ sub }) {
3775
3588
  })
3776
3589
  });
3777
3590
  }
3778
- function ContactSubscriptionOrdersList({ client, contactId, pageSize = 10 }) {
3591
+ function ContactSubscriptionOrdersList({ contactId, pageSize = 10 }) {
3779
3592
  const [page, setPage] = (0, react.useState)(1);
3780
3593
  const [statusFilter, setStatusFilter] = (0, react.useState)(null);
3781
- const { data, isLoading, isError, isFetching } = useContactSubscriptionOrders(client, contactId, {
3594
+ const { data, isLoading, isError, isFetching } = useContactSubscriptionOrders(contactId, {
3782
3595
  page,
3783
3596
  per_page: pageSize,
3784
3597
  ...statusFilter ? { status: statusFilter } : {}
@@ -3863,85 +3676,22 @@ function ContactSubscriptionOrdersList({ client, contactId, pageSize = 10 }) {
3863
3676
  });
3864
3677
  }
3865
3678
  //#endregion
3866
- //#region ../../contacts/fluid-company-contacts-api-client/src/namespaces/company_contacts.ts
3867
- /**
3868
- * Create a company contact
3869
- *
3870
- *
3871
- * @param client - Fetch client instance
3872
- * @param body - body
3873
- */
3874
- async function createCompanyContact(client, body) {
3875
- return client.post(`/api/company/contacts`, body);
3876
- }
3877
- /**
3878
- * Delete a company contact
3879
- *
3880
- *
3881
- * @param client - Fetch client instance
3882
- * @param id - id
3883
- */
3884
- async function deleteCompanyContact(client, id) {
3885
- return client.delete(`/api/company/contacts/${id}`);
3886
- }
3887
- /**
3888
- * Get a company contact
3889
- *
3890
- *
3891
- * @param client - Fetch client instance
3892
- * @param id - id
3893
- */
3894
- async function getCompanyContact(client, id) {
3895
- return client.get(`/api/company/contacts/${id}`);
3896
- }
3897
- /**
3898
- * Update a company contact
3899
- *
3900
- *
3901
- * @param client - Fetch client instance
3902
- * @param id - id
3903
- * @param body - body
3904
- */
3905
- async function updateCompanyContact(client, id, body) {
3906
- return client.patch(`/api/company/contacts/${id}`, body);
3907
- }
3908
- //#endregion
3909
- //#region ../../contacts/ui/src/shared/utils/createContactApi.ts
3910
- function createContactApi(config) {
3911
- const { mode, client } = config;
3912
- if (mode === "admin") return {
3913
- getContact: (id) => getCompanyContact(client, id),
3914
- createContact: (data) => createCompanyContact(client, { contact: data }),
3915
- updateContact: (id, data) => updateCompanyContact(client, id, {
3916
- id: Number(id),
3917
- contact: data
3918
- }),
3919
- deleteContact: (id) => deleteCompanyContact(client, id)
3920
- };
3921
- return {
3922
- getContact: (id) => getUserContact(client, id),
3923
- createContact: (data) => createUserContact(client, { contact: data }),
3924
- updateContact: (id, data) => updateUserContact(client, id, { contact: data }),
3925
- deleteContact: (id) => deleteUserContact(client, id)
3926
- };
3927
- }
3928
- //#endregion
3929
3679
  //#region ../../contacts/ui/src/shared/hooks/useContactDetail.ts
3930
- function useContactDetail(config, contactId, queryKeyPrefix = "contacts") {
3931
- const { getContact } = createContactApi(config);
3680
+ function useContactDetail(contactId, queryKeyPrefix = "contacts") {
3681
+ const api = useContactsCrud();
3932
3682
  return (0, _tanstack_react_query.useQuery)({
3933
3683
  queryKey: CONTACTS_QUERY_KEYS.detail(queryKeyPrefix, contactId),
3934
- queryFn: () => getContact(contactId),
3684
+ queryFn: () => api.getContact(contactId),
3935
3685
  enabled: !!contactId
3936
3686
  });
3937
3687
  }
3938
3688
  //#endregion
3939
3689
  //#region ../../contacts/ui/src/shared/hooks/useUpdateContactMutation.ts
3940
- function useUpdateContactMutation(config, contactId, queryKeyPrefix = "contacts", options) {
3690
+ function useUpdateContactMutation(contactId, queryKeyPrefix = "contacts", options) {
3941
3691
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
3942
- const { updateContact } = createContactApi(config);
3692
+ const api = useContactsCrud();
3943
3693
  return (0, _tanstack_react_query.useMutation)({
3944
- mutationFn: ({ id, data }) => updateContact(id, data),
3694
+ mutationFn: ({ id, data }) => api.updateContact(id, data),
3945
3695
  onSuccess: () => {
3946
3696
  require_src.fluidToast({
3947
3697
  title: "Contact updated successfully",
@@ -3962,11 +3712,11 @@ function useUpdateContactMutation(config, contactId, queryKeyPrefix = "contacts"
3962
3712
  }
3963
3713
  //#endregion
3964
3714
  //#region ../../contacts/ui/src/shared/hooks/useDeleteContactMutation.ts
3965
- function useDeleteContactMutation(config, queryKeyPrefix = "contacts", options) {
3715
+ function useDeleteContactMutation(queryKeyPrefix = "contacts", options) {
3966
3716
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
3967
- const { deleteContact } = createContactApi(config);
3717
+ const api = useContactsCrud();
3968
3718
  return (0, _tanstack_react_query.useMutation)({
3969
- mutationFn: (contactId) => deleteContact(contactId),
3719
+ mutationFn: (contactId) => api.deleteContact(contactId),
3970
3720
  onSuccess: () => {
3971
3721
  require_src.fluidToast({
3972
3722
  title: "Contact deleted successfully",
@@ -4021,9 +3771,9 @@ const editContactFormSchema = createContactFormSchema.passthrough();
4021
3771
  //#endregion
4022
3772
  //#region ../../contacts/ui/src/shared/hooks/useContactDetailPage.ts
4023
3773
  const mutableKeys = Object.keys(createContactFormSchema.shape);
4024
- function useContactDetailPage(config, contactId, options) {
3774
+ function useContactDetailPage(contactId, options) {
4025
3775
  const queryKeyPrefix = options?.queryKeyPrefix ?? "contacts";
4026
- const { data, isLoading } = useContactDetail(config, contactId, queryKeyPrefix);
3776
+ const { data, isLoading } = useContactDetail(contactId, queryKeyPrefix);
4027
3777
  const { data: countries } = (0, _tanstack_react_query.useQuery)({
4028
3778
  queryKey: ["countries"],
4029
3779
  queryFn: options?.getCountries ?? (() => Promise.resolve([])),
@@ -4044,10 +3794,10 @@ function useContactDetailPage(config, contactId, options) {
4044
3794
  }, [contact]),
4045
3795
  mode: "onBlur"
4046
3796
  });
4047
- const updateMutation = useUpdateContactMutation(config, contactId, queryKeyPrefix, { onSuccess: () => {
3797
+ const updateMutation = useUpdateContactMutation(contactId, queryKeyPrefix, { onSuccess: () => {
4048
3798
  methods.reset(methods.getValues());
4049
3799
  } });
4050
- const deleteMutation = useDeleteContactMutation(config, queryKeyPrefix, { onSuccess: () => {
3800
+ const deleteMutation = useDeleteContactMutation(queryKeyPrefix, { onSuccess: () => {
4051
3801
  options?.onDeleteSuccess?.();
4052
3802
  } });
4053
3803
  const onSave = (0, react.useCallback)(() => {
@@ -4098,11 +3848,11 @@ function useContactDetailPage(config, contactId, options) {
4098
3848
  }
4099
3849
  //#endregion
4100
3850
  //#region ../../contacts/ui/src/shared/hooks/useCreateContactMutation.ts
4101
- function useCreateContactMutation(config, queryKeyPrefix = "contacts", options) {
3851
+ function useCreateContactMutation(queryKeyPrefix = "contacts", options) {
4102
3852
  const queryClient = (0, _tanstack_react_query.useQueryClient)();
4103
- const { createContact } = createContactApi(config);
3853
+ const api = useContactsCrud();
4104
3854
  return (0, _tanstack_react_query.useMutation)({
4105
- mutationFn: (data) => createContact(data),
3855
+ mutationFn: (data) => api.createContact(data),
4106
3856
  onSuccess: (data) => {
4107
3857
  require_src.fluidToast({
4108
3858
  title: "Contact created successfully",
@@ -4146,12 +3896,260 @@ function useContactsConfig() {
4146
3896
  ]) };
4147
3897
  }
4148
3898
  //#endregion
3899
+ //#region ../../contacts/fluid-user-contacts-api-client/src/namespaces/users_contacts.ts
3900
+ /**
3901
+ * List activities for a contact
3902
+ *
3903
+ *
3904
+ * @param client - Fetch client instance
3905
+ * @param id - id
3906
+ * @param params? - params?
3907
+ */
3908
+ async function listUserContactActivities(client, id, params) {
3909
+ return client.get(`/api/users/v2025-06/contacts/${id}/activities`, params);
3910
+ }
3911
+ /**
3912
+ * Bulk delete contacts
3913
+ *
3914
+ *
3915
+ * @param client - Fetch client instance
3916
+ * @param body - body
3917
+ */
3918
+ async function bulkDeleteUserContacts(client, body) {
3919
+ return client.delete(`/api/users/v2025-06/contacts/bulk_delete`, { body });
3920
+ }
3921
+ /**
3922
+ * Create a contact
3923
+ *
3924
+ *
3925
+ * @param client - Fetch client instance
3926
+ * @param body - body
3927
+ */
3928
+ async function createUserContact(client, body) {
3929
+ return client.post(`/api/users/v2025-06/contacts`, body);
3930
+ }
3931
+ /**
3932
+ * List user's contacts
3933
+ *
3934
+ *
3935
+ * @param client - Fetch client instance
3936
+ * @param params? - params?
3937
+ */
3938
+ async function listUserContacts(client, params) {
3939
+ return client.get(`/api/users/v2025-06/contacts`, params);
3940
+ }
3941
+ /**
3942
+ * Delete a contact
3943
+ *
3944
+ *
3945
+ * @param client - Fetch client instance
3946
+ * @param id - id
3947
+ */
3948
+ async function deleteUserContact(client, id) {
3949
+ return client.delete(`/api/users/v2025-06/contacts/${id}`);
3950
+ }
3951
+ /**
3952
+ * Get a contact
3953
+ *
3954
+ *
3955
+ * @param client - Fetch client instance
3956
+ * @param id - id
3957
+ */
3958
+ async function getUserContact(client, id) {
3959
+ return client.get(`/api/users/v2025-06/contacts/${id}`);
3960
+ }
3961
+ /**
3962
+ * Update a contact
3963
+ *
3964
+ *
3965
+ * @param client - Fetch client instance
3966
+ * @param id - id
3967
+ * @param body - body
3968
+ */
3969
+ async function updateUserContact(client, id, body) {
3970
+ return client.patch(`/api/users/v2025-06/contacts/${id}`, body);
3971
+ }
3972
+ /**
3973
+ * Create a note for a contact (deprecated)
3974
+ *
3975
+ *
3976
+ * @param client - Fetch client instance
3977
+ * @param id - id
3978
+ * @param body - body
3979
+ */
3980
+ async function createUserContactNote(client, id, body) {
3981
+ return client.post(`/api/users/v2025-06/contacts/${id}/notes`, body);
3982
+ }
3983
+ /**
3984
+ * List notes for a contact
3985
+ *
3986
+ *
3987
+ * @param client - Fetch client instance
3988
+ * @param id - id
3989
+ */
3990
+ async function listUserContactNotes(client, id) {
3991
+ return client.get(`/api/users/v2025-06/contacts/${id}/notes`);
3992
+ }
3993
+ /**
3994
+ * List orders for a contact
3995
+ *
3996
+ *
3997
+ * @param client - Fetch client instance
3998
+ * @param id - id
3999
+ * @param params? - params?
4000
+ */
4001
+ async function listUserContactOrders(client, id, params) {
4002
+ return client.get(`/api/users/v2025-06/contacts/${id}/orders`, params);
4003
+ }
4004
+ /**
4005
+ * Mark contact's activities as read
4006
+ *
4007
+ *
4008
+ * @param client - Fetch client instance
4009
+ * @param id - id
4010
+ */
4011
+ async function markUserContactRead(client, id) {
4012
+ return client.post(`/api/users/v2025-06/contacts/${id}/read`);
4013
+ }
4014
+ /**
4015
+ * List subscription orders for a contact
4016
+ *
4017
+ *
4018
+ * @param client - Fetch client instance
4019
+ * @param id - id
4020
+ * @param params? - params?
4021
+ */
4022
+ async function listUserContactSubscriptionOrders(client, id, params) {
4023
+ return client.get(`/api/users/v2025-06/contacts/${id}/subscription_orders`, params);
4024
+ }
4025
+ /**
4026
+ * Create a task for a contact
4027
+ *
4028
+ *
4029
+ * @param client - Fetch client instance
4030
+ * @param id - id
4031
+ * @param body - body
4032
+ */
4033
+ async function createUserContactTask(client, id, body) {
4034
+ return client.post(`/api/users/v2025-06/contacts/${id}/tasks`, body);
4035
+ }
4036
+ /**
4037
+ * List tasks for a contact
4038
+ *
4039
+ *
4040
+ * @param client - Fetch client instance
4041
+ * @param id - id
4042
+ */
4043
+ async function listUserContactTasks(client, id) {
4044
+ return client.get(`/api/users/v2025-06/contacts/${id}/tasks`);
4045
+ }
4046
+ //#endregion
4047
+ //#region ../../notes/fluid-user-notes-api-client/src/namespaces/users_notes.ts
4048
+ /**
4049
+ * Delete a note
4050
+ *
4051
+ *
4052
+ * @param client - Fetch client instance
4053
+ * @param id - id
4054
+ * @param params - params
4055
+ */
4056
+ async function deleteUserNote(client, id, params) {
4057
+ return client.delete(`/api/users/v2025-06/notes/${id}`, { params });
4058
+ }
4059
+ /**
4060
+ * Update a note
4061
+ *
4062
+ *
4063
+ * @param client - Fetch client instance
4064
+ * @param id - id
4065
+ * @param body - body
4066
+ */
4067
+ async function updateUserNote(client, id, body) {
4068
+ return client.patch(`/api/users/v2025-06/notes/${id}`, body);
4069
+ }
4070
+ //#endregion
4071
+ //#region ../../tasks/fluid-user-tasks-api-client/src/namespaces/users_tasks.ts
4072
+ /**
4073
+ * Delete a task
4074
+ *
4075
+ *
4076
+ * @param client - Fetch client instance
4077
+ * @param id - id
4078
+ */
4079
+ async function deleteUserTask(client, id) {
4080
+ return client.delete(`/api/users/v2025-06/tasks/${id}`);
4081
+ }
4082
+ /**
4083
+ * Update a task
4084
+ *
4085
+ *
4086
+ * @param client - Fetch client instance
4087
+ * @param id - id
4088
+ * @param body - body
4089
+ */
4090
+ async function updateUserTask(client, id, body) {
4091
+ return client.patch(`/api/users/v2025-06/tasks/${id}`, body);
4092
+ }
4093
+ //#endregion
4094
+ //#region src/contacts/PortalContactsApiProvider.tsx
4095
+ function PortalContactsApiProvider({ children }) {
4096
+ const { client } = useContactsConfig();
4097
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactsApiProvider, {
4098
+ value: (0, react.useMemo)(() => {
4099
+ return {
4100
+ contacts: {
4101
+ getContact: (id) => getUserContact(client, id),
4102
+ listContacts: (params) => listUserContacts(client, params),
4103
+ createContact: (data) => createUserContact(client, { contact: data }),
4104
+ updateContact: (id, data) => updateUserContact(client, id, {
4105
+ id: Number(id),
4106
+ contact: data
4107
+ }),
4108
+ deleteContact: (id) => deleteUserContact(client, id),
4109
+ bulkDeleteContacts: (ids) => bulkDeleteUserContacts(client, { contact_ids: ids }),
4110
+ listActivities: (contactId) => listUserContactActivities(client, contactId),
4111
+ markRead: (contactId) => markUserContactRead(client, contactId),
4112
+ listOrders: (contactId, params) => listUserContactOrders(client, contactId, params),
4113
+ listSubscriptionOrders: (contactId, params) => listUserContactSubscriptionOrders(client, contactId, params)
4114
+ },
4115
+ notes: {
4116
+ listNotes: (contactId) => listUserContactNotes(client, contactId),
4117
+ createNote: (contactId, input) => createUserContactNote(client, contactId, {
4118
+ id: Number(contactId),
4119
+ note: input
4120
+ }),
4121
+ updateNote: (noteId, contactId, input) => updateUserNote(client, noteId, {
4122
+ contact_id: Number(contactId),
4123
+ id: noteId,
4124
+ note: input
4125
+ }),
4126
+ deleteNote: (noteId, contactId) => deleteUserNote(client, noteId, { contact_id: Number(contactId) })
4127
+ },
4128
+ tasks: {
4129
+ listTasks: (contactId) => listUserContactTasks(client, contactId),
4130
+ createTask: (contactId, input) => createUserContactTask(client, contactId, {
4131
+ id: Number(contactId),
4132
+ task: input
4133
+ }),
4134
+ updateTask: (taskId, input) => updateUserTask(client, taskId, {
4135
+ id: taskId,
4136
+ task: input
4137
+ }),
4138
+ deleteTask: (taskId) => deleteUserTask(client, taskId)
4139
+ }
4140
+ };
4141
+ }, [client]),
4142
+ children
4143
+ });
4144
+ }
4145
+ //#endregion
4149
4146
  //#region src/screens/ContactsScreen.tsx
4150
4147
  const QUERY_KEY_PREFIX = "sdk-contacts";
4151
4148
  function fetchCountries(client) {
4152
4149
  return client.get("/api/countries");
4153
4150
  }
4154
- function ContactListView({ client, onNavigate, onContactSelect }) {
4151
+ function ContactListView({ onNavigate, onContactSelect }) {
4152
+ const api = useContactsCrud();
4155
4153
  const handleSelectContact = (0, react.useCallback)((contact) => {
4156
4154
  onContactSelect?.(String(contact.id));
4157
4155
  onNavigate({
@@ -4160,8 +4158,8 @@ function ContactListView({ client, onNavigate, onContactSelect }) {
4160
4158
  });
4161
4159
  }, [onNavigate, onContactSelect]);
4162
4160
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactsListScreen, {
4163
- listContacts: (0, react.useCallback)((params) => listUserContacts(client, params), [client]),
4164
- deleteContacts: (0, react.useCallback)((ids) => bulkDeleteUserContacts(client, { contact_ids: ids }), [client]),
4161
+ listContacts: (0, react.useCallback)((params) => api.listContacts(params), [api]),
4162
+ deleteContacts: (0, react.useCallback)((ids) => api.bulkDeleteContacts(ids), [api]),
4165
4163
  queryKeyPrefix: QUERY_KEY_PREFIX,
4166
4164
  tableLayout: "members",
4167
4165
  onEditContact: handleSelectContact,
@@ -4171,11 +4169,9 @@ function ContactListView({ client, onNavigate, onContactSelect }) {
4171
4169
  }, [onNavigate])
4172
4170
  });
4173
4171
  }
4174
- function ContactDetailView({ contactId, client, onNavigate }) {
4175
- const { contact, isLoading, methods, countryOptions, isDirty, isSubmitting, isDeleting, onSave, onDelete } = useContactDetailPage((0, react.useMemo)(() => ({
4176
- mode: "rep",
4177
- client
4178
- }), [client]), contactId, {
4172
+ function ContactDetailView({ contactId, onNavigate }) {
4173
+ const { client } = useContactsConfig();
4174
+ const { contact, isLoading, methods, countryOptions, isDirty, isSubmitting, isDeleting, onSave, onDelete } = useContactDetailPage(contactId, {
4179
4175
  queryKeyPrefix: QUERY_KEY_PREFIX,
4180
4176
  getCountries: (0, react.useCallback)(() => fetchCountries(client), [client]),
4181
4177
  onDeleteSuccess: () => onNavigate({ view: "list" })
@@ -4227,18 +4223,9 @@ function ContactDetailView({ contactId, client, onNavigate }) {
4227
4223
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RepContactDetailView, {
4228
4224
  contact,
4229
4225
  contactId,
4230
- client,
4231
- notesClient: client,
4232
- tasksClient: client,
4233
4226
  countryOptions,
4234
- ordersSlot: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactOrdersList, {
4235
- client,
4236
- contactId
4237
- }),
4238
- subscriptionsSlot: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactSubscriptionOrdersList, {
4239
- client,
4240
- contactId
4241
- })
4227
+ ordersSlot: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactOrdersList, { contactId }),
4228
+ subscriptionsSlot: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactSubscriptionOrdersList, { contactId })
4242
4229
  })
4243
4230
  })
4244
4231
  });
@@ -4258,12 +4245,9 @@ const CREATE_DEFAULT_VALUES = {
4258
4245
  metadata: {},
4259
4246
  affiliate: {}
4260
4247
  };
4261
- function ContactCreateView({ client, onNavigate, onCreateContact }) {
4248
+ function ContactCreateView({ onNavigate, onCreateContact }) {
4262
4249
  const formRef = (0, react.useRef)(null);
4263
- const config = (0, react.useMemo)(() => ({
4264
- mode: "rep",
4265
- client
4266
- }), [client]);
4250
+ const { client } = useContactsConfig();
4267
4251
  const { data: countries } = (0, _tanstack_react_query.useQuery)({
4268
4252
  queryKey: ["countries"],
4269
4253
  queryFn: () => fetchCountries(client)
@@ -4273,7 +4257,7 @@ function ContactCreateView({ client, onNavigate, onCreateContact }) {
4273
4257
  value: c.iso ?? String(c.id)
4274
4258
  })).sort((a, b) => a.name.localeCompare(b.name)), [countries]);
4275
4259
  const methods = require_src.useZodForm(createContactFormSchema, { defaultValues: CREATE_DEFAULT_VALUES });
4276
- const mutation = useCreateContactMutation(config, QUERY_KEY_PREFIX, { onSuccess: (data) => {
4260
+ const mutation = useCreateContactMutation(QUERY_KEY_PREFIX, { onSuccess: (data) => {
4277
4261
  onCreateContact?.();
4278
4262
  const newContactId = data?.contact?.id;
4279
4263
  if (newContactId) onNavigate({
@@ -4316,29 +4300,25 @@ function ContactCreateView({ client, onNavigate, onCreateContact }) {
4316
4300
  });
4317
4301
  }
4318
4302
  function ContactsScreen({ onContactSelect, onCreateContact, background, textColor, accentColor, padding, borderRadius, defaultViewMode, ...divProps }) {
4319
- const { client } = useContactsConfig();
4320
4303
  const [nav, setNav] = (0, react.useState)({ view: "list" });
4321
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4304
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PortalContactsApiProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4322
4305
  ...divProps,
4323
4306
  className: `h-full ${divProps.className ?? ""}`,
4324
4307
  children: [
4325
4308
  nav.view === "list" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactListView, {
4326
- client,
4327
4309
  onNavigate: setNav,
4328
4310
  onContactSelect
4329
4311
  }),
4330
4312
  nav.view === "detail" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactDetailView, {
4331
4313
  contactId: nav.contactId,
4332
- client,
4333
4314
  onNavigate: setNav
4334
4315
  }),
4335
4316
  nav.view === "new" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContactCreateView, {
4336
- client,
4337
4317
  onNavigate: setNav,
4338
4318
  onCreateContact
4339
4319
  })
4340
4320
  ]
4341
- });
4321
+ }) });
4342
4322
  }
4343
4323
  const contactsScreenPropertySchema = {
4344
4324
  widgetType: "ContactsScreen",
@@ -4363,4 +4343,4 @@ Object.defineProperty(exports, "contactsScreenPropertySchema", {
4363
4343
  }
4364
4344
  });
4365
4345
 
4366
- //# sourceMappingURL=ContactsScreen-0h6EW-5L.cjs.map
4346
+ //# sourceMappingURL=ContactsScreen-BELhEJNe.cjs.map