@raystack/frontier 0.115.0 → 0.116.1

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.
@@ -47,8 +47,8 @@ function convertBillingAddressToString(address) {
47
47
  // admin/views/roles/columns.tsx
48
48
  import { Flex } from "@raystack/apsara";
49
49
 
50
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-UHvby2ZZMfLm/sdk/admin/views/roles/roles.module.css.js
51
- var digest = "c5cef93519be48c91fcd255c5afd7ace284ee316bd467a56066954db439d3f8d";
50
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-2BjjUYeCXRQl/sdk/admin/views/roles/roles.module.css.js
51
+ var digest = "676b25b1a852da1c6a23592eb7e50d2d38988e95bec996371c4a810e0981389c";
52
52
  var css = `._tableRoot_1d549_1 {
53
53
  width: 100%;
54
54
  }
@@ -515,8 +515,8 @@ var UploadIcon = /* @__PURE__ */ forwardRef(function(_ref, forwardedRef) {
515
515
  // admin/components/PageHeader.tsx
516
516
  import { Flex as Flex2, Text } from "@raystack/apsara";
517
517
 
518
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-C5Q0wAkwPhz7/sdk/admin/components/page-header.module.css.js
519
- var digest2 = "4f6ce4f7815b9be38e4b4f7cea2e25ae897a28c66d77f213b17a26c469b53695";
518
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-vGSXL5lVDeMw/sdk/admin/components/page-header.module.css.js
519
+ var digest2 = "dfb48b06fc1ee43254769c4d0e5b21be9ef872661a685c5fa584907f5e45498d";
520
520
  var css2 = `._breadcrumb_1kaun_1 {
521
521
  list-style: none;
522
522
  padding: 0;
@@ -638,8 +638,8 @@ function PageTitle({ title, appName }) {
638
638
  return null;
639
639
  }
640
640
 
641
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-qjARN6Q5X6BL/sdk/admin/views/roles/roles.module.css.js
642
- var digest3 = "a6f5aa247b01cd6d0043e7a0b8803a4682396cd826b6ddb5ce584336133c04aa";
641
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-eoxmV7Lexpcd/sdk/admin/views/roles/roles.module.css.js
642
+ var digest3 = "5fc310ade357a1c42c28c476c82fa6815e524425cc544af92856a38f9c3ed88b";
643
643
  var css3 = `._tableRoot_1d549_1 {
644
644
  width: 100%;
645
645
  }
@@ -830,13 +830,12 @@ import {
830
830
  EmptyState as EmptyState2,
831
831
  Flex as Flex7
832
832
  } from "@raystack/apsara";
833
- import { useState as useState3 } from "react";
834
833
 
835
834
  // admin/views/invoices/navbar.tsx
836
835
  import { DataTable as DataTable2, Flex as Flex6, IconButton, Text as Text4 } from "@raystack/apsara";
837
836
 
838
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-toIRctUNIh86/sdk/admin/components/navbar.module.css.js
839
- var digest4 = "ef784a0b54e8491467cb265332dd152aed6992b830b5d29b6198aa6e999071b1";
837
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-xP2ZWV1aPHBB/sdk/admin/components/navbar.module.css.js
838
+ var digest4 = "e10215f1e84a8ec1d480a94e8e73d4c62d4547f5d4c51c3d42b5f278a108661d";
840
839
  var css4 = `._navbar_641ya_1 {
841
840
  padding: var(--rs-space-4) var(--rs-space-7);
842
841
  border-bottom: 0.5px solid var(--rs-color-border-base-primary);
@@ -930,8 +929,8 @@ var InvoicesNavabar = ({ searchQuery }) => {
930
929
  ] });
931
930
  };
932
931
 
933
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-8NqXoVm7vtKl/sdk/admin/views/invoices/invoices.module.css.js
934
- var digest5 = "82b9a4e44ebae45d7816ce748327ae05541f79de4821fc4bcc5afdc75090c300";
932
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-0Ji2aVVjMuUq/sdk/admin/views/invoices/invoices.module.css.js
933
+ var digest5 = "c7dffe9bb0b1e799936d1847133a9718c6b35fd2100d8b3f686103fdb4e90116";
935
934
  var css5 = `._table_xk3nj_1 {
936
935
  height: auto;
937
936
  }
@@ -1012,8 +1011,8 @@ function formatInviteExpiry(expiresAt) {
1012
1011
  };
1013
1012
  }
1014
1013
 
1015
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-hztvsO9siZTH/sdk/admin/views/invoices/invoices.module.css.js
1016
- var digest6 = "96098ac43b149fff8a643d660a0363d010e289f950bf5f80829aae8441810033";
1014
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-PDnq0mopqkS6/sdk/admin/views/invoices/invoices.module.css.js
1015
+ var digest6 = "5814639c433e7fb3dc73e7ff9f7c600d0b4fc2f32f61c9f75a7f1f1395c4dbd3";
1017
1016
  var css6 = `._table_xk3nj_1 {
1018
1017
  height: auto;
1019
1018
  }
@@ -1112,7 +1111,7 @@ var getColumns2 = ({ t }) => {
1112
1111
  };
1113
1112
 
1114
1113
  // admin/views/invoices/index.tsx
1115
- import { useInfiniteQuery } from "@connectrpc/connect-query";
1114
+ import { useInfiniteQuery as useInfiniteQuery2 } from "@connectrpc/connect-query";
1116
1115
  import { AdminServiceQueries } from "@raystack/proton/frontier";
1117
1116
 
1118
1117
  // utils/connect-pagination.ts
@@ -1153,6 +1152,113 @@ function getGroupCountMapFromFirstPage(infiniteData) {
1153
1152
  return { [groupKey]: groupCount };
1154
1153
  }
1155
1154
 
1155
+ // shared/terminology.tsx
1156
+ import { createContext, useContext, useMemo } from "react";
1157
+ import { jsx as jsx9 } from "react/jsx-runtime";
1158
+ var applyCase = (text, caseType) => {
1159
+ switch (caseType) {
1160
+ case "lower":
1161
+ return text.toLowerCase();
1162
+ case "upper":
1163
+ return text.toUpperCase();
1164
+ case "capital":
1165
+ return text.charAt(0).toUpperCase() + text.slice(1);
1166
+ default:
1167
+ return text;
1168
+ }
1169
+ };
1170
+ var createEntity = (singular, plural) => {
1171
+ return ({
1172
+ plural: isPlural = false,
1173
+ case: caseType
1174
+ } = {}) => {
1175
+ const text = isPlural ? plural : singular;
1176
+ return applyCase(text, caseType);
1177
+ };
1178
+ };
1179
+ var DEFAULT_TERMINOLOGY = {
1180
+ organization: { singular: "Organization", plural: "Organizations" },
1181
+ project: { singular: "Project", plural: "Projects" },
1182
+ team: { singular: "Team", plural: "Teams" },
1183
+ member: { singular: "Member", plural: "Members" },
1184
+ user: { singular: "User", plural: "Users" },
1185
+ appName: "Frontier"
1186
+ };
1187
+ function createTerminologyMap(terminology, defaults = DEFAULT_TERMINOLOGY) {
1188
+ const t = terminology || defaults;
1189
+ return {
1190
+ organization: createEntity(
1191
+ t.organization?.singular || defaults.organization.singular,
1192
+ t.organization?.plural || defaults.organization.plural
1193
+ ),
1194
+ project: createEntity(
1195
+ t.project?.singular || defaults.project.singular,
1196
+ t.project?.plural || defaults.project.plural
1197
+ ),
1198
+ team: createEntity(
1199
+ t.team?.singular || defaults.team.singular,
1200
+ t.team?.plural || defaults.team.plural
1201
+ ),
1202
+ member: createEntity(
1203
+ t.member?.singular || defaults.member.singular,
1204
+ t.member?.plural || defaults.member.plural
1205
+ ),
1206
+ user: createEntity(
1207
+ t.user?.singular || defaults.user.singular,
1208
+ t.user?.plural || defaults.user.plural
1209
+ ),
1210
+ appName: createEntity(
1211
+ t.appName || defaults.appName,
1212
+ t.appName || defaults.appName
1213
+ )
1214
+ };
1215
+ }
1216
+ var TerminologyContext = createContext(
1217
+ createTerminologyMap()
1218
+ );
1219
+ var TerminologyProvider = ({
1220
+ children,
1221
+ terminology,
1222
+ defaults
1223
+ }) => {
1224
+ const map = useMemo(
1225
+ () => createTerminologyMap(terminology, defaults),
1226
+ [terminology, defaults]
1227
+ );
1228
+ return /* @__PURE__ */ jsx9(TerminologyContext.Provider, { value: map, children });
1229
+ };
1230
+ var useTerminology = () => {
1231
+ return useContext(TerminologyContext);
1232
+ };
1233
+
1234
+ // admin/hooks/useLoadMore.ts
1235
+ import { useCallback as useCallback2, useRef } from "react";
1236
+ var useLoadMore = ({
1237
+ hasNextPage,
1238
+ isFetchingNextPage,
1239
+ fetchNextPage,
1240
+ isError,
1241
+ label
1242
+ }) => {
1243
+ const isLoadingMoreRef = useRef(false);
1244
+ return useCallback2(async () => {
1245
+ if (!hasNextPage || isFetchingNextPage || isError || isLoadingMoreRef.current) {
1246
+ return;
1247
+ }
1248
+ isLoadingMoreRef.current = true;
1249
+ try {
1250
+ await fetchNextPage();
1251
+ } catch (error) {
1252
+ console.error(`Error loading more ${label}:`, error);
1253
+ } finally {
1254
+ isLoadingMoreRef.current = false;
1255
+ }
1256
+ }, [hasNextPage, isFetchingNextPage, isError, fetchNextPage, label]);
1257
+ };
1258
+
1259
+ // admin/hooks/useServerTableQuery.ts
1260
+ import { useCallback as useCallback3, useMemo as useMemo2, useRef as useRef2, useState as useState4 } from "react";
1261
+
1156
1262
  // utils/transform-query.ts
1157
1263
  import {
1158
1264
  RQLRequestSchema,
@@ -1250,84 +1356,96 @@ function transformDataTableQueryToRQLRequest(query, options = {}) {
1250
1356
  return rqlRequest;
1251
1357
  }
1252
1358
 
1253
- // shared/terminology.tsx
1254
- import { createContext, useContext, useMemo } from "react";
1255
- import { jsx as jsx9 } from "react/jsx-runtime";
1256
- var applyCase = (text, caseType) => {
1257
- switch (caseType) {
1258
- case "lower":
1259
- return text.toLowerCase();
1260
- case "upper":
1261
- return text.toUpperCase();
1262
- case "capital":
1263
- return text.charAt(0).toUpperCase() + text.slice(1);
1359
+ // hooks/index.ts
1360
+ import {
1361
+ useQuery as useQuery2,
1362
+ useMutation,
1363
+ useInfiniteQuery,
1364
+ useTransport,
1365
+ createConnectQueryKey
1366
+ } from "@connectrpc/connect-query";
1367
+ import { ConnectError as ConnectError2, Code as Code2 } from "@connectrpc/connect";
1368
+
1369
+ // utils/error.ts
1370
+ import { Code, ConnectError } from "@connectrpc/connect";
1371
+ var DEFAULT_ERROR_MESSAGE = "Something went wrong";
1372
+ function handleConnectError(error, handlers) {
1373
+ const connectError = error instanceof ConnectError ? error : new ConnectError(
1374
+ typeof error === "string" ? error : error instanceof Error ? error.message : DEFAULT_ERROR_MESSAGE
1375
+ );
1376
+ const defaultHandler = handlers?.Default ?? ((err) => console.error(err.message));
1377
+ switch (connectError.code) {
1378
+ case Code.AlreadyExists:
1379
+ handlers?.AlreadyExists ? handlers.AlreadyExists(connectError) : defaultHandler(connectError);
1380
+ break;
1381
+ case Code.InvalidArgument:
1382
+ handlers?.InvalidArgument ? handlers.InvalidArgument(connectError) : defaultHandler(connectError);
1383
+ break;
1384
+ case Code.PermissionDenied:
1385
+ handlers?.PermissionDenied ? handlers.PermissionDenied(connectError) : defaultHandler(connectError);
1386
+ break;
1387
+ case Code.NotFound:
1388
+ handlers?.NotFound ? handlers.NotFound(connectError) : defaultHandler(connectError);
1389
+ break;
1390
+ case Code.FailedPrecondition:
1391
+ handlers?.FailedPrecondition ? handlers.FailedPrecondition(connectError) : defaultHandler(connectError);
1392
+ break;
1264
1393
  default:
1265
- return text;
1394
+ defaultHandler(connectError);
1266
1395
  }
1267
- };
1268
- var createEntity = (singular, plural) => {
1269
- return ({
1270
- plural: isPlural = false,
1271
- case: caseType
1272
- } = {}) => {
1273
- const text = isPlural ? plural : singular;
1274
- return applyCase(text, caseType);
1275
- };
1276
- };
1277
- var DEFAULT_TERMINOLOGY = {
1278
- organization: { singular: "Organization", plural: "Organizations" },
1279
- project: { singular: "Project", plural: "Projects" },
1280
- team: { singular: "Team", plural: "Teams" },
1281
- member: { singular: "Member", plural: "Members" },
1282
- user: { singular: "User", plural: "Users" },
1283
- appName: "Frontier"
1284
- };
1285
- function createTerminologyMap(terminology, defaults = DEFAULT_TERMINOLOGY) {
1286
- const t = terminology || defaults;
1287
- return {
1288
- organization: createEntity(
1289
- t.organization?.singular || defaults.organization.singular,
1290
- t.organization?.plural || defaults.organization.plural
1291
- ),
1292
- project: createEntity(
1293
- t.project?.singular || defaults.project.singular,
1294
- t.project?.plural || defaults.project.plural
1295
- ),
1296
- team: createEntity(
1297
- t.team?.singular || defaults.team.singular,
1298
- t.team?.plural || defaults.team.plural
1299
- ),
1300
- member: createEntity(
1301
- t.member?.singular || defaults.member.singular,
1302
- t.member?.plural || defaults.member.plural
1303
- ),
1304
- user: createEntity(
1305
- t.user?.singular || defaults.user.singular,
1306
- t.user?.plural || defaults.user.plural
1307
- ),
1308
- appName: createEntity(
1309
- t.appName || defaults.appName,
1310
- t.appName || defaults.appName
1311
- )
1312
- };
1313
1396
  }
1314
- var TerminologyContext = createContext(
1315
- createTerminologyMap()
1316
- );
1317
- var TerminologyProvider = ({
1318
- children,
1319
- terminology,
1320
- defaults
1321
- }) => {
1322
- const map = useMemo(
1323
- () => createTerminologyMap(terminology, defaults),
1324
- [terminology, defaults]
1325
- );
1326
- return /* @__PURE__ */ jsx9(TerminologyContext.Provider, { value: map, children });
1327
- };
1328
- var useTerminology = () => {
1329
- return useContext(TerminologyContext);
1330
- };
1397
+
1398
+ // hooks/index.ts
1399
+ import { FrontierServiceQueries as FrontierServiceQueries2 } from "@raystack/proton/frontier";
1400
+ import { useQueryClient } from "@tanstack/react-query";
1401
+ import { create as create2 } from "@bufbuild/protobuf";
1402
+
1403
+ // hooks/useDebouncedValue.ts
1404
+ import { useEffect as useEffect2, useState as useState3 } from "react";
1405
+ function useDebouncedValue(value, delay) {
1406
+ const [debouncedValue, setDebouncedValue] = useState3(value);
1407
+ useEffect2(() => {
1408
+ const timer = setTimeout(() => setDebouncedValue(value), delay);
1409
+ return () => clearTimeout(timer);
1410
+ }, [value, delay]);
1411
+ return debouncedValue;
1412
+ }
1413
+
1414
+ // admin/hooks/useServerTableQuery.ts
1415
+ function useServerTableQuery({
1416
+ defaultSort,
1417
+ transformOptions,
1418
+ search,
1419
+ mapQuery,
1420
+ debounceMs = 200
1421
+ } = {}) {
1422
+ const [tableQuery, setTableQuery] = useState4(() => ({
1423
+ offset: 0,
1424
+ limit: DEFAULT_PAGE_SIZE,
1425
+ sort: defaultSort ? [defaultSort] : []
1426
+ }));
1427
+ const transformOptionsRef = useRef2(transformOptions);
1428
+ transformOptionsRef.current = transformOptions;
1429
+ const mapQueryRef = useRef2(mapQuery);
1430
+ mapQueryRef.current = mapQuery;
1431
+ const computedQuery = useMemo2(() => {
1432
+ const mapped = mapQueryRef.current ? mapQueryRef.current(tableQuery) : tableQuery;
1433
+ const rql = transformDataTableQueryToRQLRequest(
1434
+ mapped,
1435
+ transformOptionsRef.current
1436
+ );
1437
+ return search === void 0 ? rql : { ...rql, search };
1438
+ }, [tableQuery, search]);
1439
+ const rqlQuery = useDebouncedValue(computedQuery, debounceMs);
1440
+ const onTableQueryChange = useCallback3((query) => {
1441
+ setTableQuery({
1442
+ ...query,
1443
+ offset: 0,
1444
+ limit: query.limit || DEFAULT_PAGE_SIZE
1445
+ });
1446
+ }, []);
1447
+ return { tableQuery, rqlQuery, onTableQueryChange };
1448
+ }
1331
1449
 
1332
1450
  // admin/views/invoices/index.tsx
1333
1451
  import { Fragment, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
@@ -1347,16 +1465,18 @@ var NoInvoices = () => {
1347
1465
  );
1348
1466
  };
1349
1467
  var DEFAULT_SORT = { name: "createdAt", order: "desc" };
1350
- var INITIAL_QUERY = {
1351
- offset: 0,
1352
- limit: DEFAULT_PAGE_SIZE
1353
- };
1354
1468
  function InvoicesView({ appName } = {}) {
1355
1469
  const t = useTerminology();
1356
- const [tableQuery, setTableQuery] = useState3(INITIAL_QUERY);
1357
- const query = transformDataTableQueryToRQLRequest(tableQuery, {
1358
- fieldNameMapping: {
1359
- createdAt: "created_at"
1470
+ const {
1471
+ tableQuery,
1472
+ rqlQuery: query,
1473
+ onTableQueryChange
1474
+ } = useServerTableQuery({
1475
+ defaultSort: DEFAULT_SORT,
1476
+ transformOptions: {
1477
+ fieldNameMapping: {
1478
+ createdAt: "created_at"
1479
+ }
1360
1480
  }
1361
1481
  });
1362
1482
  const {
@@ -1367,7 +1487,7 @@ function InvoicesView({ appName } = {}) {
1367
1487
  error,
1368
1488
  isError,
1369
1489
  hasNextPage
1370
- } = useInfiniteQuery(
1490
+ } = useInfiniteQuery2(
1371
1491
  AdminServiceQueries.searchInvoices,
1372
1492
  { query },
1373
1493
  {
@@ -1380,22 +1500,13 @@ function InvoicesView({ appName } = {}) {
1380
1500
  }
1381
1501
  );
1382
1502
  const data = infiniteData?.pages?.flatMap((page) => page?.invoices || []) || [];
1383
- const onTableQueryChange = (newQuery) => {
1384
- setTableQuery({
1385
- ...newQuery,
1386
- offset: 0,
1387
- limit: newQuery.limit || DEFAULT_PAGE_SIZE
1388
- });
1389
- };
1390
- const handleLoadMore = async () => {
1391
- try {
1392
- if (!hasNextPage)
1393
- return;
1394
- await fetchNextPage();
1395
- } catch (error2) {
1396
- console.error("Error loading more invoices:", error2);
1397
- }
1398
- };
1503
+ const handleLoadMore = useLoadMore({
1504
+ hasNextPage,
1505
+ isFetchingNextPage,
1506
+ isError,
1507
+ fetchNextPage,
1508
+ label: "invoices"
1509
+ });
1399
1510
  const columns = getColumns2({ t });
1400
1511
  const loading = isLoading || isFetchingNextPage;
1401
1512
  if (isError) {
@@ -1450,15 +1561,15 @@ function InvoicesView({ appName } = {}) {
1450
1561
 
1451
1562
  // admin/views/products/index.tsx
1452
1563
  import { EmptyState as EmptyState3, Flex as Flex10, DataTable as DataTable4 } from "@raystack/apsara";
1453
- import { useEffect as useEffect2 } from "react";
1454
- import { useQuery as useQuery2 } from "@connectrpc/connect-query";
1455
- import { FrontierServiceQueries as FrontierServiceQueries2 } from "@raystack/proton/frontier";
1564
+ import { useEffect as useEffect3 } from "react";
1565
+ import { useQuery as useQuery3 } from "@connectrpc/connect-query";
1566
+ import { FrontierServiceQueries as FrontierServiceQueries3 } from "@raystack/proton/frontier";
1456
1567
 
1457
1568
  // admin/views/products/columns.tsx
1458
1569
  import { Flex as Flex8, Image, Amount as Amount2 } from "@raystack/apsara";
1459
1570
 
1460
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-xUUhxWN7TWwQ/sdk/admin/views/products/products.module.css.js
1461
- var digest7 = "9aa1dd0139daf925cc7200aeb2d22f392e77e3be01bb2130b9101481137b67fe";
1571
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-yN4JVxNm5d6Q/sdk/admin/views/products/products.module.css.js
1572
+ var digest7 = "abe055d52da67537845b8756485eaf51d631405c832a0cc1a476735de0c3bd88";
1462
1573
  var css7 = `._tableRoot_3ccjp_1 {
1463
1574
  width: 100%;
1464
1575
  }
@@ -1610,8 +1721,8 @@ var getColumns3 = (onNavigateToPrices) => {
1610
1721
  ];
1611
1722
  };
1612
1723
 
1613
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-D2uP2lmS1psN/sdk/admin/views/products/products.module.css.js
1614
- var digest8 = "295d66d0bf007f1521a060af13763631a6f70ad8efa8312e3593c8a80a46e326";
1724
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-kNePO3MURh9z/sdk/admin/views/products/products.module.css.js
1725
+ var digest8 = "8d53ef568bb10abe24657a886b92266f9374c8608cc236031ef8765df55a78e7";
1615
1726
  var css8 = `._tableRoot_3ccjp_1 {
1616
1727
  width: 100%;
1617
1728
  }
@@ -1668,8 +1779,8 @@ var products_module_css_default2 = { "tableRoot": "_tableRoot_3ccjp_1", "tableWr
1668
1779
  // admin/views/products/details.tsx
1669
1780
  import { Flex as Flex9, Text as Text6, Grid as Grid2, Drawer as Drawer2 } from "@raystack/apsara";
1670
1781
 
1671
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-T0t6ZWzgD2yx/sdk/admin/views/products/products.module.css.js
1672
- var digest9 = "3bb5cd6217b5f5fcc1d38676550d1c7881b3acc09341e56283e73f919097badf";
1782
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-ocQqam6edFh5/sdk/admin/views/products/products.module.css.js
1783
+ var digest9 = "b0b2e10296db583292c29e9bed7bb3689cf21f2fa997990d66ae55f4c50264ba";
1673
1784
  var css9 = `._tableRoot_3ccjp_1 {
1674
1785
  width: 100%;
1675
1786
  }
@@ -1780,13 +1891,13 @@ function ProductsView({
1780
1891
  isLoading: isProductsLoading,
1781
1892
  error,
1782
1893
  isError
1783
- } = useQuery2(FrontierServiceQueries2.listProducts, {}, {
1894
+ } = useQuery3(FrontierServiceQueries3.listProducts, {}, {
1784
1895
  staleTime: Infinity
1785
1896
  });
1786
1897
  const products = productsResponse?.products || [];
1787
1898
  const productMapById = reduceByKey(products ?? [], "id");
1788
1899
  const product = selectedProductId ? productMapById[selectedProductId] ?? null : null;
1789
- useEffect2(() => {
1900
+ useEffect3(() => {
1790
1901
  if (selectedProductId && !isProductsLoading && !isError && !product) {
1791
1902
  onCloseDetail?.();
1792
1903
  }
@@ -1865,14 +1976,14 @@ var noDataChildren2 = /* @__PURE__ */ jsx13(
1865
1976
 
1866
1977
  // admin/views/products/prices/index.tsx
1867
1978
  import { Flex as Flex11, EmptyState as EmptyState4, DataTable as DataTable5 } from "@raystack/apsara";
1868
- import { useQuery as useQuery3 } from "@connectrpc/connect-query";
1869
- import { FrontierServiceQueries as FrontierServiceQueries3 } from "@raystack/proton/frontier";
1979
+ import { useQuery as useQuery4 } from "@connectrpc/connect-query";
1980
+ import { FrontierServiceQueries as FrontierServiceQueries4 } from "@raystack/proton/frontier";
1870
1981
 
1871
1982
  // admin/views/products/prices/columns.tsx
1872
1983
  import { Amount as Amount3 } from "@raystack/apsara";
1873
1984
 
1874
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-0ibUeYG0b7Lj/sdk/admin/views/products/prices/prices.module.css.js
1875
- var digest10 = "8b68d57f32fc94cdde9ebf4b9aa3c4532d292606396c0cf70a69b2ac8b3efa63";
1985
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-lmV27OOdr6Zj/sdk/admin/views/products/prices/prices.module.css.js
1986
+ var digest10 = "f7a10d0038e8f5dad5780e9fb11b20b862a9bcf1db91b11063e5e319e3dd1271";
1876
1987
  var css10 = `._first-column_6e56r_1 {
1877
1988
  padding-left: var(--rs-space-7);
1878
1989
  }
@@ -1963,8 +2074,8 @@ var getColumns4 = (prices) => {
1963
2074
  ];
1964
2075
  };
1965
2076
 
1966
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-nscFQ56FCYtj/sdk/admin/views/products/products.module.css.js
1967
- var digest11 = "382d8457a09dd1aa5883adbc385cc915d20f8b37a3606324eb3af1a453689a76";
2077
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-N59n7zrDqXp9/sdk/admin/views/products/products.module.css.js
2078
+ var digest11 = "2b8e64a0c04d1ab17f15a2d801cec831d840c9efe76de2539b49f71deaed520a";
1968
2079
  var css11 = `._tableRoot_3ccjp_1 {
1969
2080
  width: 100%;
1970
2081
  }
@@ -2030,8 +2141,8 @@ function ProductPricesView({
2030
2141
  isLoading: isProductLoading,
2031
2142
  error,
2032
2143
  isError
2033
- } = useQuery3(
2034
- FrontierServiceQueries3.getProduct,
2144
+ } = useQuery4(
2145
+ FrontierServiceQueries4.getProduct,
2035
2146
  { id: productId ?? "" },
2036
2147
  { staleTime: Infinity }
2037
2148
  );
@@ -2094,8 +2205,7 @@ import {
2094
2205
  EmptyState as EmptyState5,
2095
2206
  Flex as Flex17
2096
2207
  } from "@raystack/apsara";
2097
- import { useDebouncedState } from "@raystack/apsara/hooks";
2098
- import { useCallback as useCallback3, useMemo as useMemo2, useState as useState5 } from "react";
2208
+ import { useEffect as useEffect4, useCallback as useCallback5, useMemo as useMemo3, useState as useState6 } from "react";
2099
2209
 
2100
2210
  // admin/views/audit-logs/navbar.tsx
2101
2211
  import { DataTable as DataTable6, Flex as Flex12, Text as Text7, IconButton as IconButton2, Spinner } from "@raystack/apsara";
@@ -2126,8 +2236,8 @@ function CpuChipIcon(props) {
2126
2236
  );
2127
2237
  }
2128
2238
 
2129
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-pylH45qeTpKy/sdk/admin/components/navbar.module.css.js
2130
- var digest12 = "41630be772bab0247342cfed024e38a1742ff05898b92cec3779c56c05058603";
2239
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-JyxyceW9ZgP7/sdk/admin/components/navbar.module.css.js
2240
+ var digest12 = "e211084ed231efe7b451409faf4097bc4042a0f6cc5921eb2d7c9a0dd98f7b85";
2131
2241
  var css12 = `._navbar_641ya_1 {
2132
2242
  padding: var(--rs-space-4) var(--rs-space-7);
2133
2243
  border-bottom: 0.5px solid var(--rs-color-border-base-primary);
@@ -2156,8 +2266,8 @@ var css12 = `._navbar_641ya_1 {
2156
2266
  var navbar_module_css_default2 = { "navbar": "_navbar_641ya_1", "nav-chip": "_nav-chip_641ya_11", "navChip": "_nav-chip_641ya_11" };
2157
2267
 
2158
2268
  // admin/views/audit-logs/navbar.tsx
2159
- import { useCallback as useCallback2, useState as useState4 } from "react";
2160
- import { useQueryClient } from "@tanstack/react-query";
2269
+ import { useCallback as useCallback4, useState as useState5 } from "react";
2270
+ import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
2161
2271
 
2162
2272
  // admin/views/audit-logs/util.ts
2163
2273
  import { toJsonString } from "@bufbuild/protobuf";
@@ -2200,19 +2310,19 @@ var auditLogToJson = (auditLog) => {
2200
2310
  // admin/views/audit-logs/navbar.tsx
2201
2311
  import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
2202
2312
  var Navbar = ({ searchQuery, onExportCsv }) => {
2203
- const [showSearch, setShowSearch] = useState4(searchQuery ? true : false);
2204
- const [isDownloading, setIsDownloading] = useState4(false);
2205
- const queryClient = useQueryClient();
2206
- const toggleSearch = useCallback2(() => {
2313
+ const [showSearch, setShowSearch] = useState5(searchQuery ? true : false);
2314
+ const [isDownloading, setIsDownloading] = useState5(false);
2315
+ const queryClient = useQueryClient2();
2316
+ const toggleSearch = useCallback4(() => {
2207
2317
  setShowSearch((prev) => !prev);
2208
2318
  }, []);
2209
- const onSearchBlur = useCallback2((e) => {
2319
+ const onSearchBlur = useCallback4((e) => {
2210
2320
  const value = e.target.value;
2211
2321
  if (!value) {
2212
2322
  setShowSearch(false);
2213
2323
  }
2214
2324
  }, []);
2215
- const onDownloadClick = useCallback2(async () => {
2325
+ const onDownloadClick = useCallback4(async () => {
2216
2326
  if (!onExportCsv)
2217
2327
  return;
2218
2328
  try {
@@ -2267,8 +2377,8 @@ var Navbar = ({ searchQuery, onExportCsv }) => {
2267
2377
  };
2268
2378
  var navbar_default = Navbar;
2269
2379
 
2270
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-vsxrUMmMha1C/sdk/admin/views/audit-logs/audit-logs.module.css.js
2271
- var digest13 = "49d2c4f0843da9b0552e673cac8432b68fa1eb22e67723c5da06cfc429dd2dab";
2380
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-RtWedadD4j7K/sdk/admin/views/audit-logs/audit-logs.module.css.js
2381
+ var digest13 = "30c4e0875fbd9a64ac5595852595294d7d376934731486a9f7f03f5f3752c656";
2272
2382
  var css13 = `._table_vb46j_1 {
2273
2383
  height: auto;
2274
2384
  }
@@ -2371,8 +2481,8 @@ var audit_logs_module_css_default = { "table": "_table_vb46j_1", "table-empty":
2371
2481
  // admin/views/audit-logs/columns.tsx
2372
2482
  import { Badge, Flex as Flex14, Text as Text9 } from "@raystack/apsara";
2373
2483
 
2374
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-M2EIveZh3VUG/sdk/admin/views/audit-logs/audit-logs.module.css.js
2375
- var digest14 = "60b0ea23db782abf32348e8bd30220821dbfd3501f407b0e288ff7be39842f43";
2484
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-d1IeW3soJ4FQ/sdk/admin/views/audit-logs/audit-logs.module.css.js
2485
+ var digest14 = "bc3108c4dfa8694501d7549fa28728d5efc07782598bcd7de944532a80ff43a1";
2376
2486
  var css14 = `._table_vb46j_1 {
2377
2487
  height: auto;
2378
2488
  }
@@ -2621,7 +2731,7 @@ var getColumns5 = ({
2621
2731
  };
2622
2732
 
2623
2733
  // admin/views/audit-logs/index.tsx
2624
- import { useInfiniteQuery as useInfiniteQuery2 } from "@connectrpc/connect-query";
2734
+ import { useInfiniteQuery as useInfiniteQuery3 } from "@connectrpc/connect-query";
2625
2735
  import {
2626
2736
  AdminServiceQueries as AdminServiceQueries2
2627
2737
  } from "@raystack/proton/frontier";
@@ -2630,8 +2740,8 @@ import {
2630
2740
  import { Flex as Flex16, IconButton as IconButton4, SidePanel } from "@raystack/apsara";
2631
2741
  import { List as List3 } from "@raystack/apsara";
2632
2742
 
2633
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-fWO97XJEZ4pf/sdk/admin/views/audit-logs/audit-logs.module.css.js
2634
- var digest15 = "d5eafd69c40fc654a6399b1b0388bb0d181c24600208e307ceb9653fad967918";
2743
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-M4B83zMtzwXb/sdk/admin/views/audit-logs/audit-logs.module.css.js
2744
+ var digest15 = "29eecaa5e9acd9ab8fdf557a3076c93f0e328df772fa8219042ce9fa7129c5c1";
2635
2745
  var css15 = `._table_vb46j_1 {
2636
2746
  height: auto;
2637
2747
  }
@@ -2759,8 +2869,8 @@ function MapIcon(props) {
2759
2869
  // admin/views/audit-logs/sidepanel-log-dialog.tsx
2760
2870
  import { Dialog, IconButton as IconButton3, CodeBlock } from "@raystack/apsara";
2761
2871
 
2762
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-WeDlWRh4Nwpc/sdk/admin/views/audit-logs/audit-logs.module.css.js
2763
- var digest16 = "3ac76d159499c04e5bce0bc7d07e152f76a938beb9ea1011bec1efdd2c29fc48";
2872
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-6RbuKL06hPKs/sdk/admin/views/audit-logs/audit-logs.module.css.js
2873
+ var digest16 = "aa205c6c6dcfd9e7134ffe89bf129bb4d2b3f44532b131771927f37752ed91a3";
2764
2874
  var css16 = `._table_vb46j_1 {
2765
2875
  height: auto;
2766
2876
  }
@@ -2958,8 +3068,8 @@ function SidePanelLogDialog(props) {
2958
3068
  // admin/views/audit-logs/sidepanel-list-link.tsx
2959
3069
  import { Button, List } from "@raystack/apsara";
2960
3070
 
2961
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-BRlSdfrmcE9g/sdk/admin/views/audit-logs/audit-logs.module.css.js
2962
- var digest17 = "1aa97336c43e72be9f812f17863a3923000d538cf08975597dc28d897b155a85";
3071
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-YuJnAFMkX14W/sdk/admin/views/audit-logs/audit-logs.module.css.js
3072
+ var digest17 = "e11431245d2bd6c2133426dc6979ebff281eff284de47e66e6818b557150fa92";
2963
3073
  var css17 = `._table_vb46j_1 {
2964
3074
  height: auto;
2965
3075
  }
@@ -3095,8 +3205,8 @@ function SidepanelListItemLink({
3095
3205
  // admin/views/audit-logs/sidepanel-list-id.tsx
3096
3206
  import { CopyButton, Flex as Flex15, List as List2, Text as Text10, Tooltip } from "@raystack/apsara";
3097
3207
 
3098
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-sUTjxeSwFFA6/sdk/admin/views/audit-logs/audit-logs.module.css.js
3099
- var digest18 = "06ed9276362147e05881de818823a176ef533beeff0c6906612d08fe520fe88a";
3208
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-t0toUKP3br5Q/sdk/admin/views/audit-logs/audit-logs.module.css.js
3209
+ var digest18 = "30a53d8a6908707f2daf539ee2cdb90c20f159e8782407558b18bf6577782b22";
3100
3210
  var css18 = `._table_vb46j_1 {
3101
3211
  height: auto;
3102
3212
  }
@@ -3231,6 +3341,7 @@ var DEFAULT_ROLES = {
3231
3341
  ORG_VIEWER: "app_organization_viewer",
3232
3342
  PROJECT_VIEWER: "app_project_viewer"
3233
3343
  };
3344
+ var SHARED_QUERY_STALE_TIME = 30 * 1e3;
3234
3345
  var defaultTerminology = {
3235
3346
  organization: { singular: "Organization", plural: "Organizations" },
3236
3347
  project: { singular: "Project", plural: "Projects" },
@@ -3297,10 +3408,10 @@ var useAdminPaths = () => {
3297
3408
  };
3298
3409
 
3299
3410
  // admin/hooks/useOrganizationLookup.ts
3300
- import { useQuery as useQuery4 } from "@connectrpc/connect-query";
3301
- import { FrontierServiceQueries as FrontierServiceQueries4 } from "@raystack/proton/frontier";
3302
- var useOrganizationLookup = (orgId) => useQuery4(
3303
- FrontierServiceQueries4.getOrganization,
3411
+ import { useQuery as useQuery5 } from "@connectrpc/connect-query";
3412
+ import { FrontierServiceQueries as FrontierServiceQueries5 } from "@raystack/proton/frontier";
3413
+ var useOrganizationLookup = (orgId) => useQuery5(
3414
+ FrontierServiceQueries5.getOrganization,
3304
3415
  { id: orgId || "" },
3305
3416
  {
3306
3417
  enabled: !!orgId,
@@ -3445,7 +3556,7 @@ function SidePanelDetails({
3445
3556
  }
3446
3557
 
3447
3558
  // admin/views/audit-logs/index.tsx
3448
- import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
3559
+ import { useQueryClient as useQueryClient3 } from "@tanstack/react-query";
3449
3560
  import { Fragment as Fragment5, jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
3450
3561
  var NoAuditLogs = () => {
3451
3562
  return /* @__PURE__ */ jsx28(
@@ -3462,10 +3573,6 @@ var NoAuditLogs = () => {
3462
3573
  );
3463
3574
  };
3464
3575
  var DEFAULT_SORT2 = { name: "occurredAt", order: "desc" };
3465
- var INITIAL_QUERY2 = {
3466
- offset: 0,
3467
- limit: DEFAULT_PAGE_SIZE
3468
- };
3469
3576
  var TRANSFORM_OPTIONS = {
3470
3577
  fieldNameMapping: {
3471
3578
  occurredAt: "occurred_at",
@@ -3479,19 +3586,20 @@ var TRANSFORM_OPTIONS = {
3479
3586
  };
3480
3587
  function AuditLogsView({ appName, onExportCsv, onNavigate } = {}) {
3481
3588
  const t = useTerminology();
3482
- const queryClient = useQueryClient2();
3483
- const [tableQuery, setTableQuery] = useDebouncedState(
3484
- {
3485
- query: INITIAL_QUERY2,
3486
- rqlRequest: transformDataTableQueryToRQLRequest(
3487
- INITIAL_QUERY2,
3488
- TRANSFORM_OPTIONS
3489
- )
3490
- },
3491
- 200
3492
- );
3493
- const [sidePanelOpen, setSidePanelOpen] = useState5(false);
3494
- const [selectedAuditLog, setSelectedAuditLog] = useState5(
3589
+ const queryClient = useQueryClient3();
3590
+ const {
3591
+ tableQuery,
3592
+ rqlQuery,
3593
+ onTableQueryChange
3594
+ } = useServerTableQuery({
3595
+ defaultSort: DEFAULT_SORT2,
3596
+ transformOptions: TRANSFORM_OPTIONS
3597
+ });
3598
+ useEffect4(() => {
3599
+ queryClient.setQueryData(AUDIT_LOG_QUERY_KEY, rqlQuery);
3600
+ }, [queryClient, rqlQuery]);
3601
+ const [sidePanelOpen, setSidePanelOpen] = useState6(false);
3602
+ const [selectedAuditLog, setSelectedAuditLog] = useState6(
3495
3603
  null
3496
3604
  );
3497
3605
  const {
@@ -3502,14 +3610,14 @@ function AuditLogsView({ appName, onExportCsv, onNavigate } = {}) {
3502
3610
  error,
3503
3611
  isError,
3504
3612
  hasNextPage
3505
- } = useInfiniteQuery2(
3613
+ } = useInfiniteQuery3(
3506
3614
  AdminServiceQueries2.listAuditRecords,
3507
- { query: tableQuery.rqlRequest },
3615
+ { query: rqlQuery },
3508
3616
  {
3509
3617
  pageParamKey: "query",
3510
3618
  getNextPageParam: (lastPage) => getConnectNextPageParam(
3511
3619
  lastPage,
3512
- { query: tableQuery.rqlRequest },
3620
+ { query: rqlQuery },
3513
3621
  "auditRecords"
3514
3622
  ),
3515
3623
  staleTime: 0,
@@ -3519,35 +3627,14 @@ function AuditLogsView({ appName, onExportCsv, onNavigate } = {}) {
3519
3627
  }
3520
3628
  );
3521
3629
  const data = infiniteData?.pages?.flatMap((page) => page?.auditRecords || []) || [];
3522
- const onTableQueryChange = useCallback3(
3523
- (query) => {
3524
- const updatedQuery = {
3525
- ...query,
3526
- offset: 0,
3527
- limit: query.limit || DEFAULT_PAGE_SIZE
3528
- };
3529
- const updatedRQLRequest = transformDataTableQueryToRQLRequest(
3530
- updatedQuery,
3531
- TRANSFORM_OPTIONS
3532
- );
3533
- queryClient.setQueryData(AUDIT_LOG_QUERY_KEY, updatedRQLRequest);
3534
- setTableQuery({
3535
- query: updatedQuery,
3536
- rqlRequest: updatedRQLRequest
3537
- });
3538
- },
3539
- [queryClient]
3540
- );
3541
- const handleLoadMore = async () => {
3542
- try {
3543
- if (!hasNextPage)
3544
- return;
3545
- await fetchNextPage();
3546
- } catch (error2) {
3547
- console.error("Error loading more audit logs:", error2);
3548
- }
3549
- };
3550
- const columns = useMemo2(
3630
+ const handleLoadMore = useLoadMore({
3631
+ hasNextPage,
3632
+ isFetchingNextPage,
3633
+ isError,
3634
+ fetchNextPage,
3635
+ label: "audit logs"
3636
+ });
3637
+ const columns = useMemo3(
3551
3638
  () => getColumns5({
3552
3639
  groupCountMap: infiniteData ? getGroupCountMapFromFirstPage(infiniteData) : {},
3553
3640
  t
@@ -3555,7 +3642,7 @@ function AuditLogsView({ appName, onExportCsv, onNavigate } = {}) {
3555
3642
  [infiniteData, t]
3556
3643
  );
3557
3644
  const loading = isLoading || isFetchingNextPage;
3558
- const onRowClick = useCallback3((row) => {
3645
+ const onRowClick = useCallback5((row) => {
3559
3646
  setSelectedAuditLog((_selectedLog) => {
3560
3647
  if (_selectedLog?.id === row.id)
3561
3648
  setSidePanelOpen((_value) => !_value);
@@ -3584,7 +3671,7 @@ function AuditLogsView({ appName, onExportCsv, onNavigate } = {}) {
3584
3671
  /* @__PURE__ */ jsx28(
3585
3672
  DataTable7,
3586
3673
  {
3587
- query: tableQuery.query,
3674
+ query: tableQuery,
3588
3675
  columns,
3589
3676
  data,
3590
3677
  isLoading: loading,
@@ -3594,7 +3681,7 @@ function AuditLogsView({ appName, onExportCsv, onNavigate } = {}) {
3594
3681
  onLoadMore: handleLoadMore,
3595
3682
  onRowClick,
3596
3683
  children: /* @__PURE__ */ jsxs19(Flex17, { direction: "column", style: { width: "100%" }, children: [
3597
- /* @__PURE__ */ jsx28(navbar_default, { searchQuery: tableQuery.query.search, onExportCsv }),
3684
+ /* @__PURE__ */ jsx28(navbar_default, { searchQuery: tableQuery.search, onExportCsv }),
3598
3685
  /* @__PURE__ */ jsx28(DataTable7.Toolbar, {}),
3599
3686
  /* @__PURE__ */ jsxs19(Flex17, { className: audit_logs_module_css_default["table-content-container"], children: [
3600
3687
  /* @__PURE__ */ jsx28(
@@ -3631,8 +3718,8 @@ import { DataTable as DataTable8, EmptyState as EmptyState6, Flex as Flex18 } fr
3631
3718
  // admin/views/admins/columns.tsx
3632
3719
  import { Button as Button2 } from "@raystack/apsara";
3633
3720
 
3634
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-EVebhEPABqGx/sdk/admin/views/admins/admins.module.css.js
3635
- var digest19 = "ef309006f5e9e704b5bfc70ba927627d9909c6284c0cd23291fd6628a59182b8";
3721
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-BywJ0Ey0kI4h/sdk/admin/views/admins/admins.module.css.js
3722
+ var digest19 = "2537f93b2e17654724e457320791b79882f934e4635e0b0713d6cd1d55f435a7";
3636
3723
  var css19 = `._tableRoot_1tmha_1 {
3637
3724
  width: 100%;
3638
3725
  }
@@ -3727,8 +3814,8 @@ var getColumns6 = ({ onNavigateToOrg, t } = {}) => {
3727
3814
  ];
3728
3815
  };
3729
3816
 
3730
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-WcRDQYDqaeRU/sdk/admin/views/admins/admins.module.css.js
3731
- var digest20 = "5cd72e71043cbf53835fc5b3e7ee4bdaad1e4bae5b647fd8be2ea3b6fcb9c299";
3817
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-fwomBNUnCZ90/sdk/admin/views/admins/admins.module.css.js
3818
+ var digest20 = "8c33fcd4d93b0b594b6ce3d27d74075305f88695beec0002d2c123e40a49e703";
3732
3819
  var css20 = `._tableRoot_1tmha_1 {
3733
3820
  width: 100%;
3734
3821
  }
@@ -3760,7 +3847,7 @@ var css20 = `._tableRoot_1tmha_1 {
3760
3847
  var admins_module_css_default2 = { "tableRoot": "_tableRoot_1tmha_1", "tableWrapper": "_tableWrapper_1tmha_5", "header": "_header_1tmha_9", "first-column": "_first-column_1tmha_14", "firstColumn": "_first-column_1tmha_14" };
3761
3848
 
3762
3849
  // admin/views/admins/index.tsx
3763
- import { useQuery as useQuery5 } from "@connectrpc/connect-query";
3850
+ import { useQuery as useQuery6 } from "@connectrpc/connect-query";
3764
3851
  import { AdminServiceQueries as AdminServiceQueries3 } from "@raystack/proton/frontier";
3765
3852
  import { jsx as jsx30, jsxs as jsxs20 } from "react/jsx-runtime";
3766
3853
  var pageHeader = {
@@ -3784,7 +3871,7 @@ function AdminsView({ onNavigateToOrg, icon } = {}) {
3784
3871
  isLoading,
3785
3872
  error,
3786
3873
  isError
3787
- } = useQuery5(AdminServiceQueries3.listPlatformUsers, {}, {
3874
+ } = useQuery6(AdminServiceQueries3.listPlatformUsers, {}, {
3788
3875
  staleTime: Infinity
3789
3876
  });
3790
3877
  const columns = getColumns6({ onNavigateToOrg, t });
@@ -3839,8 +3926,8 @@ import { EmptyState as EmptyState7, Flex as Flex20, DataTable as DataTable9, Dra
3839
3926
  // admin/views/plans/columns.tsx
3840
3927
  import { Text as Text11 } from "@raystack/apsara";
3841
3928
 
3842
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-XD4GhTGqKAPG/sdk/admin/views/plans/plans.module.css.js
3843
- var digest21 = "6563e9d7bf2be005da0df9ddf3632da3b6965aa70830d5c4bb30721c9c290edf";
3929
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-sv6U5FbLopTy/sdk/admin/views/plans/plans.module.css.js
3930
+ var digest21 = "a7aaafe2ea896d0c29c41e0b3859e7a4d37f9fbe0bb9d8b0911e0fb887c41f14";
3844
3931
  var css21 = `._tableRoot_1akba_1 {
3845
3932
  width: 100%;
3846
3933
  }
@@ -3931,8 +4018,8 @@ var getColumns7 = ({ onSelectPlan } = {}) => {
3931
4018
  ];
3932
4019
  };
3933
4020
 
3934
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-hQdFaJA3ww1j/sdk/admin/views/plans/plans.module.css.js
3935
- var digest22 = "cd2b9f70e055e0714840fefe4db5193d0db62e64fdc99daf2ec32b0e7d3da079";
4021
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-GsEL0iN74bd5/sdk/admin/views/plans/plans.module.css.js
4022
+ var digest22 = "63e38744cfb67b3f97d1aab5f81d309b8f6d07e2e8290a1cba8046891e3655e6";
3936
4023
  var css22 = `._tableRoot_1akba_1 {
3937
4024
  width: 100%;
3938
4025
  }
@@ -3976,8 +4063,8 @@ var css22 = `._tableRoot_1akba_1 {
3976
4063
  var plans_module_css_default2 = { "tableRoot": "_tableRoot_1akba_1", "tableWrapper": "_tableWrapper_1akba_4", "table": "_table_1akba_1", "header": "_header_1akba_12", "first-column": "_first-column_1akba_17", "firstColumn": "_first-column_1akba_17", "sheetContent": "_sheetContent_1akba_21", "sheetContentBody": "_sheetContentBody_1akba_26" };
3977
4064
 
3978
4065
  // admin/views/plans/index.tsx
3979
- import { useQuery as useQuery6 } from "@connectrpc/connect-query";
3980
- import { FrontierServiceQueries as FrontierServiceQueries5 } from "@raystack/proton/frontier";
4066
+ import { useQuery as useQuery7 } from "@connectrpc/connect-query";
4067
+ import { FrontierServiceQueries as FrontierServiceQueries6 } from "@raystack/proton/frontier";
3981
4068
 
3982
4069
  // admin/views/plans/details.tsx
3983
4070
  import { Flex as Flex19, Text as Text12, Grid as Grid3 } from "@raystack/apsara";
@@ -4016,7 +4103,7 @@ function PlansView({
4016
4103
  isLoading: isPlansLoading,
4017
4104
  error,
4018
4105
  isError
4019
- } = useQuery6(FrontierServiceQueries5.listPlans, {}, {
4106
+ } = useQuery7(FrontierServiceQueries6.listPlans, {}, {
4020
4107
  staleTime: Infinity
4021
4108
  });
4022
4109
  const plans = plansResponse?.plans || [];
@@ -4084,8 +4171,8 @@ import { Flex as Flex21, DataTable as DataTable10, EmptyState as EmptyState8 } f
4084
4171
  // admin/views/webhooks/webhooks/columns.tsx
4085
4172
  import { Text as Text13 } from "@raystack/apsara";
4086
4173
 
4087
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-LDHF9v9ktuME/sdk/admin/views/webhooks/webhooks/webhooks.module.css.js
4088
- var digest23 = "55eb7caf6f8cdec81af4fa0e9c9a470a51e57fc5725774a2f75debb696b8e97d";
4174
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-OLg4E130b22P/sdk/admin/views/webhooks/webhooks/webhooks.module.css.js
4175
+ var digest23 = "398a6bfdb9d0c49afb5f7b9b0e0ddf02ff6ce4c24ebc39a9e23795705380fabe";
4089
4176
  var css23 = `._tableRoot_iq3pc_1 {
4090
4177
  width: 100%;
4091
4178
  }
@@ -4166,8 +4253,8 @@ var getColumns8 = () => {
4166
4253
  ];
4167
4254
  };
4168
4255
 
4169
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-IGqyiYgXXlyu/sdk/admin/views/webhooks/webhooks/webhooks.module.css.js
4170
- var digest24 = "56d642be17ccea5ade3778fe78710766e538110fc365bbc43cee37be8c27800b";
4256
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-0dTFe19eeZCf/sdk/admin/views/webhooks/webhooks/webhooks.module.css.js
4257
+ var digest24 = "d667b5dcff65daca5d733b9b3c6989b0bc3012e1131e700165642601275a0f38";
4171
4258
  var css24 = `._tableRoot_iq3pc_1 {
4172
4259
  width: 100%;
4173
4260
  }
@@ -4212,10 +4299,10 @@ var css24 = `._tableRoot_iq3pc_1 {
4212
4299
  var webhooks_module_css_default2 = { "tableRoot": "_tableRoot_iq3pc_1", "tableWrapper": "_tableWrapper_iq3pc_5", "table": "_table_iq3pc_1", "first-column": "_first-column_iq3pc_13", "firstColumn": "_first-column_iq3pc_13", "stateColumn": "_stateColumn_iq3pc_17", "dateColumn": "_dateColumn_iq3pc_21", "header": "_header_iq3pc_25" };
4213
4300
 
4214
4301
  // admin/views/webhooks/webhooks/hooks/useWebhookQueries.ts
4215
- import { useQuery as useQuery7 } from "@connectrpc/connect-query";
4302
+ import { useQuery as useQuery8 } from "@connectrpc/connect-query";
4216
4303
  import { AdminServiceQueries as AdminServiceQueries4 } from "@raystack/proton/frontier";
4217
4304
  function useWebhookQueries() {
4218
- const listWebhooks = useQuery7(
4305
+ const listWebhooks = useQuery8(
4219
4306
  AdminServiceQueries4.listWebhooks,
4220
4307
  {},
4221
4308
  {
@@ -4279,10 +4366,10 @@ function WebhooksView({ icon } = {}) {
4279
4366
 
4280
4367
  // admin/views/preferences/PreferencesView.tsx
4281
4368
  import { Flex as Flex24, EmptyState as EmptyState10 } from "@raystack/apsara";
4282
- import { createQueryOptions, useTransport as useTransport2 } from "@connectrpc/connect-query";
4369
+ import { createQueryOptions, useTransport as useTransport3 } from "@connectrpc/connect-query";
4283
4370
  import {
4284
4371
  AdminServiceQueries as AdminServiceQueries6,
4285
- FrontierServiceQueries as FrontierServiceQueries6
4372
+ FrontierServiceQueries as FrontierServiceQueries7
4286
4373
  } from "@raystack/proton/frontier";
4287
4374
  import { useQueries } from "@tanstack/react-query";
4288
4375
 
@@ -4292,8 +4379,8 @@ import { EmptyState as EmptyState9, DataTable as DataTable11, Flex as Flex22 } f
4292
4379
  // admin/views/preferences/columns.tsx
4293
4380
  import { Text as Text14 } from "@raystack/apsara";
4294
4381
 
4295
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-TFDJu5pGeTsL/sdk/admin/views/preferences/preferences.module.css.js
4296
- var digest25 = "d837db0db127d68f9320e571544e1d40025a29acf4a49839e01a70e3523b6efa";
4382
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-zR5BuAMq5kZk/sdk/admin/views/preferences/preferences.module.css.js
4383
+ var digest25 = "f3853ca8031bfcaf64e38dfa47a806510643a49985c8b5add020e403d81c1342";
4297
4384
  var css25 = `._tableRoot_hre5m_1 {
4298
4385
  width: 100%;
4299
4386
  }
@@ -4384,8 +4471,8 @@ var getColumns9 = ({
4384
4471
  ];
4385
4472
  };
4386
4473
 
4387
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-E9OAgbQ9Ggo6/sdk/admin/views/preferences/preferences.module.css.js
4388
- var digest26 = "baca89eb27089ce85d108908c5c8259ce68b194d0075db273ecb763ad33501c2";
4474
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-f819ruS2dEPZ/sdk/admin/views/preferences/preferences.module.css.js
4475
+ var digest26 = "dcdcd5cca1f4ac470b3d84bb29e78729e967735f5f7bbf5126b821c0bff1ba8c";
4389
4476
  var css26 = `._tableRoot_hre5m_1 {
4390
4477
  width: 100%;
4391
4478
  }
@@ -4488,7 +4575,7 @@ import {
4488
4575
  Input,
4489
4576
  toastManager
4490
4577
  } from "@raystack/apsara";
4491
- import { useCallback as useCallback4, useEffect as useEffect3, useState as useState6 } from "react";
4578
+ import { useCallback as useCallback6, useEffect as useEffect5, useState as useState7 } from "react";
4492
4579
 
4493
4580
  // ../node_modules/.pnpm/react-loading-skeleton@3.5.0_react@19.2.4/node_modules/react-loading-skeleton/dist/index.js
4494
4581
  import React4 from "react";
@@ -4566,42 +4653,11 @@ function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, con
4566
4653
  }
4567
4654
 
4568
4655
  // admin/views/preferences/details.tsx
4569
- import { useMutation, createConnectQueryKey, useTransport } from "@connectrpc/connect-query";
4570
-
4571
- // utils/error.ts
4572
- import { Code, ConnectError } from "@connectrpc/connect";
4573
- var DEFAULT_ERROR_MESSAGE = "Something went wrong";
4574
- function handleConnectError(error, handlers) {
4575
- const connectError = error instanceof ConnectError ? error : new ConnectError(
4576
- typeof error === "string" ? error : error instanceof Error ? error.message : DEFAULT_ERROR_MESSAGE
4577
- );
4578
- const defaultHandler = handlers?.Default ?? ((err) => console.error(err.message));
4579
- switch (connectError.code) {
4580
- case Code.AlreadyExists:
4581
- handlers?.AlreadyExists ? handlers.AlreadyExists(connectError) : defaultHandler(connectError);
4582
- break;
4583
- case Code.InvalidArgument:
4584
- handlers?.InvalidArgument ? handlers.InvalidArgument(connectError) : defaultHandler(connectError);
4585
- break;
4586
- case Code.PermissionDenied:
4587
- handlers?.PermissionDenied ? handlers.PermissionDenied(connectError) : defaultHandler(connectError);
4588
- break;
4589
- case Code.NotFound:
4590
- handlers?.NotFound ? handlers.NotFound(connectError) : defaultHandler(connectError);
4591
- break;
4592
- case Code.FailedPrecondition:
4593
- handlers?.FailedPrecondition ? handlers.FailedPrecondition(connectError) : defaultHandler(connectError);
4594
- break;
4595
- default:
4596
- defaultHandler(connectError);
4597
- }
4598
- }
4599
-
4600
- // admin/views/preferences/details.tsx
4656
+ import { useMutation as useMutation2, createConnectQueryKey as createConnectQueryKey2, useTransport as useTransport2 } from "@connectrpc/connect-query";
4601
4657
  import { AdminServiceQueries as AdminServiceQueries5, CreatePreferencesRequestSchema } from "@raystack/proton/frontier";
4602
4658
  import { PreferenceTrait_InputType } from "@raystack/proton/frontier";
4603
- import { useQueryClient as useQueryClient3 } from "@tanstack/react-query";
4604
- import { create as create2 } from "@bufbuild/protobuf";
4659
+ import { useQueryClient as useQueryClient4 } from "@tanstack/react-query";
4660
+ import { create as create3 } from "@bufbuild/protobuf";
4605
4661
  import { jsx as jsx38, jsxs as jsxs25 } from "react/jsx-runtime";
4606
4662
  function PreferenceValue({ value, trait, onChange }) {
4607
4663
  if (trait.inputType === PreferenceTrait_InputType.CHECKBOX) {
@@ -4634,15 +4690,15 @@ function PreferenceDetails({
4634
4690
  isLoading,
4635
4691
  onCloseDetail
4636
4692
  }) {
4637
- const [value, setValue] = useState6("");
4638
- const [originalValue, setOriginalValue] = useState6("");
4693
+ const [value, setValue] = useState7("");
4694
+ const [originalValue, setOriginalValue] = useState7("");
4639
4695
  const preference = preferences?.find((p) => p.name === name);
4640
4696
  const trait = traits?.find((t) => t.name === name);
4641
- const queryClient = useQueryClient3();
4642
- const transport = useTransport();
4643
- const { mutateAsync: createPreferences, isPending: isActionLoading } = useMutation(AdminServiceQueries5.createPreferences, {
4697
+ const queryClient = useQueryClient4();
4698
+ const transport = useTransport2();
4699
+ const { mutateAsync: createPreferences, isPending: isActionLoading } = useMutation2(AdminServiceQueries5.createPreferences, {
4644
4700
  onSuccess: (data) => {
4645
- const queryKey = createConnectQueryKey({
4701
+ const queryKey = createConnectQueryKey2({
4646
4702
  schema: AdminServiceQueries5.listPreferences,
4647
4703
  transport,
4648
4704
  input: {},
@@ -4678,7 +4734,7 @@ function PreferenceDetails({
4678
4734
  { name: trait?.title ?? name }
4679
4735
  ]
4680
4736
  };
4681
- useEffect3(() => {
4737
+ useEffect5(() => {
4682
4738
  const v = preference?.value !== "" && preference?.value !== void 0 ? preference?.value : trait?.default;
4683
4739
  const newValue = v || "";
4684
4740
  setValue(newValue);
@@ -4719,9 +4775,9 @@ function PreferenceDetails({
4719
4775
  value: formatTimestamp(preference?.updatedAt, `${DATE_FORMAT} hh:mm:ss A`)
4720
4776
  }
4721
4777
  ];
4722
- const onSave = useCallback4(async () => {
4778
+ const onSave = useCallback6(async () => {
4723
4779
  try {
4724
- await createPreferences(create2(CreatePreferencesRequestSchema, {
4780
+ await createPreferences(create3(CreatePreferencesRequestSchema, {
4725
4781
  preferences: [
4726
4782
  {
4727
4783
  name,
@@ -4807,7 +4863,7 @@ function PreferencesView({
4807
4863
  onSelectPreference,
4808
4864
  icon
4809
4865
  } = {}) {
4810
- const transport = useTransport2();
4866
+ const transport = useTransport3();
4811
4867
  const [preferencesQuery, traitsQuery] = useQueries({
4812
4868
  queries: [
4813
4869
  {
@@ -4815,7 +4871,7 @@ function PreferencesView({
4815
4871
  staleTime: Infinity
4816
4872
  },
4817
4873
  {
4818
- ...createQueryOptions(FrontierServiceQueries6.describePreferences, {}, { transport }),
4874
+ ...createQueryOptions(FrontierServiceQueries7.describePreferences, {}, { transport }),
4819
4875
  staleTime: Infinity
4820
4876
  }
4821
4877
  ]
@@ -4873,8 +4929,8 @@ import {
4873
4929
  Spinner as Spinner2
4874
4930
  } from "@raystack/apsara";
4875
4931
 
4876
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-Q2ZeGtYqr9C3/sdk/admin/components/navbar.module.css.js
4877
- var digest27 = "74975cb9fd8b21af648fffcdacc5cd42ceadf5269687d2940e5d1dc65d413e0a";
4932
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-XrRyvuaQZ6JB/sdk/admin/components/navbar.module.css.js
4933
+ var digest27 = "ee6e1167e1d95c29f615c818e49da6f7e77deacbc2d367d8a028e0b53694129e";
4878
4934
  var css27 = `._navbar_641ya_1 {
4879
4935
  padding: var(--rs-space-4) var(--rs-space-7);
4880
4936
  border-bottom: 0.5px solid var(--rs-color-border-base-primary);
@@ -4928,10 +4984,10 @@ function UsersIcon(props) {
4928
4984
  var UsersIcon_default = UsersIcon;
4929
4985
 
4930
4986
  // admin/views/users/list/navbar.tsx
4931
- import { useState as useState8 } from "react";
4987
+ import { useState as useState9 } from "react";
4932
4988
 
4933
4989
  // admin/views/users/list/invite-users.tsx
4934
- import { useMemo as useMemo3, useState as useState7, useEffect as useEffect4 } from "react";
4990
+ import { useMemo as useMemo4, useState as useState8, useEffect as useEffect6 } from "react";
4935
4991
  import {
4936
4992
  Button as Button4,
4937
4993
  Dialog as Dialog2,
@@ -8988,8 +9044,8 @@ var NEVER = INVALID;
8988
9044
  import { Controller, useForm } from "react-hook-form";
8989
9045
  import { zodResolver } from "@hookform/resolvers/zod";
8990
9046
 
8991
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-g17laF137SfN/sdk/admin/views/users/list/invite-users.module.css.js
8992
- var digest28 = "2129c2aa69316aecc47fd959883902af29768c3ec781aa8f2759e134b88d33db";
9047
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-9Xh2JX9X5FGV/sdk/admin/views/users/list/invite-users.module.css.js
9048
+ var digest28 = "0c7aff3e1a4d9d18bc8051bb4b37d9444ae017445ec91c5858491915c2ff3ae9";
8993
9049
  var css28 = `._invite-users-dialog-body_daxb4_1 {
8994
9050
  display: flex;
8995
9051
  flex-direction: column;
@@ -9016,14 +9072,14 @@ var css28 = `._invite-users-dialog-body_daxb4_1 {
9016
9072
  var invite_users_module_css_default = { "invite-users-dialog-body": "_invite-users-dialog-body_daxb4_1", "inviteUsersDialogBody": "_invite-users-dialog-body_daxb4_1", "invite-users-emails-textarea": "_invite-users-emails-textarea_daxb4_8", "inviteUsersEmailsTextarea": "_invite-users-emails-textarea_daxb4_8" };
9017
9073
 
9018
9074
  // admin/views/users/list/invite-users.tsx
9019
- import { useMutation as useMutation2, useQuery as useQuery8 } from "@connectrpc/connect-query";
9075
+ import { useMutation as useMutation3, useQuery as useQuery9 } from "@connectrpc/connect-query";
9020
9076
  import {
9021
9077
  AdminServiceQueries as AdminServiceQueries7,
9022
9078
  SearchOrganizationsRequestSchema,
9023
- FrontierServiceQueries as FrontierServiceQueries7,
9079
+ FrontierServiceQueries as FrontierServiceQueries8,
9024
9080
  ListRolesRequestSchema
9025
9081
  } from "@raystack/proton/frontier";
9026
- import { create as create3 } from "@bufbuild/protobuf";
9082
+ import { create as create4 } from "@bufbuild/protobuf";
9027
9083
  import { jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
9028
9084
  var createInviteSchema = (t) => objectType({
9029
9085
  role: stringType().min(1, { message: "Role is required" }),
@@ -9038,15 +9094,16 @@ var createInviteSchema = (t) => objectType({
9038
9094
  });
9039
9095
  var InviteUser = () => {
9040
9096
  const t = useTerminology();
9041
- const [open, onOpenChange] = useState7(false);
9097
+ const [open, onOpenChange] = useState8(false);
9042
9098
  const {
9043
9099
  data: organizations,
9044
9100
  isLoading: isOrganizationsLoading,
9045
9101
  error: organizationsError
9046
- } = useQuery8(
9102
+ } = useQuery9(
9047
9103
  AdminServiceQueries7.searchOrganizations,
9048
- create3(SearchOrganizationsRequestSchema, { query: {} }),
9104
+ create4(SearchOrganizationsRequestSchema, { query: {} }),
9049
9105
  {
9106
+ enabled: open,
9050
9107
  select: (data) => data?.organizations || []
9051
9108
  }
9052
9109
  );
@@ -9054,29 +9111,30 @@ var InviteUser = () => {
9054
9111
  data: roles,
9055
9112
  isLoading: isRolesLoading,
9056
9113
  error: rolesError
9057
- } = useQuery8(
9058
- FrontierServiceQueries7.listRoles,
9059
- create3(ListRolesRequestSchema, { scopes: [SCOPES.ORG] }),
9114
+ } = useQuery9(
9115
+ FrontierServiceQueries8.listRoles,
9116
+ create4(ListRolesRequestSchema, { scopes: [SCOPES.ORG] }),
9060
9117
  {
9118
+ enabled: open,
9061
9119
  select: (data) => data?.roles || []
9062
9120
  }
9063
9121
  );
9064
9122
  const isLoading = isRolesLoading || isOrganizationsLoading;
9065
- useEffect4(() => {
9123
+ useEffect6(() => {
9066
9124
  if (organizationsError) {
9067
9125
  console.error("Failed to fetch organizations:", organizationsError);
9068
9126
  }
9069
9127
  }, [organizationsError]);
9070
- useEffect4(() => {
9128
+ useEffect6(() => {
9071
9129
  if (rolesError) {
9072
9130
  console.error("Failed to fetch roles:", rolesError);
9073
9131
  }
9074
9132
  }, [rolesError]);
9075
- const defaultRoleId = useMemo3(
9133
+ const defaultRoleId = useMemo4(
9076
9134
  () => roles?.find((role) => role.name === DEFAULT_ROLES.ORG_VIEWER)?.id,
9077
9135
  [roles]
9078
9136
  );
9079
- const inviteSchema2 = useMemo3(() => createInviteSchema(t), [t]);
9137
+ const inviteSchema2 = useMemo4(() => createInviteSchema(t), [t]);
9080
9138
  const {
9081
9139
  formState: { errors, isSubmitting },
9082
9140
  handleSubmit,
@@ -9088,8 +9146,8 @@ var InviteUser = () => {
9088
9146
  role: defaultRoleId
9089
9147
  }
9090
9148
  });
9091
- const { mutateAsync: inviteUser } = useMutation2(
9092
- FrontierServiceQueries7.createOrganizationInvitation,
9149
+ const { mutateAsync: inviteUser } = useMutation3(
9150
+ FrontierServiceQueries8.createOrganizationInvitation,
9093
9151
  {
9094
9152
  onSuccess: (data) => {
9095
9153
  const invitedCount = data?.invitations?.length ?? 0;
@@ -9256,8 +9314,8 @@ var InviteUser = () => {
9256
9314
  // admin/views/users/list/navbar.tsx
9257
9315
  import { Fragment as Fragment6, jsx as jsx42, jsxs as jsxs27 } from "react/jsx-runtime";
9258
9316
  var Navbar2 = ({ searchQuery, onExportUsers }) => {
9259
- const [showSearch, setShowSearch] = useState8(searchQuery ? true : false);
9260
- const [isDownloading, setIsDownloading] = useState8(false);
9317
+ const [showSearch, setShowSearch] = useState9(searchQuery ? true : false);
9318
+ const [isDownloading, setIsDownloading] = useState9(false);
9261
9319
  function toggleSearch() {
9262
9320
  setShowSearch((prev) => !prev);
9263
9321
  }
@@ -9323,8 +9381,8 @@ var Navbar2 = ({ searchQuery, onExportUsers }) => {
9323
9381
  };
9324
9382
  var navbar_default2 = Navbar2;
9325
9383
 
9326
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-T97SqzN3atz6/sdk/admin/views/users/list/list.module.css.js
9327
- var digest29 = "62921d0860765d38d8b641e323ad3ccf5b2e6dcc6841be838e9d0a908e94792d";
9384
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-iQTSgK0lENam/sdk/admin/views/users/list/list.module.css.js
9385
+ var digest29 = "34dd0f9b65db600842063fd4cde00f59176446f3cb705163f17d68f25c6b66b2";
9328
9386
  var css29 = `._table_1jm7t_1 {
9329
9387
  height: auto;
9330
9388
  }
@@ -9384,8 +9442,8 @@ import {
9384
9442
  Text as Text17
9385
9443
  } from "@raystack/apsara";
9386
9444
 
9387
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-zbGTH4Hd5qUa/sdk/admin/views/users/list/list.module.css.js
9388
- var digest30 = "ea144f7ae2d6fbbc355436640beae225c26bdfdeea6d601584a573fbbc6d30d9";
9445
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-AsMZ3M6dBGlh/sdk/admin/views/users/list/list.module.css.js
9446
+ var digest30 = "acb92ae1c2212e1e58f499384b1cd2aa3b860a84cf9912dadd7b1c3229115c46";
9389
9447
  var css30 = `._table_1jm7t_1 {
9390
9448
  height: auto;
9391
9449
  }
@@ -9527,9 +9585,8 @@ var getColumns10 = ({
9527
9585
  };
9528
9586
 
9529
9587
  // admin/views/users/list/list.tsx
9530
- import { useInfiniteQuery as useInfiniteQuery3 } from "@connectrpc/connect-query";
9588
+ import { useInfiniteQuery as useInfiniteQuery4 } from "@connectrpc/connect-query";
9531
9589
  import { AdminServiceQueries as AdminServiceQueries8 } from "@raystack/proton/frontier";
9532
- import { useDebouncedState as useDebouncedState2 } from "@raystack/apsara/hooks";
9533
9590
  import { Fragment as Fragment7, jsx as jsx44, jsxs as jsxs29 } from "react/jsx-runtime";
9534
9591
  var NoUsers = () => {
9535
9592
  const t = useTerminology();
@@ -9547,20 +9604,19 @@ var NoUsers = () => {
9547
9604
  );
9548
9605
  };
9549
9606
  var DEFAULT_SORT3 = { name: "createdAt", order: "desc" };
9550
- var INITIAL_QUERY3 = {
9551
- offset: 0,
9552
- limit: DEFAULT_PAGE_SIZE
9553
- };
9554
9607
  var UsersList = ({ onExportUsers, onNavigateToUser }) => {
9555
9608
  const t = useTerminology();
9556
- const [tableQuery, setTableQuery] = useDebouncedState2(
9557
- INITIAL_QUERY3,
9558
- 200
9559
- );
9560
- const query = transformDataTableQueryToRQLRequest(tableQuery, {
9561
- fieldNameMapping: {
9562
- createdAt: "created_at",
9563
- updatedAt: "updated_at"
9609
+ const {
9610
+ tableQuery,
9611
+ rqlQuery: query,
9612
+ onTableQueryChange
9613
+ } = useServerTableQuery({
9614
+ defaultSort: DEFAULT_SORT3,
9615
+ transformOptions: {
9616
+ fieldNameMapping: {
9617
+ createdAt: "created_at",
9618
+ updatedAt: "updated_at"
9619
+ }
9564
9620
  }
9565
9621
  });
9566
9622
  const {
@@ -9568,9 +9624,10 @@ var UsersList = ({ onExportUsers, onNavigateToUser }) => {
9568
9624
  isLoading,
9569
9625
  isFetchingNextPage,
9570
9626
  fetchNextPage,
9627
+ hasNextPage,
9571
9628
  error,
9572
9629
  isError
9573
- } = useInfiniteQuery3(
9630
+ } = useInfiniteQuery4(
9574
9631
  AdminServiceQueries8.searchUsers,
9575
9632
  { query },
9576
9633
  {
@@ -9584,20 +9641,13 @@ var UsersList = ({ onExportUsers, onNavigateToUser }) => {
9584
9641
  );
9585
9642
  const data = infiniteData?.pages?.flatMap((page) => page?.users || []) || [];
9586
9643
  const groupCountMap = infiniteData ? getGroupCountMapFromFirstPage(infiniteData) : {};
9587
- const onTableQueryChange = (newQuery) => {
9588
- setTableQuery({
9589
- ...newQuery,
9590
- offset: 0,
9591
- limit: newQuery.limit || DEFAULT_PAGE_SIZE
9592
- });
9593
- };
9594
- const handleLoadMore = async () => {
9595
- try {
9596
- await fetchNextPage();
9597
- } catch (error2) {
9598
- console.error("Error loading more users:", error2);
9599
- }
9600
- };
9644
+ const handleLoadMore = useLoadMore({
9645
+ hasNextPage,
9646
+ isFetchingNextPage,
9647
+ isError,
9648
+ fetchNextPage,
9649
+ label: "users"
9650
+ });
9601
9651
  const columns = getColumns10({ groupCountMap, onNavigateToUser });
9602
9652
  const loading = isLoading || isFetchingNextPage;
9603
9653
  const onRowClick = (row) => {
@@ -9658,7 +9708,7 @@ var UsersList = ({ onExportUsers, onNavigateToUser }) => {
9658
9708
  import { Flex as Flex38, EmptyState as EmptyState12, Spinner as Spinner3 } from "@raystack/apsara";
9659
9709
 
9660
9710
  // admin/views/users/details/layout/layout.tsx
9661
- import { useState as useState11 } from "react";
9711
+ import { useState as useState12 } from "react";
9662
9712
  import { Flex as Flex34 } from "@raystack/apsara";
9663
9713
 
9664
9714
  // admin/views/users/details/layout/side-panel.tsx
@@ -9667,8 +9717,8 @@ import { Avatar as Avatar5, getAvatarColor as getAvatarColor3, SidePanel as Side
9667
9717
  // admin/views/users/details/layout/side-panel-details.tsx
9668
9718
  import { Flex as Flex29, List as List4, Text as Text18, CopyButton as CopyButton2, Tooltip as Tooltip2 } from "@raystack/apsara";
9669
9719
 
9670
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-ZdTdo3Khe0Qx/sdk/admin/views/users/details/layout/side-panel.module.css.js
9671
- var digest31 = "7675a4fd7e0445eeaf500fdcf1ba1a5cbd3b1440c9190d1667df72d8196dec00";
9720
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-MjD77dhwEjKi/sdk/admin/views/users/details/layout/side-panel.module.css.js
9721
+ var digest31 = "747cf54a02a1595ac5ddcdd17cc67b42ace07480f4a38a553b63f6540d507684";
9672
9722
  var css31 = `._side-panel_cosj9_1 {
9673
9723
  transform: all 0.3s ease-in-out;
9674
9724
  padding-bottom: var(--rs-space-15);
@@ -9788,8 +9838,8 @@ var SidePanelDetails2 = () => {
9788
9838
  // admin/views/users/details/layout/side-panel-membership.tsx
9789
9839
  import { Flex as Flex31, List as List5, Text as Text21, Avatar as Avatar3 } from "@raystack/apsara";
9790
9840
 
9791
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-92b61vt5louZ/sdk/admin/views/users/details/layout/side-panel.module.css.js
9792
- var digest32 = "d8376142c47eb155d37aa2c8720d5fc0bb2680a711c8b41eb55dd1efdf2c4df2";
9841
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-U8PWtgdxeMbT/sdk/admin/views/users/details/layout/side-panel.module.css.js
9842
+ var digest32 = "bb7705fa3ddd4db4fdc969dd76870b08cd2214ee0211076b65098fc80095d78f";
9793
9843
  var css32 = `._side-panel_cosj9_1 {
9794
9844
  transform: all 0.3s ease-in-out;
9795
9845
  padding-bottom: var(--rs-space-15);
@@ -9858,8 +9908,8 @@ var side_panel_module_css_default2 = { "side-panel": "_side-panel_cosj9_1", "sid
9858
9908
  // admin/views/users/details/layout/membership-dropdown.tsx
9859
9909
  import { Text as Text20, Menu, Skeleton as Skeleton3 } from "@raystack/apsara";
9860
9910
 
9861
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-GY6mM6ecx3VU/sdk/admin/views/users/details/layout/side-panel.module.css.js
9862
- var digest33 = "ecb9328bbb3052d54cf414b542419a85e15b38363fa3fb3a797115de82961ea1";
9911
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-y2NZkDDGTW92/sdk/admin/views/users/details/layout/side-panel.module.css.js
9912
+ var digest33 = "d3c034e05d99e49d64b260c0cf0c031432bd8eb7f2e7e5454e9e38e402e00d41";
9863
9913
  var css33 = `._side-panel_cosj9_1 {
9864
9914
  transform: all 0.3s ease-in-out;
9865
9915
  padding-bottom: var(--rs-space-15);
@@ -9926,18 +9976,18 @@ var css33 = `._side-panel_cosj9_1 {
9926
9976
  var side_panel_module_css_default3 = { "side-panel": "_side-panel_cosj9_1", "sidePanel": "_side-panel_cosj9_1", "side-panel-label": "_side-panel-label_cosj9_6", "sidePanelLabel": "_side-panel-label_cosj9_6", "text-overflow": "_text-overflow_cosj9_10", "textOverflow": "_text-overflow_cosj9_10", "list-header": "_list-header_cosj9_18", "listHeader": "_list-header_cosj9_18", "loader-header": "_loader-header_cosj9_21", "loaderHeader": "_loader-header_cosj9_21", "dropdown-item": "_dropdown-item_cosj9_30", "dropdownItem": "_dropdown-item_cosj9_30", "dropdown-menu-trigger": "_dropdown-menu-trigger_cosj9_35", "dropdownMenuTrigger": "_dropdown-menu-trigger_cosj9_35", "listLabel": "_listLabel_cosj9_50" };
9927
9977
 
9928
9978
  // admin/views/users/details/layout/membership-dropdown.tsx
9929
- import { useMemo as useMemo5, useState as useState10 } from "react";
9979
+ import { useMemo as useMemo6, useState as useState11 } from "react";
9930
9980
  import {
9931
9981
  SearchOrganizationUsersResponse_OrganizationUserSchema
9932
9982
  } from "@raystack/proton/frontier";
9933
- import { create as create6 } from "@bufbuild/protobuf";
9983
+ import { create as create7 } from "@bufbuild/protobuf";
9934
9984
 
9935
9985
  // admin/hooks/useOrganizationRoles.ts
9936
- import { useEffect as useEffect5, useMemo as useMemo4 } from "react";
9937
- import { useQuery as useQuery9 } from "@connectrpc/connect-query";
9938
- import { create as create4 } from "@bufbuild/protobuf";
9986
+ import { useEffect as useEffect7, useMemo as useMemo5 } from "react";
9987
+ import { useQuery as useQuery10 } from "@connectrpc/connect-query";
9988
+ import { create as create5 } from "@bufbuild/protobuf";
9939
9989
  import {
9940
- FrontierServiceQueries as FrontierServiceQueries8,
9990
+ FrontierServiceQueries as FrontierServiceQueries9,
9941
9991
  ListRolesRequestSchema as ListRolesRequestSchema2,
9942
9992
  ListOrganizationRolesRequestSchema
9943
9993
  } from "@raystack/proton/frontier";
@@ -9946,11 +9996,12 @@ var useOrganizationRoles = (orgId, { enabled = true } = {}) => {
9946
9996
  data: defaultRoles = [],
9947
9997
  isLoading: isDefaultRolesLoading,
9948
9998
  error: defaultRolesError
9949
- } = useQuery9(
9950
- FrontierServiceQueries8.listRoles,
9951
- create4(ListRolesRequestSchema2, { scopes: [SCOPES.ORG] }),
9999
+ } = useQuery10(
10000
+ FrontierServiceQueries9.listRoles,
10001
+ create5(ListRolesRequestSchema2, { scopes: [SCOPES.ORG] }),
9952
10002
  {
9953
10003
  enabled,
10004
+ staleTime: SHARED_QUERY_STALE_TIME,
9954
10005
  select: (data) => data?.roles || []
9955
10006
  }
9956
10007
  );
@@ -9958,18 +10009,19 @@ var useOrganizationRoles = (orgId, { enabled = true } = {}) => {
9958
10009
  data: organizationRoles = [],
9959
10010
  isLoading: isOrgRolesLoading,
9960
10011
  error: orgRolesError
9961
- } = useQuery9(
9962
- FrontierServiceQueries8.listOrganizationRoles,
9963
- create4(ListOrganizationRolesRequestSchema, {
10012
+ } = useQuery10(
10013
+ FrontierServiceQueries9.listOrganizationRoles,
10014
+ create5(ListOrganizationRolesRequestSchema, {
9964
10015
  orgId: orgId || "",
9965
10016
  scopes: [SCOPES.ORG]
9966
10017
  }),
9967
10018
  {
9968
10019
  enabled: enabled && !!orgId,
10020
+ staleTime: SHARED_QUERY_STALE_TIME,
9969
10021
  select: (data) => data?.roles || []
9970
10022
  }
9971
10023
  );
9972
- useEffect5(() => {
10024
+ useEffect7(() => {
9973
10025
  if (defaultRolesError) {
9974
10026
  console.error("Failed to fetch default roles:", defaultRolesError);
9975
10027
  }
@@ -9977,11 +10029,11 @@ var useOrganizationRoles = (orgId, { enabled = true } = {}) => {
9977
10029
  console.error("Failed to fetch organization roles:", orgRolesError);
9978
10030
  }
9979
10031
  }, [defaultRolesError, orgRolesError]);
9980
- const roles = useMemo4(
10032
+ const roles = useMemo5(
9981
10033
  () => [...defaultRoles, ...organizationRoles],
9982
10034
  [defaultRoles, organizationRoles]
9983
10035
  );
9984
- const titleById = useMemo4(
10036
+ const titleById = useMemo5(
9985
10037
  () => new Map(roles.map((role) => [role.id, role.title || role.name])),
9986
10038
  [roles]
9987
10039
  );
@@ -10004,12 +10056,12 @@ import {
10004
10056
  toastManager as toastManager3
10005
10057
  } from "@raystack/apsara";
10006
10058
  import {
10007
- FrontierServiceQueries as FrontierServiceQueries9,
10059
+ FrontierServiceQueries as FrontierServiceQueries10,
10008
10060
  SetOrganizationMemberRoleRequestSchema
10009
10061
  } from "@raystack/proton/frontier";
10010
- import { create as create5 } from "@bufbuild/protobuf";
10011
- import { ConnectError as ConnectError2 } from "@connectrpc/connect";
10012
- import { useMutation as useMutation3 } from "@connectrpc/connect-query";
10062
+ import { create as create6 } from "@bufbuild/protobuf";
10063
+ import { ConnectError as ConnectError3 } from "@connectrpc/connect";
10064
+ import { useMutation as useMutation4 } from "@connectrpc/connect-query";
10013
10065
  import { useForm as useForm2 } from "react-hook-form";
10014
10066
  import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
10015
10067
  import { jsx as jsx46, jsxs as jsxs31 } from "react/jsx-runtime";
@@ -10035,14 +10087,14 @@ var AssignRole = ({
10035
10087
  },
10036
10088
  resolver: zodResolver2(formSchema)
10037
10089
  });
10038
- const { mutateAsync: setMemberRole } = useMutation3(
10039
- FrontierServiceQueries9.setOrganizationMemberRole
10090
+ const { mutateAsync: setMemberRole } = useMutation4(
10091
+ FrontierServiceQueries10.setOrganizationMemberRole
10040
10092
  );
10041
10093
  const selectedRoleId = watch("roleId");
10042
10094
  const onSubmit = async (data) => {
10043
10095
  try {
10044
10096
  await setMemberRole(
10045
- create5(SetOrganizationMemberRoleRequestSchema, {
10097
+ create6(SetOrganizationMemberRoleRequestSchema, {
10046
10098
  orgId: organizationId,
10047
10099
  userId: user?.id,
10048
10100
  roleId: data.roleId
@@ -10058,7 +10110,7 @@ var AssignRole = ({
10058
10110
  } catch (error) {
10059
10111
  toastManager3.add({
10060
10112
  title: "Failed to assign role",
10061
- description: error instanceof ConnectError2 ? error.message : void 0,
10113
+ description: error instanceof ConnectError3 ? error.message : void 0,
10062
10114
  type: "error"
10063
10115
  });
10064
10116
  console.error(error);
@@ -10127,7 +10179,7 @@ var AssignRole = ({
10127
10179
  };
10128
10180
 
10129
10181
  // admin/views/users/details/layout/suspend-user.tsx
10130
- import { useState as useState9 } from "react";
10182
+ import { useState as useState10 } from "react";
10131
10183
  import { AlertDialog, Button as Button6, toastManager as toastManager4 } from "@raystack/apsara";
10132
10184
  import { jsx as jsx47, jsxs as jsxs32 } from "react/jsx-runtime";
10133
10185
  var SuspendUser = ({
@@ -10136,7 +10188,7 @@ var SuspendUser = ({
10136
10188
  onSubmit
10137
10189
  }) => {
10138
10190
  const t = useTerminology();
10139
- const [isSubmitting, setIsSubmitting] = useState9(false);
10191
+ const [isSubmitting, setIsSubmitting] = useState10(false);
10140
10192
  const handleSuspend = async () => {
10141
10193
  try {
10142
10194
  setIsSubmitting(true);
@@ -10200,8 +10252,8 @@ var MembershipDropdown = ({
10200
10252
  data,
10201
10253
  onReset
10202
10254
  }) => {
10203
- const [isAssignRoleDialogOpen, setIsAssignRoleDialogOpen] = useState10(false);
10204
- const [isSuspendDialogOpen, setIsSuspendDialogOpen] = useState10(false);
10255
+ const [isAssignRoleDialogOpen, setIsAssignRoleDialogOpen] = useState11(false);
10256
+ const [isSuspendDialogOpen, setIsSuspendDialogOpen] = useState11(false);
10205
10257
  const { user } = useUser();
10206
10258
  const { roles, isLoading } = useOrganizationRoles(data?.orgId);
10207
10259
  const toggleAssignRoleDialog = () => {
@@ -10218,8 +10270,8 @@ var MembershipDropdown = ({
10218
10270
  toggleSuspendDialog();
10219
10271
  onReset?.();
10220
10272
  };
10221
- const memoizedUser = useMemo5(
10222
- () => create6(
10273
+ const memoizedUser = useMemo6(
10274
+ () => create7(
10223
10275
  SearchOrganizationUsersResponse_OrganizationUserSchema,
10224
10276
  Object.assign(user ?? {}, {
10225
10277
  roleNames: data?.roleNames || [],
@@ -10319,10 +10371,10 @@ var SidePanelMembership = ({
10319
10371
 
10320
10372
  // admin/views/users/details/layout/side-panel-invitation.tsx
10321
10373
  import { Flex as Flex32, List as List6, Text as Text22, Avatar as Avatar4, Skeleton as Skeleton4 } from "@raystack/apsara";
10322
- import { useMemo as useMemo6 } from "react";
10374
+ import { useMemo as useMemo7 } from "react";
10323
10375
 
10324
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-EGrhKoNvWd0K/sdk/admin/views/users/details/layout/side-panel.module.css.js
10325
- var digest34 = "66fdf00a2db363f4259f5e715eb5b7103feb81ad5f88c09bef45068d0c4226b9";
10376
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-U75tMjmDqdQu/sdk/admin/views/users/details/layout/side-panel.module.css.js
10377
+ var digest34 = "89390ece12707fcef8194471c56fb56dab7244dddefa506f8a50844bf2515c1b";
10326
10378
  var css34 = `._side-panel_cosj9_1 {
10327
10379
  transform: all 0.3s ease-in-out;
10328
10380
  padding-bottom: var(--rs-space-15);
@@ -10397,7 +10449,7 @@ var SidePanelInvitation = ({
10397
10449
  }) => {
10398
10450
  const { data: org } = useOrganizationLookup(data?.orgId);
10399
10451
  const { titleById } = useOrganizationRoles(data?.orgId);
10400
- const roleTitles = useMemo6(
10452
+ const roleTitles = useMemo7(
10401
10453
  () => (data?.roleIds || []).map((roleId) => titleById.get(roleId)).filter(Boolean).join(", "),
10402
10454
  [titleById, data?.roleIds]
10403
10455
  );
@@ -10443,8 +10495,8 @@ var SidePanelInvitation = ({
10443
10495
  ] });
10444
10496
  };
10445
10497
 
10446
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-8TYqyfw82P1o/sdk/admin/views/users/details/layout/side-panel.module.css.js
10447
- var digest35 = "b3c619d67b91e3ecf856e8aea430748d41fe5cc449e60283694b45b0f60ea575";
10498
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-p07oeCe41pHA/sdk/admin/views/users/details/layout/side-panel.module.css.js
10499
+ var digest35 = "6ebe3011f0c452aeb2b08ae9a51bb617c75af41d150740e06cde8231ec840b6f";
10448
10500
  var css35 = `._side-panel_cosj9_1 {
10449
10501
  transform: all 0.3s ease-in-out;
10450
10502
  padding-bottom: var(--rs-space-15);
@@ -10513,9 +10565,9 @@ var side_panel_module_css_default5 = { "side-panel": "_side-panel_cosj9_1", "sid
10513
10565
  // admin/views/users/details/layout/side-panel.tsx
10514
10566
  import {
10515
10567
  AdminServiceQueries as AdminServiceQueries9,
10516
- FrontierServiceQueries as FrontierServiceQueries10
10568
+ FrontierServiceQueries as FrontierServiceQueries11
10517
10569
  } from "@raystack/proton/frontier";
10518
- import { useQuery as useQuery10 } from "@connectrpc/connect-query";
10570
+ import { useQuery as useQuery11 } from "@connectrpc/connect-query";
10519
10571
  import { jsx as jsx51, jsxs as jsxs36 } from "react/jsx-runtime";
10520
10572
  var UserDetailsSidePanel = () => {
10521
10573
  const { user } = useUser();
@@ -10524,7 +10576,7 @@ var UserDetailsSidePanel = () => {
10524
10576
  isLoading,
10525
10577
  refetch: onReset,
10526
10578
  error
10527
- } = useQuery10(
10579
+ } = useQuery11(
10528
10580
  AdminServiceQueries9.searchUserOrganizations,
10529
10581
  {
10530
10582
  id: user?.id || "",
@@ -10540,8 +10592,8 @@ var UserDetailsSidePanel = () => {
10540
10592
  data: invitationsResponse,
10541
10593
  isLoading: isInvitationsLoading,
10542
10594
  error: invitationsError
10543
- } = useQuery10(
10544
- FrontierServiceQueries10.listUserInvitations,
10595
+ } = useQuery11(
10596
+ FrontierServiceQueries11.listUserInvitations,
10545
10597
  // `id` is the user's email, not their uuid — invitations are keyed by email
10546
10598
  // since the invitee may not have an account yet.
10547
10599
  {
@@ -10590,8 +10642,8 @@ var UserDetailsSidePanel = () => {
10590
10642
  );
10591
10643
  };
10592
10644
 
10593
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-y1pJTLrrtCnf/sdk/admin/views/users/details/layout/layout.module.css.js
10594
- var digest36 = "fbf3f7d88da6beef7f0ec7917fd82c59e773ce5265d2786625253eae75739998";
10645
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-p225rQwpYgIQ/sdk/admin/views/users/details/layout/layout.module.css.js
10646
+ var digest36 = "2430657112747f93b7a6a4be860bc02620f052ecbff890ce4bc101dbf64ef53a";
10595
10647
  var css36 = `._page_190wz_1 {
10596
10648
  height: 100vh;
10597
10649
  width: 100%;
@@ -10632,8 +10684,8 @@ import {
10632
10684
  } from "@raystack/apsara";
10633
10685
  import { SidebarIcon } from "@raystack/apsara/icons";
10634
10686
 
10635
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-ZXYbC00dr73e/sdk/admin/components/navbar.module.css.js
10636
- var digest37 = "8cb8882840d360d34580ea60c113de006cfea80cf1174ddd1a4cf12cc20aa32a";
10687
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-cY89ar7VZXdR/sdk/admin/components/navbar.module.css.js
10688
+ var digest37 = "69d2126afb7862a8891e73400af27b519c6899bb98465a00eda4cafa1da928c9";
10637
10689
  var css37 = `._navbar_641ya_1 {
10638
10690
  padding: var(--rs-space-4) var(--rs-space-7);
10639
10691
  border-bottom: 0.5px solid var(--rs-color-border-base-primary);
@@ -10734,7 +10786,7 @@ var UserDetailsNavbar = ({
10734
10786
  // admin/views/users/details/layout/layout.tsx
10735
10787
  import { jsx as jsx53, jsxs as jsxs38 } from "react/jsx-runtime";
10736
10788
  var UserDetailsLayout = ({ children, currentPath, onNavigate }) => {
10737
- const [showSidePanel, setShowSidePanel] = useState11(true);
10789
+ const [showSidePanel, setShowSidePanel] = useState12(true);
10738
10790
  function toggleSidePanel() {
10739
10791
  setShowSidePanel(!showSidePanel);
10740
10792
  }
@@ -10754,36 +10806,36 @@ var UserDetailsLayout = ({ children, currentPath, onNavigate }) => {
10754
10806
  };
10755
10807
 
10756
10808
  // admin/views/users/details/user-details.tsx
10757
- import { useQuery as useQuery12 } from "@connectrpc/connect-query";
10758
- import { FrontierServiceQueries as FrontierServiceQueries12 } from "@raystack/proton/frontier";
10809
+ import { useQuery as useQuery13 } from "@connectrpc/connect-query";
10810
+ import { FrontierServiceQueries as FrontierServiceQueries13 } from "@raystack/proton/frontier";
10759
10811
 
10760
10812
  // admin/views/users/details/security/security.tsx
10761
10813
  import { Flex as Flex37, Separator as Separator3, Text as Text25 } from "@raystack/apsara";
10762
10814
 
10763
10815
  // admin/views/users/details/security/block-user.tsx
10764
- import { useCallback as useCallback5, useState as useState12 } from "react";
10816
+ import { useCallback as useCallback7, useState as useState13 } from "react";
10765
10817
  import { AlertDialog as AlertDialog2, Button as Button7, toastManager as toastManager5 } from "@raystack/apsara";
10766
10818
  import {
10767
- createConnectQueryKey as createConnectQueryKey2,
10768
- useMutation as useMutation4,
10769
- useTransport as useTransport3
10819
+ createConnectQueryKey as createConnectQueryKey3,
10820
+ useMutation as useMutation5,
10821
+ useTransport as useTransport4
10770
10822
  } from "@connectrpc/connect-query";
10771
- import { FrontierServiceQueries as FrontierServiceQueries11 } from "@raystack/proton/frontier";
10772
- import { useQueryClient as useQueryClient4 } from "@tanstack/react-query";
10823
+ import { FrontierServiceQueries as FrontierServiceQueries12 } from "@raystack/proton/frontier";
10824
+ import { useQueryClient as useQueryClient5 } from "@tanstack/react-query";
10773
10825
  import { jsx as jsx54, jsxs as jsxs39 } from "react/jsx-runtime";
10774
10826
  var BlockUserDialog = () => {
10775
10827
  const t = useTerminology();
10776
- const [isDialogOpen, setIsDialogOpen] = useState12(false);
10828
+ const [isDialogOpen, setIsDialogOpen] = useState13(false);
10777
10829
  const { user, reset } = useUser();
10778
- const queryClient = useQueryClient4();
10779
- const transport = useTransport3();
10830
+ const queryClient = useQueryClient5();
10831
+ const transport = useTransport4();
10780
10832
  const isActive = user?.state === "enabled";
10781
10833
  const userName = getUserName(user);
10782
- const optimisticUpdateState = useCallback5(
10834
+ const optimisticUpdateState = useCallback7(
10783
10835
  (state) => {
10784
10836
  queryClient.setQueryData(
10785
- createConnectQueryKey2({
10786
- schema: FrontierServiceQueries11.getUser,
10837
+ createConnectQueryKey3({
10838
+ schema: FrontierServiceQueries12.getUser,
10787
10839
  transport,
10788
10840
  input: { id: user?.id || "" },
10789
10841
  cardinality: "finite"
@@ -10800,8 +10852,8 @@ var BlockUserDialog = () => {
10800
10852
  },
10801
10853
  [queryClient, transport, user?.id]
10802
10854
  );
10803
- const { mutateAsync: blockUser, isPending: isBlockingUser } = useMutation4(
10804
- FrontierServiceQueries11.disableUser,
10855
+ const { mutateAsync: blockUser, isPending: isBlockingUser } = useMutation5(
10856
+ FrontierServiceQueries12.disableUser,
10805
10857
  {
10806
10858
  onSuccess: () => {
10807
10859
  toastManager5.add({ title: `${t.user({ case: "capital" })} blocked successfully`, type: "success" });
@@ -10811,8 +10863,8 @@ var BlockUserDialog = () => {
10811
10863
  }
10812
10864
  }
10813
10865
  );
10814
- const { mutateAsync: unblockUser, isPending: isUnblockingUser } = useMutation4(
10815
- FrontierServiceQueries11.enableUser,
10866
+ const { mutateAsync: unblockUser, isPending: isUnblockingUser } = useMutation5(
10867
+ FrontierServiceQueries12.enableUser,
10816
10868
  {
10817
10869
  onSuccess: () => {
10818
10870
  toastManager5.add({ title: `${t.user({ case: "capital" })} unblocked successfully`, type: "success" });
@@ -10910,11 +10962,11 @@ var BlockUserDialog = () => {
10910
10962
  };
10911
10963
 
10912
10964
  // admin/views/users/details/security/sessions/index.tsx
10913
- import { useState as useState14 } from "react";
10965
+ import { useState as useState15 } from "react";
10914
10966
  import { Flex as Flex36, Text as Text24, Button as Button10, toastManager as toastManager7 } from "@raystack/apsara";
10915
10967
 
10916
10968
  // admin/views/users/details/security/sessions/revoke-session-confirm.tsx
10917
- import { useState as useState13 } from "react";
10969
+ import { useState as useState14 } from "react";
10918
10970
  import {
10919
10971
  Dialog as Dialog4,
10920
10972
  Button as Button9,
@@ -10990,8 +11042,8 @@ var RevokeSessionFinalConfirm = ({
10990
11042
  ] }) });
10991
11043
  };
10992
11044
 
10993
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-yLm3zKjEJdMK/sdk/admin/views/users/details/security/sessions/sessions.module.css.js
10994
- var digest38 = "7ba76353f7c8c9945031e3747627d28ecc7291fd23837909f1d03c017a268b50";
11045
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-8CpV3SbxciRc/sdk/admin/views/users/details/security/sessions/sessions.module.css.js
11046
+ var digest38 = "04f50aa865a29833be9319a8bd4f70fcbf1f3cdad86bfa341163162c460f4ffb";
10995
11047
  var css38 = `._sessionsContainer_jptao_1 {
10996
11048
  border: 1px solid var(--rs-color-border-base-primary);
10997
11049
  border-radius: var(--rs-radius-2);
@@ -11054,7 +11106,7 @@ var sessions_module_css_default = { "sessionsContainer": "_sessionsContainer_jpt
11054
11106
  // admin/views/users/details/security/sessions/revoke-session-confirm.tsx
11055
11107
  import { Fragment as Fragment9, jsx as jsx56, jsxs as jsxs41 } from "react/jsx-runtime";
11056
11108
  var RevokeSessionConfirm = ({ isOpen, onOpenChange, sessionInfo, onRevokeConfirm, isLoading = false }) => {
11057
- const [isFinalConfirmOpen, setIsFinalConfirmOpen] = useState13(false);
11109
+ const [isFinalConfirmOpen, setIsFinalConfirmOpen] = useState14(false);
11058
11110
  const handleRevoke = () => {
11059
11111
  setIsFinalConfirmOpen(true);
11060
11112
  };
@@ -11128,8 +11180,8 @@ var RevokeSessionConfirm = ({ isOpen, onOpenChange, sessionInfo, onRevokeConfirm
11128
11180
  // admin/views/users/details/security/sessions/session-skeleton.tsx
11129
11181
  import { Flex as Flex35, Skeleton as Skeleton5 } from "@raystack/apsara";
11130
11182
 
11131
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-UjVpWXni1xK2/sdk/admin/views/users/details/security/sessions/sessions.module.css.js
11132
- var digest39 = "b29f0267ad58c89971893df3057c7f0145212364fd8f3be113ce004600e10af0";
11183
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-PQlNLK8m25B6/sdk/admin/views/users/details/security/sessions/sessions.module.css.js
11184
+ var digest39 = "2d8f6924f031550498dbc6a556178da117519ab6171eec022d78512aa205a98d";
11133
11185
  var css39 = `._sessionsContainer_jptao_1 {
11134
11186
  border: 1px solid var(--rs-color-border-base-primary);
11135
11187
  border-radius: var(--rs-radius-2);
@@ -11202,14 +11254,14 @@ var SessionSkeleton = ({ count = 3 }) => {
11202
11254
  };
11203
11255
 
11204
11256
  // admin/views/users/details/security/sessions/index.tsx
11205
- import { useQuery as useQuery11, useMutation as useMutation5, createConnectQueryKey as createConnectQueryKey3, useTransport as useTransport4 } from "@connectrpc/connect-query";
11206
- import { useQueryClient as useQueryClient5 } from "@tanstack/react-query";
11257
+ import { useQuery as useQuery12, useMutation as useMutation6, createConnectQueryKey as createConnectQueryKey4, useTransport as useTransport5 } from "@connectrpc/connect-query";
11258
+ import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
11207
11259
  import { AdminServiceQueries as AdminServiceQueries10 } from "@raystack/proton/frontier";
11208
11260
  import dayjs3 from "dayjs";
11209
11261
  import relativeTime2 from "dayjs/plugin/relativeTime";
11210
11262
 
11211
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-i68mhgD8m5np/sdk/admin/views/users/details/security/sessions/sessions.module.css.js
11212
- var digest40 = "de32edab611b06c1bc4fe5d5545248631f3acaddebf73096cbf7d4c501234f86";
11263
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-ltHWxegVcPPg/sdk/admin/views/users/details/security/sessions/sessions.module.css.js
11264
+ var digest40 = "2979e7feca08af3453a18fe3996c170e10ea8af55b1e03174499414e1319e276";
11213
11265
  var css40 = `._sessionsContainer_jptao_1 {
11214
11266
  border: 1px solid var(--rs-color-border-base-primary);
11215
11267
  border-radius: var(--rs-radius-2);
@@ -11301,15 +11353,15 @@ var formatDeviceDisplay = (browser, operatingSystem) => {
11301
11353
  };
11302
11354
  var UserSessions = () => {
11303
11355
  const { user } = useUser();
11304
- const queryClient = useQueryClient5();
11305
- const transport = useTransport4();
11306
- const [isRevokeDialogOpen, setIsRevokeDialogOpen] = useState14(false);
11307
- const [selectedSession, setSelectedSession] = useState14(null);
11356
+ const queryClient = useQueryClient6();
11357
+ const transport = useTransport5();
11358
+ const [isRevokeDialogOpen, setIsRevokeDialogOpen] = useState15(false);
11359
+ const [selectedSession, setSelectedSession] = useState15(null);
11308
11360
  const {
11309
11361
  data: sessionsData,
11310
11362
  isLoading,
11311
11363
  error
11312
- } = useQuery11(
11364
+ } = useQuery12(
11313
11365
  AdminServiceQueries10.listUserSessions,
11314
11366
  { userId: user?.id || "" },
11315
11367
  {
@@ -11319,10 +11371,10 @@ var UserSessions = () => {
11319
11371
  const {
11320
11372
  mutate: revokeUserSession,
11321
11373
  isPending: isRevokingSession
11322
- } = useMutation5(AdminServiceQueries10.revokeUserSession, {
11374
+ } = useMutation6(AdminServiceQueries10.revokeUserSession, {
11323
11375
  onSuccess: () => {
11324
11376
  queryClient.invalidateQueries({
11325
- queryKey: createConnectQueryKey3({
11377
+ queryKey: createConnectQueryKey4({
11326
11378
  schema: AdminServiceQueries10.listUserSessions,
11327
11379
  transport,
11328
11380
  input: { userId: user?.id || "" },
@@ -11418,8 +11470,8 @@ var UserSessions = () => {
11418
11470
  ] });
11419
11471
  };
11420
11472
 
11421
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-DkgEDq1HbUQl/sdk/admin/views/users/details/security/security.module.css.js
11422
- var digest41 = "495b9cfe32a2329fcde503ae5b029b3e57d4199fdbee84a4eb5824ecad40d14e";
11473
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-6jgCgTQBUnlJ/sdk/admin/views/users/details/security/security.module.css.js
11474
+ var digest41 = "989645d3731b0e0a4e09f84500ab1f9ca4bc89b3b7ba049d6306306a0f637930";
11423
11475
  var css41 = `._container_4259p_1 {
11424
11476
  width: 100%;
11425
11477
  }
@@ -11475,8 +11527,8 @@ var UserDetailContent = ({ user, refetch, currentPath, onNavigate }) => {
11475
11527
  };
11476
11528
  var UserDetailsByUserId = ({ userId, currentPath, onNavigate }) => {
11477
11529
  const t = useTerminology();
11478
- const { data, isLoading, refetch } = useQuery12(
11479
- FrontierServiceQueries12.getUser,
11530
+ const { data, isLoading, refetch } = useQuery13(
11531
+ FrontierServiceQueries13.getUser,
11480
11532
  { id: userId },
11481
11533
  {
11482
11534
  enabled: !!userId,
@@ -11539,7 +11591,7 @@ function UsersView({
11539
11591
  // admin/views/organizations/list/index.tsx
11540
11592
  import { Button as Button14, DataTable as DataTable15, EmptyState as EmptyState13, Flex as Flex43 } from "@raystack/apsara";
11541
11593
  import { OrganizationIcon as OrganizationIcon2 } from "@raystack/apsara/icons";
11542
- import { useEffect as useEffect7, useState as useState18 } from "react";
11594
+ import { useEffect as useEffect9, useState as useState19 } from "react";
11543
11595
 
11544
11596
  // admin/views/organizations/list/navbar.tsx
11545
11597
  import {
@@ -11553,8 +11605,8 @@ import {
11553
11605
  } from "@raystack/apsara";
11554
11606
  import { OrganizationIcon } from "@raystack/apsara/icons";
11555
11607
 
11556
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-qNnhEohXZIAq/sdk/admin/components/navbar.module.css.js
11557
- var digest42 = "b7f0a83dee443773d2aae453e8a081dbc810cd0057dabfbef9c7f4bad9e0bd4f";
11608
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-QUvvuupiR7dj/sdk/admin/components/navbar.module.css.js
11609
+ var digest42 = "9171eddd6e3e3485061928026cbf908f7fce41ef055ea38615e2888bd0ca6c6e";
11558
11610
  var css42 = `._navbar_641ya_1 {
11559
11611
  padding: var(--rs-space-4) var(--rs-space-7);
11560
11612
  border-bottom: 0.5px solid var(--rs-color-border-base-primary);
@@ -11583,7 +11635,7 @@ var css42 = `._navbar_641ya_1 {
11583
11635
  var navbar_module_css_default5 = { "navbar": "_navbar_641ya_1", "nav-chip": "_nav-chip_641ya_11", "navChip": "_nav-chip_641ya_11" };
11584
11636
 
11585
11637
  // admin/views/organizations/list/navbar.tsx
11586
- import { useState as useState15 } from "react";
11638
+ import { useState as useState16 } from "react";
11587
11639
  import { Fragment as Fragment11, jsx as jsx62, jsxs as jsxs46 } from "react/jsx-runtime";
11588
11640
  var OrganizationsNavabar = ({
11589
11641
  searchQuery,
@@ -11591,8 +11643,8 @@ var OrganizationsNavabar = ({
11591
11643
  onExportCsv
11592
11644
  }) => {
11593
11645
  const t = useTerminology();
11594
- const [showSearch, setShowSearch] = useState15(searchQuery ? true : false);
11595
- const [isDownloading, setIsDownloading] = useState15(false);
11646
+ const [showSearch, setShowSearch] = useState16(searchQuery ? true : false);
11647
+ const [isDownloading, setIsDownloading] = useState16(false);
11596
11648
  function toggleSearch() {
11597
11649
  setShowSearch((prev) => !prev);
11598
11650
  }
@@ -11670,8 +11722,8 @@ var OrganizationsNavabar = ({
11670
11722
  ] });
11671
11723
  };
11672
11724
 
11673
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-AYMlhGi7ZHmV/sdk/admin/views/organizations/list/list.module.css.js
11674
- var digest43 = "94c62dc71b8ef22b63b3853dbbe39e47c189185cad12f4e2b392ca894158b527";
11725
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-COFQ168xKcAm/sdk/admin/views/organizations/list/list.module.css.js
11726
+ var digest43 = "d4711ad8c246a4014ab54278ebdd6b6f7429c12b963eec511d104ea78f3c60ac";
11675
11727
  var css43 = `._table_w4mi3_1 {
11676
11728
  height: auto;
11677
11729
  }
@@ -11775,8 +11827,8 @@ import {
11775
11827
  Text as Text27
11776
11828
  } from "@raystack/apsara";
11777
11829
 
11778
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-cMNHMaCBcjin/sdk/admin/views/organizations/list/list.module.css.js
11779
- var digest44 = "d2cc13526a2e5d9d8dd448256bc31c8fbbea442d40950a94f93d35324fb0e2ab";
11830
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-YWL69wLVPT5T/sdk/admin/views/organizations/list/list.module.css.js
11831
+ var digest44 = "166172af9fe677ef075796abcf390778d70d4557196f0bbcac6285347c000727";
11780
11832
  var css44 = `._table_w4mi3_1 {
11781
11833
  height: auto;
11782
11834
  }
@@ -12019,19 +12071,19 @@ var getColumns11 = ({
12019
12071
  };
12020
12072
 
12021
12073
  // admin/views/organizations/list/index.tsx
12022
- import { useInfiniteQuery as useInfiniteQuery4, useQuery as useQuery13 } from "@connectrpc/connect-query";
12074
+ import { useInfiniteQuery as useInfiniteQuery5, useQuery as useQuery14 } from "@connectrpc/connect-query";
12023
12075
  import {
12024
12076
  AdminServiceQueries as AdminServiceQueries12,
12025
- FrontierServiceQueries as FrontierServiceQueries13,
12077
+ FrontierServiceQueries as FrontierServiceQueries14,
12026
12078
  ListPlansRequestSchema
12027
12079
  } from "@raystack/proton/frontier";
12028
- import { create as create7 } from "@bufbuild/protobuf";
12080
+ import { create as create8 } from "@bufbuild/protobuf";
12029
12081
 
12030
12082
  // admin/views/organizations/list/create.tsx
12031
- import { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo7, useState as useState17 } from "react";
12083
+ import { useCallback as useCallback8, useEffect as useEffect8, useMemo as useMemo8, useState as useState18 } from "react";
12032
12084
 
12033
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-4ycAbcSL0HtS/sdk/admin/views/organizations/list/list.module.css.js
12034
- var digest45 = "bbcf28d7e5eb25967adc35a093e0e408116cdc23affae18cc6b16bba47f292eb";
12085
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-0k0eKWUdI7iU/sdk/admin/views/organizations/list/list.module.css.js
12086
+ var digest45 = "1bd5ea341030e9701f5f688f99c1613eb8df97e3ee50392a1fc82d616b858f46";
12035
12087
  var css45 = `._table_w4mi3_1 {
12036
12088
  height: auto;
12037
12089
  }
@@ -12140,7 +12192,7 @@ import {
12140
12192
  } from "@raystack/apsara";
12141
12193
 
12142
12194
  // client/components/image-upload/image-upload.tsx
12143
- import { useRef, useState as useState16 } from "react";
12195
+ import { useRef as useRef3, useState as useState17 } from "react";
12144
12196
  import ReactCrop, {
12145
12197
  centerCrop,
12146
12198
  makeAspectCrop
@@ -12155,8 +12207,8 @@ import {
12155
12207
  } from "@raystack/apsara";
12156
12208
  import "react-image-crop/dist/ReactCrop.css";
12157
12209
 
12158
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-up30yO36na6h/sdk/client/components/image-upload/image-upload.module.css.js
12159
- var digest46 = "224d8303a6ee4986793f5e53050a8a7518e5955b2b44731f7c057403f80973db";
12210
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-hMrD5L8S70D7/sdk/client/components/image-upload/image-upload.module.css.js
12211
+ var digest46 = "e195ceaf391a76ef3c633ed6ad78fce229da4f9dec0a4cf0b336b110c5903878";
12160
12212
  var css46 = `._iconButton_1ifr2_1 {
12161
12213
  position: relative;
12162
12214
  width: var(--rs-space-14);
@@ -12250,8 +12302,8 @@ var image_upload_module_css_default = { "iconButton": "_iconButton_1ifr2_1", "av
12250
12302
  // client/components/image-upload/image-upload.tsx
12251
12303
  import { jsx as jsx64, jsxs as jsxs48 } from "react/jsx-runtime";
12252
12304
  function CropDialog({ open, onOpenChange, imgSrc, onSave }) {
12253
- const [crop, setCrop] = useState16();
12254
- const imgRef = useRef(null);
12305
+ const [crop, setCrop] = useState17();
12306
+ const imgRef = useRef3(null);
12255
12307
  function onImageLoad(e) {
12256
12308
  const { naturalWidth: width, naturalHeight: height } = e.currentTarget;
12257
12309
  const newCrop = centerCrop(
@@ -12368,9 +12420,9 @@ function ImageUpload({
12368
12420
  initials,
12369
12421
  ...rest
12370
12422
  }) {
12371
- const inputRef = useRef(null);
12372
- const [imgSrc, setImgSrc] = useState16("");
12373
- const [showCropDialog, setShowCropDialog] = useState16(false);
12423
+ const inputRef = useRef3(null);
12424
+ const [imgSrc, setImgSrc] = useState17("");
12425
+ const [showCropDialog, setShowCropDialog] = useState17(false);
12374
12426
  function onUploadIconClick() {
12375
12427
  if (inputRef.current) {
12376
12428
  inputRef.current.value = "";
@@ -12459,8 +12511,8 @@ function ImageUpload({
12459
12511
  import { debounce } from "lodash";
12460
12512
  import { Controller as Controller2, useForm as useForm3 } from "react-hook-form";
12461
12513
  import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
12462
- import { useMutation as useMutation6 } from "@connectrpc/connect-query";
12463
- import { Code as Code2 } from "@connectrpc/connect";
12514
+ import { useMutation as useMutation7 } from "@connectrpc/connect-query";
12515
+ import { Code as Code3 } from "@connectrpc/connect";
12464
12516
  import { AdminServiceQueries as AdminServiceQueries11 } from "@raystack/proton/frontier";
12465
12517
  import { jsx as jsx65, jsxs as jsxs49 } from "react/jsx-runtime";
12466
12518
  var orgCreateSchema = external_exports.object({
@@ -12481,8 +12533,8 @@ function CreateOrganizationPanel({
12481
12533
  onSuccess
12482
12534
  }) {
12483
12535
  const t = useTerminology();
12484
- const [countries, setCountries] = useState17(countriesProp);
12485
- useEffect6(() => {
12536
+ const [countries, setCountries] = useState18(countriesProp);
12537
+ useEffect8(() => {
12486
12538
  if (countriesProp.length > 0) {
12487
12539
  setCountries(countriesProp);
12488
12540
  }
@@ -12504,16 +12556,16 @@ function CreateOrganizationPanel({
12504
12556
  },
12505
12557
  resolver: zodResolver3(orgCreateSchema)
12506
12558
  });
12507
- const uniqueSuffix = useMemo7(() => randomSuffix(), []);
12508
- const debouncedGenerateSlug = useMemo7(
12559
+ const uniqueSuffix = useMemo8(() => randomSuffix(), []);
12560
+ const debouncedGenerateSlug = useMemo8(
12509
12561
  () => debounce((title) => {
12510
12562
  const baseSlug = generateSlug(title);
12511
12563
  setValue("name", baseSlug ? `${baseSlug}-${uniqueSuffix}` : "");
12512
12564
  }, 300),
12513
12565
  [setValue, uniqueSuffix]
12514
12566
  );
12515
- useEffect6(() => () => debouncedGenerateSlug.cancel(), [debouncedGenerateSlug]);
12516
- const handleTitleChange = useCallback6(
12567
+ useEffect8(() => () => debouncedGenerateSlug.cancel(), [debouncedGenerateSlug]);
12568
+ const handleTitleChange = useCallback8(
12517
12569
  (e) => {
12518
12570
  if (dirtyFields.name)
12519
12571
  return;
@@ -12521,11 +12573,11 @@ function CreateOrganizationPanel({
12521
12573
  },
12522
12574
  [debouncedGenerateSlug, dirtyFields.name]
12523
12575
  );
12524
- const { mutateAsync: createOrganization, isPending } = useMutation6(
12576
+ const { mutateAsync: createOrganization, isPending } = useMutation7(
12525
12577
  AdminServiceQueries11.adminCreateOrganization,
12526
12578
  {
12527
12579
  onError: (error) => {
12528
- if (error?.code === Code2.AlreadyExists) {
12580
+ if (error?.code === Code3.AlreadyExists) {
12529
12581
  setError("name", {
12530
12582
  message: `${t.organization({ case: "capital" })} URL is already taken`
12531
12583
  });
@@ -12713,7 +12765,6 @@ function CreateOrganizationPanel({
12713
12765
  }
12714
12766
 
12715
12767
  // admin/views/organizations/list/index.tsx
12716
- import { useDebouncedState as useDebouncedState3 } from "@raystack/apsara/hooks";
12717
12768
  import { Fragment as Fragment12, jsx as jsx66, jsxs as jsxs50 } from "react/jsx-runtime";
12718
12769
  var NoOrganizations = () => {
12719
12770
  const t = useTerminology();
@@ -12755,10 +12806,6 @@ var ZeroState = ({ openCreatePanel }) => {
12755
12806
  ) });
12756
12807
  };
12757
12808
  var DEFAULT_SORT4 = { name: "createdAt", order: "desc" };
12758
- var INITIAL_QUERY4 = {
12759
- offset: 0,
12760
- limit: DEFAULT_PAGE_SIZE
12761
- };
12762
12809
  var OrganizationListView = ({
12763
12810
  appName,
12764
12811
  onNavigateToOrg,
@@ -12768,19 +12815,22 @@ var OrganizationListView = ({
12768
12815
  countries = []
12769
12816
  } = {}) => {
12770
12817
  const t = useTerminology();
12771
- const [showCreatePanel, setShowCreatePanel] = useState18(false);
12772
- const [tableQuery, setTableQuery] = useDebouncedState3(
12773
- INITIAL_QUERY4,
12774
- 200
12775
- );
12776
- const query = transformDataTableQueryToRQLRequest(tableQuery, {
12777
- fieldNameMapping: {
12778
- createdBy: "created_by",
12779
- planName: "plan_name",
12780
- subscriptionCycleEndAt: "subscription_cycle_end_at",
12781
- paymentMode: "payment_mode",
12782
- subscriptionState: "subscription_state",
12783
- createdAt: "created_at"
12818
+ const [showCreatePanel, setShowCreatePanel] = useState19(false);
12819
+ const {
12820
+ tableQuery,
12821
+ rqlQuery: query,
12822
+ onTableQueryChange
12823
+ } = useServerTableQuery({
12824
+ defaultSort: DEFAULT_SORT4,
12825
+ transformOptions: {
12826
+ fieldNameMapping: {
12827
+ createdBy: "created_by",
12828
+ planName: "plan_name",
12829
+ subscriptionCycleEndAt: "subscription_cycle_end_at",
12830
+ paymentMode: "payment_mode",
12831
+ subscriptionState: "subscription_state",
12832
+ createdAt: "created_at"
12833
+ }
12784
12834
  }
12785
12835
  });
12786
12836
  const {
@@ -12788,9 +12838,10 @@ var OrganizationListView = ({
12788
12838
  isLoading,
12789
12839
  isFetchingNextPage,
12790
12840
  fetchNextPage,
12841
+ hasNextPage,
12791
12842
  error,
12792
12843
  isError
12793
- } = useInfiniteQuery4(
12844
+ } = useInfiniteQuery5(
12794
12845
  AdminServiceQueries12.searchOrganizations,
12795
12846
  { query },
12796
12847
  {
@@ -12802,34 +12853,27 @@ var OrganizationListView = ({
12802
12853
  retryDelay: 1e3
12803
12854
  }
12804
12855
  );
12805
- const { data: plans = [], isLoading: isPlansLoading, error: plansError } = useQuery13(
12806
- FrontierServiceQueries13.listPlans,
12807
- create7(ListPlansRequestSchema, {}),
12856
+ const { data: plans = [], isLoading: isPlansLoading, error: plansError } = useQuery14(
12857
+ FrontierServiceQueries14.listPlans,
12858
+ create8(ListPlansRequestSchema, {}),
12808
12859
  {
12809
12860
  select: (data2) => data2?.plans || []
12810
12861
  }
12811
12862
  );
12812
- useEffect7(() => {
12863
+ useEffect9(() => {
12813
12864
  if (plansError) {
12814
12865
  console.error("Failed to fetch plans:", plansError);
12815
12866
  }
12816
12867
  }, [plansError]);
12817
12868
  const data = infiniteData?.pages?.flatMap((page) => page?.organizations || []) || [];
12818
12869
  const groupCountMap = infiniteData ? getGroupCountMapFromFirstPage(infiniteData) : {};
12819
- const onTableQueryChange = (newQuery) => {
12820
- setTableQuery({
12821
- ...newQuery,
12822
- offset: 0,
12823
- limit: newQuery.limit || DEFAULT_PAGE_SIZE
12824
- });
12825
- };
12826
- const handleLoadMore = async () => {
12827
- try {
12828
- await fetchNextPage();
12829
- } catch (error2) {
12830
- console.error("Error loading more organizations:", error2);
12831
- }
12832
- };
12870
+ const handleLoadMore = useLoadMore({
12871
+ hasNextPage,
12872
+ isFetchingNextPage,
12873
+ isError,
12874
+ fetchNextPage,
12875
+ label: "organizations"
12876
+ });
12833
12877
  function closeCreateOrgPanel() {
12834
12878
  setShowCreatePanel(false);
12835
12879
  }
@@ -12915,14 +12959,14 @@ var OrganizationListView = ({
12915
12959
  };
12916
12960
 
12917
12961
  // admin/views/organizations/details/index.tsx
12918
- import { useEffect as useEffect12, useMemo as useMemo10, useState as useState22 } from "react";
12962
+ import { useEffect as useEffect14, useMemo as useMemo11, useState as useState23 } from "react";
12919
12963
  import {
12920
- useQuery as useQuery17,
12921
- createConnectQueryKey as createConnectQueryKey8,
12922
- useTransport as useTransport9
12964
+ useQuery as useQuery18,
12965
+ createConnectQueryKey as createConnectQueryKey9,
12966
+ useTransport as useTransport10
12923
12967
  } from "@connectrpc/connect-query";
12924
- import { useQueryClient as useQueryClient10 } from "@tanstack/react-query";
12925
- import { create as create17 } from "@bufbuild/protobuf";
12968
+ import { useQueryClient as useQueryClient11 } from "@tanstack/react-query";
12969
+ import { create as create18 } from "@bufbuild/protobuf";
12926
12970
 
12927
12971
  // admin/views/organizations/details/layout/navbar.tsx
12928
12972
  import { SidebarIcon as SidebarIcon2, OrganizationIcon as OrganizationIcon3 } from "@raystack/apsara/icons";
@@ -12940,8 +12984,8 @@ import {
12940
12984
  Search
12941
12985
  } from "@raystack/apsara";
12942
12986
 
12943
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-C0Jg6N7odXNz/sdk/admin/views/organizations/details/layout/layout.module.css.js
12944
- var digest47 = "06c48ca9291693f11af4e0cf44a815c59b9873934f36ef1c484d91ff3353f501";
12987
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-fDhuITlp14Pm/sdk/admin/views/organizations/details/layout/layout.module.css.js
12988
+ var digest47 = "28a5384187dcbd4df6c361745e39c86da3f32b6008254e588df861745158df4b";
12945
12989
  var css47 = `._page_1nlk4_1 {
12946
12990
  width: 100%;
12947
12991
  height: 100vh;
@@ -13021,8 +13065,8 @@ var css47 = `._page_1nlk4_1 {
13021
13065
  })();
13022
13066
  var layout_module_css_default2 = { "page": "_page_1nlk4_1", "main_content": "_main_content_1nlk4_7", "mainContent": "_main_content_1nlk4_7", "main_content_with_sidepanel": "_main_content_with_sidepanel_1nlk4_12", "mainContentWithSidepanel": "_main_content_with_sidepanel_1nlk4_12", "navbar-action-menu-content": "_navbar-action-menu-content_1nlk4_17", "navbarActionMenuContent": "_navbar-action-menu-content_1nlk4_17", "navbar-action-menu-item": "_navbar-action-menu-item_1nlk4_21", "navbarActionMenuItem": "_navbar-action-menu-item_1nlk4_21", "side-panel-section-item-label": "_side-panel-section-item-label_1nlk4_26", "sidePanelSectionItemLabel": "_side-panel-section-item-label_1nlk4_26", "invite-users-dialog-body": "_invite-users-dialog-body_1nlk4_30", "inviteUsersDialogBody": "_invite-users-dialog-body_1nlk4_30", "invite-users-dialog-label": "_invite-users-dialog-label_1nlk4_37", "inviteUsersDialogLabel": "_invite-users-dialog-label_1nlk4_37", "invite-users-dialog-roles-content": "_invite-users-dialog-roles-content_1nlk4_41", "inviteUsersDialogRolesContent": "_invite-users-dialog-roles-content_1nlk4_41", "form-error-message": "_form-error-message_1nlk4_46", "formErrorMessage": "_form-error-message_1nlk4_46", "invite-users-emails-textarea": "_invite-users-emails-textarea_1nlk4_50", "inviteUsersEmailsTextarea": "_invite-users-emails-textarea_1nlk4_50", "add-token-dialog-tokens-field": "_add-token-dialog-tokens-field_1nlk4_56", "addTokenDialogTokensField": "_add-token-dialog-tokens-field_1nlk4_56" };
13023
13067
 
13024
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-WXwWQJ1n6ADT/sdk/admin/components/navbar.module.css.js
13025
- var digest48 = "acdaa5448fd420bf262ea9b3e76cdeea61f7f8cde590045d90c97e6a65befb8a";
13068
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-kUi6QAzxCy3b/sdk/admin/components/navbar.module.css.js
13069
+ var digest48 = "8fd65bd331ed18345788b519b9943cba29a341b40e0d52e8c48e7b599c510f3e";
13026
13070
  var css48 = `._navbar_641ya_1 {
13027
13071
  padding: var(--rs-space-4) var(--rs-space-7);
13028
13072
  border-bottom: 0.5px solid var(--rs-color-border-base-primary);
@@ -13060,10 +13104,10 @@ import {
13060
13104
  TextArea as TextArea2,
13061
13105
  toastManager as toastManager8
13062
13106
  } from "@raystack/apsara";
13063
- import { useContext as useContext4, useMemo as useMemo8 } from "react";
13107
+ import { useContext as useContext4, useMemo as useMemo9 } from "react";
13064
13108
 
13065
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-PX5ljuFxzV3D/sdk/admin/views/organizations/details/layout/layout.module.css.js
13066
- var digest49 = "eca2584d2e65315c49e4b11f746d8e05d973055861437e499d37682bff1b4f3b";
13109
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-1Q4BU2GaWK07/sdk/admin/views/organizations/details/layout/layout.module.css.js
13110
+ var digest49 = "a4991849ee736bebfc88755031b6d5a2a245669c930fda4dc820a6503b98eee7";
13067
13111
  var css49 = `._page_1nlk4_1 {
13068
13112
  width: 100%;
13069
13113
  height: 100vh;
@@ -13147,11 +13191,11 @@ var layout_module_css_default3 = { "page": "_page_1nlk4_1", "main_content": "_ma
13147
13191
  import {
13148
13192
  OrganizationSchema
13149
13193
  } from "@raystack/proton/frontier";
13150
- import { create as create8 } from "@bufbuild/protobuf";
13194
+ import { create as create9 } from "@bufbuild/protobuf";
13151
13195
  import { createContext as createContext4 } from "react";
13152
13196
  var defaultOrganiztionContextValue = {
13153
13197
  roles: [],
13154
- organization: create8(OrganizationSchema),
13198
+ organization: create9(OrganizationSchema),
13155
13199
  updateOrganization: async () => {
13156
13200
  },
13157
13201
  isBillingAccountLoading: false,
@@ -13169,8 +13213,6 @@ var defaultOrganiztionContextValue = {
13169
13213
  onChange: () => {
13170
13214
  }
13171
13215
  },
13172
- orgMembersMap: {},
13173
- isOrgMembersMapLoading: false,
13174
13216
  updateKYCDetails: () => {
13175
13217
  },
13176
13218
  kycDetails: void 0,
@@ -13196,16 +13238,16 @@ var DEFAULT_INVITE_ROLE = "app_organization_viewer";
13196
13238
 
13197
13239
  // admin/views/organizations/details/layout/invite-users-dialog.tsx
13198
13240
  import {
13199
- useMutation as useMutation7,
13200
- createConnectQueryKey as createConnectQueryKey4,
13201
- useTransport as useTransport5
13241
+ useMutation as useMutation8,
13242
+ createConnectQueryKey as createConnectQueryKey5,
13243
+ useTransport as useTransport6
13202
13244
  } from "@connectrpc/connect-query";
13203
- import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
13245
+ import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
13204
13246
  import {
13205
- FrontierServiceQueries as FrontierServiceQueries14,
13247
+ FrontierServiceQueries as FrontierServiceQueries15,
13206
13248
  CreateOrganizationInvitationRequestSchema
13207
13249
  } from "@raystack/proton/frontier";
13208
- import { create as create9 } from "@bufbuild/protobuf";
13250
+ import { create as create10 } from "@bufbuild/protobuf";
13209
13251
  import { jsx as jsx67, jsxs as jsxs51 } from "react/jsx-runtime";
13210
13252
  var inviteSchema = objectType({
13211
13253
  role: stringType().min(1, { message: "Role is required" }),
@@ -13218,10 +13260,10 @@ var inviteSchema = objectType({
13218
13260
  var InviteUsersDialog = ({ onOpenChange }) => {
13219
13261
  const t = useTerminology();
13220
13262
  const { roles = [], organization } = useContext4(OrganizationContext);
13221
- const queryClient = useQueryClient6();
13222
- const transport = useTransport5();
13263
+ const queryClient = useQueryClient7();
13264
+ const transport = useTransport6();
13223
13265
  const organizationId = organization?.id || "";
13224
- const defaultRoleId = useMemo8(
13266
+ const defaultRoleId = useMemo9(
13225
13267
  () => roles?.find((role) => role.name === DEFAULT_INVITE_ROLE)?.id,
13226
13268
  [roles]
13227
13269
  );
@@ -13231,13 +13273,13 @@ var InviteUsersDialog = ({ onOpenChange }) => {
13231
13273
  role: defaultRoleId
13232
13274
  }
13233
13275
  });
13234
- const { mutateAsync: createInvitation } = useMutation7(
13235
- FrontierServiceQueries14.createOrganizationInvitation,
13276
+ const { mutateAsync: createInvitation } = useMutation8(
13277
+ FrontierServiceQueries15.createOrganizationInvitation,
13236
13278
  {
13237
13279
  onSuccess: (data) => {
13238
13280
  queryClient.invalidateQueries({
13239
- queryKey: createConnectQueryKey4({
13240
- schema: FrontierServiceQueries14.listOrganizationInvitations,
13281
+ queryKey: createConnectQueryKey5({
13282
+ schema: FrontierServiceQueries15.listOrganizationInvitations,
13241
13283
  transport,
13242
13284
  input: { orgId: organizationId },
13243
13285
  cardinality: "finite"
@@ -13257,7 +13299,7 @@ var InviteUsersDialog = ({ onOpenChange }) => {
13257
13299
  return;
13258
13300
  try {
13259
13301
  await createInvitation(
13260
- create9(CreateOrganizationInvitationRequestSchema, {
13302
+ create10(CreateOrganizationInvitationRequestSchema, {
13261
13303
  orgId: organizationId,
13262
13304
  userIds: data.emails,
13263
13305
  roleIds: data.role ? [data.role] : []
@@ -13360,8 +13402,8 @@ import {
13360
13402
  import { useContext as useContext5 } from "react";
13361
13403
  import { Controller as Controller4, FormProvider as FormProvider2, useForm as useForm5 } from "react-hook-form";
13362
13404
 
13363
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-wD2SKaDBz8Wd/sdk/admin/views/organizations/details/layout/layout.module.css.js
13364
- var digest50 = "560a32aa91ea95ea1e34a0c7568c42dcad9e3ea772451e380e8b5f2b6eae708d";
13405
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-sFrqdyj3Gp9K/sdk/admin/views/organizations/details/layout/layout.module.css.js
13406
+ var digest50 = "9f0d28a1a7a3502a6b0a088589343f0af5749124a05ea9d112ee74e38595e199";
13365
13407
  var css50 = `._page_1nlk4_1 {
13366
13408
  width: 100%;
13367
13409
  height: 100vh;
@@ -13443,10 +13485,10 @@ var layout_module_css_default4 = { "page": "_page_1nlk4_1", "main_content": "_ma
13443
13485
 
13444
13486
  // admin/views/organizations/details/layout/add-tokens-dialog.tsx
13445
13487
  import { zodResolver as zodResolver5 } from "@hookform/resolvers/zod";
13446
- import { useMutation as useMutation8, createConnectQueryKey as createConnectQueryKey5, useTransport as useTransport6 } from "@connectrpc/connect-query";
13447
- import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
13448
- import { AdminServiceQueries as AdminServiceQueries13, CheckoutProductBodySchema, DelegatedCheckoutRequestSchema, FrontierServiceQueries as FrontierServiceQueries15 } from "@raystack/proton/frontier";
13449
- import { create as create10 } from "@bufbuild/protobuf";
13488
+ import { useMutation as useMutation9, createConnectQueryKey as createConnectQueryKey6, useTransport as useTransport7 } from "@connectrpc/connect-query";
13489
+ import { useQueryClient as useQueryClient8 } from "@tanstack/react-query";
13490
+ import { AdminServiceQueries as AdminServiceQueries13, CheckoutProductBodySchema, DelegatedCheckoutRequestSchema, FrontierServiceQueries as FrontierServiceQueries16 } from "@raystack/proton/frontier";
13491
+ import { create as create11 } from "@bufbuild/protobuf";
13450
13492
  import { jsx as jsx68, jsxs as jsxs52 } from "react/jsx-runtime";
13451
13493
  var addTokensSchema = objectType({
13452
13494
  product: stringType(),
@@ -13456,9 +13498,14 @@ var addTokensSchema = objectType({
13456
13498
  }).min(1).transform((num) => num.toString())
13457
13499
  });
13458
13500
  var AddTokensDialog = ({ onOpenChange }) => {
13459
- const { organization, billingAccount, fetchTokenBalance, tokenProductId } = useContext5(OrganizationContext);
13460
- const queryClient = useQueryClient7();
13461
- const transport = useTransport6();
13501
+ const {
13502
+ organization,
13503
+ billingAccount,
13504
+ fetchTokenBalance,
13505
+ tokenProductId
13506
+ } = useContext5(OrganizationContext);
13507
+ const queryClient = useQueryClient8();
13508
+ const transport = useTransport7();
13462
13509
  const organisationId = organization?.id || "";
13463
13510
  const billingAccountId = billingAccount?.id || "";
13464
13511
  const methods = useForm5({
@@ -13468,13 +13515,13 @@ var AddTokensDialog = ({ onOpenChange }) => {
13468
13515
  product: tokenProductId || defaultConfig.token_product_id || "token"
13469
13516
  }
13470
13517
  });
13471
- const { mutateAsync: delegatedCheckout } = useMutation8(
13518
+ const { mutateAsync: delegatedCheckout } = useMutation9(
13472
13519
  AdminServiceQueries13.delegatedCheckout,
13473
13520
  {
13474
13521
  onSuccess: () => {
13475
13522
  queryClient.invalidateQueries({
13476
- queryKey: createConnectQueryKey5({
13477
- schema: FrontierServiceQueries15.searchOrganizationTokens,
13523
+ queryKey: createConnectQueryKey6({
13524
+ schema: FrontierServiceQueries16.searchOrganizationTokens,
13478
13525
  transport,
13479
13526
  input: { id: organisationId },
13480
13527
  cardinality: "infinite"
@@ -13494,14 +13541,15 @@ var AddTokensDialog = ({ onOpenChange }) => {
13494
13541
  }
13495
13542
  }
13496
13543
  );
13544
+ const canCheckout = !!organisationId && !!billingAccountId;
13497
13545
  const onSubmit = async (product_body) => {
13498
- if (!organisationId)
13546
+ if (!canCheckout)
13499
13547
  return;
13500
13548
  await delegatedCheckout(
13501
- create10(DelegatedCheckoutRequestSchema, {
13549
+ create11(DelegatedCheckoutRequestSchema, {
13502
13550
  orgId: organisationId,
13503
13551
  billingId: billingAccountId,
13504
- productBody: create10(CheckoutProductBodySchema, {
13552
+ productBody: create11(CheckoutProductBodySchema, {
13505
13553
  product: product_body.product,
13506
13554
  quantity: BigInt(product_body.quantity)
13507
13555
  })
@@ -13558,6 +13606,7 @@ var AddTokensDialog = ({ onOpenChange }) => {
13558
13606
  "data-test-id": "add-tokens-invite-button",
13559
13607
  type: "submit",
13560
13608
  loaderText: "Adding...",
13609
+ disabled: !canCheckout || isSubmitting,
13561
13610
  loading: isSubmitting,
13562
13611
  children: "Add"
13563
13612
  }
@@ -13567,7 +13616,7 @@ var AddTokensDialog = ({ onOpenChange }) => {
13567
13616
  };
13568
13617
 
13569
13618
  // admin/views/organizations/details/layout/navbar.tsx
13570
- import { useContext as useContext6, useState as useState19 } from "react";
13619
+ import { useContext as useContext6, useState as useState20 } from "react";
13571
13620
  import { Fragment as Fragment13, jsx as jsx69, jsxs as jsxs53 } from "react/jsx-runtime";
13572
13621
  var DropdownItem = ({ item }) => {
13573
13622
  return /* @__PURE__ */ jsxs53(
@@ -13595,11 +13644,11 @@ var NavbarActionMenu = ({
13595
13644
  onExportTokens
13596
13645
  }) => {
13597
13646
  const t = useTerminology();
13598
- const [isInviteUsersDialogOpen, setIsInviteUsersDialogOpen] = useState19(false);
13599
- const [isAddTokensDialogOpen, setIsAddTokensDialogOpen] = useState19(false);
13600
- const [isMembersDownloading, setIsMembersDownloading] = useState19(false);
13601
- const [isProjectsDownloading, setIsProjectsDownloading] = useState19(false);
13602
- const [isTokensDownloading, setIsTokensDownloading] = useState19(false);
13647
+ const [isInviteUsersDialogOpen, setIsInviteUsersDialogOpen] = useState20(false);
13648
+ const [isAddTokensDialogOpen, setIsAddTokensDialogOpen] = useState20(false);
13649
+ const [isMembersDownloading, setIsMembersDownloading] = useState20(false);
13650
+ const [isProjectsDownloading, setIsProjectsDownloading] = useState20(false);
13651
+ const [isTokensDownloading, setIsTokensDownloading] = useState20(false);
13603
13652
  const openInviteUsersDialog = () => {
13604
13653
  setIsInviteUsersDialogOpen(true);
13605
13654
  };
@@ -13868,8 +13917,8 @@ var OrganizationsDetailsNavabar = ({
13868
13917
  ] });
13869
13918
  };
13870
13919
 
13871
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-o5Qm9B4jOUlh/sdk/admin/views/organizations/details/layout/layout.module.css.js
13872
- var digest51 = "46c4d9e393db1ddd89fd4a723f1cc2d813d0dbe02a9f3e7c37366c98488fcd69";
13920
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-gP5nEfXniEQl/sdk/admin/views/organizations/details/layout/layout.module.css.js
13921
+ var digest51 = "9cd657322730d9bafce57133135e80bf8583c276c322b981410c03f05933ffa9";
13873
13922
  var css51 = `._page_1nlk4_1 {
13874
13923
  width: 100%;
13875
13924
  height: 100vh;
@@ -13958,8 +14007,8 @@ import { Avatar as Avatar10, getAvatarColor as getAvatarColor7, SidePanel as Sid
13958
14007
  // admin/views/organizations/details/side-panel/org-details-section.tsx
13959
14008
  import { Flex as Flex47, List as List8, Text as Text32, CopyButton as CopyButton3, Tooltip as Tooltip3 } from "@raystack/apsara";
13960
14009
 
13961
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-01aY9ptcPvMG/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
13962
- var digest52 = "328d26ff7a7d92c4277c072e0b981db8f619246e76ac7d3f0da33b25e59b6c82";
14010
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-G6ADHGVvhdLM/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14011
+ var digest52 = "0ce0ed13a10b41c13bac5d04444bdfa3afb2964906befedabef1e753c719e614";
13963
14012
  var css52 = `._side-panel-section-item-label_slrfc_1 {
13964
14013
  width: 120px;
13965
14014
  }
@@ -14086,8 +14135,8 @@ var OrganizationDetailsSection = ({
14086
14135
  import { Flex as Flex48, List as List9, Text as Text33, Link as Link2, Tooltip as Tooltip4 } from "@raystack/apsara";
14087
14136
  import { useContext as useContext8 } from "react";
14088
14137
 
14089
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-Qm0Av9kNzGTx/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14090
- var digest53 = "739e1db2977e10169a6f6e93cb347234a8bf792374e8df34ad4a3119582dd1cc";
14138
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-w2pVcZrxV88F/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14139
+ var digest53 = "5258b692ca59df5bca6c2a7c18529ce0f4cc3151443d0ea0a12ee5db5cea55fa";
14091
14140
  var css53 = `._side-panel-section-item-label_slrfc_1 {
14092
14141
  width: 120px;
14093
14142
  }
@@ -14213,8 +14262,8 @@ var KYCDetailsSection = () => {
14213
14262
  import { useContext as useContext9 } from "react";
14214
14263
  import { List as List10, Text as Text34, Flex as Flex49 } from "@raystack/apsara";
14215
14264
 
14216
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-vXkNl8xHJ5Nk/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14217
- var digest54 = "0a22e0934dfe4f0dae090f7ee508d5383ac5748578cc6647e2a4f455c94ff48b";
14265
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-8KVk9Wc3f5u5/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14266
+ var digest54 = "e30a237221b8a54ab484c80d8fa08e499b8772a5026fff8c1765f43f74ca37ae";
14218
14267
  var css54 = `._side-panel-section-item-label_slrfc_1 {
14219
14268
  width: 120px;
14220
14269
  }
@@ -14278,17 +14327,17 @@ var css54 = `._side-panel-section-item-label_slrfc_1 {
14278
14327
  var side_panel_module_css_default8 = { "side-panel-section-item-label": "_side-panel-section-item-label_slrfc_1", "sidePanelSectionItemLabel": "_side-panel-section-item-label_slrfc_1", "org-details-section-org-id": "_org-details-section-org-id_slrfc_5", "orgDetailsSectionOrgId": "_org-details-section-org-id_slrfc_5", "kyc_link": "_kyc_link_slrfc_6", "kycLink": "_kyc_link_slrfc_6", "kyc-status-icon": "_kyc-status-icon_slrfc_13", "kycStatusIcon": "_kyc-status-icon_slrfc_13", "billing-header": "_billing-header_slrfc_18", "billingHeader": "_billing-header_slrfc_18", "billing-edit": "_billing-edit_slrfc_25", "billingEdit": "_billing-edit_slrfc_25", "billing-section": "_billing-section_slrfc_30", "billingSection": "_billing-section_slrfc_30", "billing-edit-disabled": "_billing-edit-disabled_slrfc_38", "billingEditDisabled": "_billing-edit-disabled_slrfc_38" };
14279
14328
 
14280
14329
  // admin/views/organizations/details/side-panel/plan-details-section.tsx
14281
- import { useQuery as useQuery14 } from "@connectrpc/connect-query";
14282
- import { FrontierServiceQueries as FrontierServiceQueries16, ListSubscriptionsRequestSchema, GetPlanRequestSchema } from "@raystack/proton/frontier";
14283
- import { create as create11 } from "@bufbuild/protobuf";
14330
+ import { useQuery as useQuery15 } from "@connectrpc/connect-query";
14331
+ import { FrontierServiceQueries as FrontierServiceQueries17, ListSubscriptionsRequestSchema, GetPlanRequestSchema } from "@raystack/proton/frontier";
14332
+ import { create as create12 } from "@bufbuild/protobuf";
14284
14333
  import { jsx as jsx72, jsxs as jsxs56 } from "react/jsx-runtime";
14285
14334
  var PlanDetailsSection = () => {
14286
14335
  const { billingAccount, organization } = useContext9(OrganizationContext);
14287
14336
  const billingAccountId = billingAccount?.id || "";
14288
14337
  const organizationId = organization?.id || "";
14289
- const { data: activeSubscription, isLoading: isSubscriptionLoading, error: subscriptionsError } = useQuery14(
14290
- FrontierServiceQueries16.listSubscriptions,
14291
- create11(ListSubscriptionsRequestSchema, {
14338
+ const { data: activeSubscription, isLoading: isSubscriptionLoading, error: subscriptionsError } = useQuery15(
14339
+ FrontierServiceQueries17.listSubscriptions,
14340
+ create12(ListSubscriptionsRequestSchema, {
14292
14341
  orgId: organizationId
14293
14342
  }),
14294
14343
  {
@@ -14304,9 +14353,9 @@ var PlanDetailsSection = () => {
14304
14353
  if (subscriptionsError) {
14305
14354
  console.error("Error fetching subscriptions:", subscriptionsError);
14306
14355
  }
14307
- const { data: planData, isLoading: isPlanLoading, error: planError } = useQuery14(
14308
- FrontierServiceQueries16.getPlan,
14309
- create11(GetPlanRequestSchema, {
14356
+ const { data: planData, isLoading: isPlanLoading, error: planError } = useQuery15(
14357
+ FrontierServiceQueries17.getPlan,
14358
+ create12(GetPlanRequestSchema, {
14310
14359
  id: activeSubscription?.planId ?? ""
14311
14360
  }),
14312
14361
  {
@@ -14344,8 +14393,8 @@ var PlanDetailsSection = () => {
14344
14393
  import { List as List11, Text as Text35, Flex as Flex50 } from "@raystack/apsara";
14345
14394
  import { CoinIcon, CoinColoredIcon } from "@raystack/apsara/icons";
14346
14395
 
14347
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-Cv6pClK6cP7H/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14348
- var digest55 = "fb0d97d10a84997cf9472da3fcd3b1d01e436420e39867859afb6065e4b84f21";
14396
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-B5XipOMP8Q23/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14397
+ var digest55 = "fed6d287d93ec9f5fdf2752006415cb10e0cafe0f38cfd794b1fbdb2c6ec3456";
14349
14398
  var css55 = `._side-panel-section-item-label_slrfc_1 {
14350
14399
  width: 120px;
14351
14400
  }
@@ -14409,10 +14458,10 @@ var css55 = `._side-panel-section-item-label_slrfc_1 {
14409
14458
  var side_panel_module_css_default9 = { "side-panel-section-item-label": "_side-panel-section-item-label_slrfc_1", "sidePanelSectionItemLabel": "_side-panel-section-item-label_slrfc_1", "org-details-section-org-id": "_org-details-section-org-id_slrfc_5", "orgDetailsSectionOrgId": "_org-details-section-org-id_slrfc_5", "kyc_link": "_kyc_link_slrfc_6", "kycLink": "_kyc_link_slrfc_6", "kyc-status-icon": "_kyc-status-icon_slrfc_13", "kycStatusIcon": "_kyc-status-icon_slrfc_13", "billing-header": "_billing-header_slrfc_18", "billingHeader": "_billing-header_slrfc_18", "billing-edit": "_billing-edit_slrfc_25", "billingEdit": "_billing-edit_slrfc_25", "billing-section": "_billing-section_slrfc_30", "billingSection": "_billing-section_slrfc_30", "billing-edit-disabled": "_billing-edit-disabled_slrfc_38", "billingEditDisabled": "_billing-edit-disabled_slrfc_38" };
14410
14459
 
14411
14460
  // admin/views/organizations/details/side-panel/tokens-details-section.tsx
14412
- import { useContext as useContext10, useEffect as useEffect8 } from "react";
14413
- import { useQuery as useQuery15 } from "@connectrpc/connect-query";
14414
- import { FrontierServiceQueries as FrontierServiceQueries17, TotalDebitedTransactionsRequestSchema } from "@raystack/proton/frontier";
14415
- import { create as create12 } from "@bufbuild/protobuf";
14461
+ import { useContext as useContext10, useEffect as useEffect10 } from "react";
14462
+ import { useQuery as useQuery16 } from "@connectrpc/connect-query";
14463
+ import { FrontierServiceQueries as FrontierServiceQueries18, TotalDebitedTransactionsRequestSchema } from "@raystack/proton/frontier";
14464
+ import { create as create13 } from "@bufbuild/protobuf";
14416
14465
  import { jsx as jsx73, jsxs as jsxs57 } from "react/jsx-runtime";
14417
14466
  var TokensDetailsSection = () => {
14418
14467
  const {
@@ -14420,13 +14469,14 @@ var TokensDetailsSection = () => {
14420
14469
  billingAccount,
14421
14470
  organization,
14422
14471
  isTokenBalanceLoading,
14472
+ isBillingAccountLoading,
14423
14473
  billingAccountDetails
14424
14474
  } = useContext10(OrganizationContext);
14425
14475
  const organizationId = organization?.id || "";
14426
14476
  const billingAccountId = billingAccount?.id || "";
14427
- const { data: tokensUsed = "0", isLoading: isTokensLoading, error } = useQuery15(
14428
- FrontierServiceQueries17.totalDebitedTransactions,
14429
- create12(TotalDebitedTransactionsRequestSchema, {
14477
+ const { data: tokensUsed = "0", isLoading: isTokensLoading, error } = useQuery16(
14478
+ FrontierServiceQueries18.totalDebitedTransactions,
14479
+ create13(TotalDebitedTransactionsRequestSchema, {
14430
14480
  orgId: organizationId,
14431
14481
  billingId: billingAccountId
14432
14482
  }),
@@ -14435,12 +14485,12 @@ var TokensDetailsSection = () => {
14435
14485
  select: (data) => String(data?.debited?.amount || "0")
14436
14486
  }
14437
14487
  );
14438
- useEffect8(() => {
14488
+ useEffect10(() => {
14439
14489
  if (error) {
14440
14490
  console.error("Error fetching debited transactions:", error);
14441
14491
  }
14442
14492
  }, [error]);
14443
- const isLoading = isTokensLoading;
14493
+ const isLoading = isBillingAccountLoading || isTokensLoading;
14444
14494
  return /* @__PURE__ */ jsxs57(List11, { children: [
14445
14495
  /* @__PURE__ */ jsx73(List11.Header, { children: "Tokens" }),
14446
14496
  /* @__PURE__ */ jsxs57(List11.Item, { children: [
@@ -14478,8 +14528,8 @@ var TokensDetailsSection = () => {
14478
14528
  // admin/views/organizations/details/side-panel/billing-details-section.tsx
14479
14529
  import { Amount as Amount4, CopyButton as CopyButton4, Flex as Flex51, IconButton as IconButton11, Link as Link3, List as List12, Text as Text36, Tooltip as Tooltip5, toastManager as toastManager11 } from "@raystack/apsara";
14480
14530
 
14481
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-V6l2IyCoMsyk/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14482
- var digest56 = "8f2811d1c2e42a6b8abe7f513e27d3174e6f00c44af1ed71e5f558fea20d5134";
14531
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-c4B87DmjiXtv/sdk/admin/views/organizations/details/side-panel/side-panel.module.css.js
14532
+ var digest56 = "b53852078592243858b880e5385d8b37cdadf542937eae57755da1691a96db6e";
14483
14533
  var css56 = `._side-panel-section-item-label_slrfc_1 {
14484
14534
  width: 120px;
14485
14535
  }
@@ -14543,18 +14593,22 @@ var css56 = `._side-panel-section-item-label_slrfc_1 {
14543
14593
  var side_panel_module_css_default10 = { "side-panel-section-item-label": "_side-panel-section-item-label_slrfc_1", "sidePanelSectionItemLabel": "_side-panel-section-item-label_slrfc_1", "org-details-section-org-id": "_org-details-section-org-id_slrfc_5", "orgDetailsSectionOrgId": "_org-details-section-org-id_slrfc_5", "kyc_link": "_kyc_link_slrfc_6", "kycLink": "_kyc_link_slrfc_6", "kyc-status-icon": "_kyc-status-icon_slrfc_13", "kycStatusIcon": "_kyc-status-icon_slrfc_13", "billing-header": "_billing-header_slrfc_18", "billingHeader": "_billing-header_slrfc_18", "billing-edit": "_billing-edit_slrfc_25", "billingEdit": "_billing-edit_slrfc_25", "billing-section": "_billing-section_slrfc_30", "billingSection": "_billing-section_slrfc_30", "billing-edit-disabled": "_billing-edit-disabled_slrfc_38", "billingEditDisabled": "_billing-edit-disabled_slrfc_38" };
14544
14594
 
14545
14595
  // admin/views/organizations/details/side-panel/billing-details-section.tsx
14546
- import { useContext as useContext11, useEffect as useEffect9 } from "react";
14547
- import { useMutation as useMutation9, useQuery as useQuery16 } from "@connectrpc/connect-query";
14548
- import { CreateCheckoutRequestSchema, FrontierServiceQueries as FrontierServiceQueries18, GetUpcomingInvoiceRequestSchema } from "@raystack/proton/frontier";
14549
- import { create as create13 } from "@bufbuild/protobuf";
14596
+ import { useContext as useContext11, useEffect as useEffect11 } from "react";
14597
+ import { useMutation as useMutation10, useQuery as useQuery17 } from "@connectrpc/connect-query";
14598
+ import { CreateCheckoutRequestSchema, FrontierServiceQueries as FrontierServiceQueries19, GetUpcomingInvoiceRequestSchema } from "@raystack/proton/frontier";
14599
+ import { create as create14 } from "@bufbuild/protobuf";
14550
14600
  import { jsx as jsx74, jsxs as jsxs58 } from "react/jsx-runtime";
14551
14601
  var BillingDetailsSection = () => {
14552
- const { billingAccount, organization } = useContext11(OrganizationContext);
14602
+ const { billingAccount, organization, isBillingAccountLoading } = useContext11(OrganizationContext);
14553
14603
  const organizationId = organization?.id || "";
14554
14604
  const billingAccountId = billingAccount?.id || "";
14555
- const { data: upcomingInvoice, isLoading, error } = useQuery16(
14556
- FrontierServiceQueries18.getUpcomingInvoice,
14557
- create13(GetUpcomingInvoiceRequestSchema, {
14605
+ const {
14606
+ data: upcomingInvoice,
14607
+ isLoading: isUpcomingInvoiceLoading,
14608
+ error
14609
+ } = useQuery17(
14610
+ FrontierServiceQueries19.getUpcomingInvoice,
14611
+ create14(GetUpcomingInvoiceRequestSchema, {
14558
14612
  orgId: organizationId,
14559
14613
  billingId: billingAccountId
14560
14614
  }),
@@ -14563,14 +14617,15 @@ var BillingDetailsSection = () => {
14563
14617
  select: (data) => data?.invoice
14564
14618
  }
14565
14619
  );
14566
- useEffect9(() => {
14620
+ useEffect11(() => {
14567
14621
  if (error) {
14568
14622
  console.error("Error fetching upcoming invoice:", error);
14569
14623
  }
14570
14624
  }, [error]);
14625
+ const isLoading = isBillingAccountLoading || isUpcomingInvoiceLoading;
14571
14626
  const due_date = upcomingInvoice?.dueDate || upcomingInvoice?.periodEndAt;
14572
14627
  const stripeLink = billingAccount?.providerId ? "https://dashboard.stripe.com/customers/" + billingAccount?.providerId : "";
14573
- const { mutateAsync: createCheckout, isPending: isPortalLoading } = useMutation9(FrontierServiceQueries18.createCheckout, {
14628
+ const { mutateAsync: createCheckout, isPending: isPortalLoading } = useMutation10(FrontierServiceQueries19.createCheckout, {
14574
14629
  onError: (error2) => {
14575
14630
  toastManager11.add({
14576
14631
  title: "Something went wrong",
@@ -14587,7 +14642,7 @@ var BillingDetailsSection = () => {
14587
14642
  const returnUrl = window.location.href;
14588
14643
  try {
14589
14644
  const resp = await createCheckout(
14590
- create13(CreateCheckoutRequestSchema, {
14645
+ create14(CreateCheckoutRequestSchema, {
14591
14646
  orgId: organizationId,
14592
14647
  cancelUrl: returnUrl,
14593
14648
  successUrl: returnUrl,
@@ -14704,7 +14759,7 @@ function OrgSidePanel({ organization }) {
14704
14759
  }
14705
14760
 
14706
14761
  // admin/views/organizations/details/layout/index.tsx
14707
- import { useState as useState21 } from "react";
14762
+ import { useState as useState22 } from "react";
14708
14763
  import { OrganizationIcon as OrganizationIcon4 } from "@raystack/apsara/icons";
14709
14764
 
14710
14765
  // admin/views/organizations/details/edit/kyc.tsx
@@ -14722,8 +14777,8 @@ import {
14722
14777
  toastManager as toastManager12
14723
14778
  } from "@raystack/apsara";
14724
14779
 
14725
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-3f77PAEIqXU6/sdk/admin/views/organizations/details/edit/edit.module.css.js
14726
- var digest57 = "2e0c25dd4514a970a6f24f45df850f96cc279514ad7cf3c73b488940d3354755";
14780
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-4o0DDhH1IFpp/sdk/admin/views/organizations/details/edit/edit.module.css.js
14781
+ var digest57 = "d2614dc4805b0c71e13a763c3cba5171f9b5fe3c52b4ac9bc79dab15e02fa044";
14727
14782
  var css57 = `._drawer-content_18xgg_1 {
14728
14783
  min-width: 500px;
14729
14784
  padding: 0;
@@ -14775,10 +14830,10 @@ var edit_module_css_default = { "drawer-content": "_drawer-content_18xgg_1", "dr
14775
14830
  import { useContext as useContext12 } from "react";
14776
14831
  import { Controller as Controller5, useForm as useForm6 } from "react-hook-form";
14777
14832
  import { zodResolver as zodResolver6 } from "@hookform/resolvers/zod";
14778
- import { useMutation as useMutation10, createConnectQueryKey as createConnectQueryKey6, useTransport as useTransport7 } from "@connectrpc/connect-query";
14779
- import { useQueryClient as useQueryClient8 } from "@tanstack/react-query";
14780
- import { AdminServiceQueries as AdminServiceQueries14, FrontierServiceQueries as FrontierServiceQueries19, SetOrganizationKycRequestSchema } from "@raystack/proton/frontier";
14781
- import { create as create14 } from "@bufbuild/protobuf";
14833
+ import { useMutation as useMutation11, createConnectQueryKey as createConnectQueryKey7, useTransport as useTransport8 } from "@connectrpc/connect-query";
14834
+ import { useQueryClient as useQueryClient9 } from "@tanstack/react-query";
14835
+ import { AdminServiceQueries as AdminServiceQueries14, FrontierServiceQueries as FrontierServiceQueries20, SetOrganizationKycRequestSchema } from "@raystack/proton/frontier";
14836
+ import { create as create15 } from "@bufbuild/protobuf";
14782
14837
  import { Fragment as Fragment15, jsx as jsx76, jsxs as jsxs60 } from "react/jsx-runtime";
14783
14838
  var kycUpdateSchema = external_exports.object({
14784
14839
  status: external_exports.boolean(),
@@ -14794,8 +14849,8 @@ var kycUpdateSchema = external_exports.object({
14794
14849
  });
14795
14850
  function EditKYCPanel({ open = false, onClose }) {
14796
14851
  const { organization, kycDetails, updateKYCDetails } = useContext12(OrganizationContext);
14797
- const queryClient = useQueryClient8();
14798
- const transport = useTransport7();
14852
+ const queryClient = useQueryClient9();
14853
+ const transport = useTransport8();
14799
14854
  const orgId = organization?.id || "";
14800
14855
  const {
14801
14856
  handleSubmit,
@@ -14810,15 +14865,15 @@ function EditKYCPanel({ open = false, onClose }) {
14810
14865
  });
14811
14866
  const {
14812
14867
  mutateAsync: setOrganizationKycMutation
14813
- } = useMutation10(AdminServiceQueries14.setOrganizationKyc, {
14868
+ } = useMutation11(AdminServiceQueries14.setOrganizationKyc, {
14814
14869
  onSuccess: (data) => {
14815
14870
  const newKycDetails = data.organizationKyc;
14816
14871
  if (newKycDetails) {
14817
14872
  updateKYCDetails(newKycDetails);
14818
14873
  }
14819
14874
  queryClient.invalidateQueries({
14820
- queryKey: createConnectQueryKey6({
14821
- schema: FrontierServiceQueries19.getOrganizationKyc,
14875
+ queryKey: createConnectQueryKey7({
14876
+ schema: FrontierServiceQueries20.getOrganizationKyc,
14822
14877
  transport,
14823
14878
  input: { orgId },
14824
14879
  cardinality: "finite"
@@ -14837,7 +14892,7 @@ function EditKYCPanel({ open = false, onClose }) {
14837
14892
  return;
14838
14893
  }
14839
14894
  await setOrganizationKycMutation(
14840
- create14(SetOrganizationKycRequestSchema, {
14895
+ create15(SetOrganizationKycRequestSchema, {
14841
14896
  orgId,
14842
14897
  status: data.status,
14843
14898
  link: data.link || ""
@@ -14947,10 +15002,10 @@ function EditKYCPanel({ open = false, onClose }) {
14947
15002
  }
14948
15003
 
14949
15004
  // admin/views/organizations/details/edit/organization.tsx
14950
- import { useContext as useContext13, useEffect as useEffect10, useState as useState20 } from "react";
15005
+ import { useContext as useContext13, useEffect as useEffect12, useState as useState21 } from "react";
14951
15006
 
14952
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-m75IFU6ZqvIA/sdk/admin/views/organizations/details/edit/edit.module.css.js
14953
- var digest58 = "8b21cb68f22581517f4deafac31b700e0c6df8e86e365b11bd47569c2539bbf4";
15007
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-pHdCAAUIEpUD/sdk/admin/views/organizations/details/edit/edit.module.css.js
15008
+ var digest58 = "fd8777dada8a2a3d08fcef36be6b705f4b181acfabd58d5ed14f2461285a4285";
14954
15009
  var css58 = `._drawer-content_18xgg_1 {
14955
15010
  min-width: 500px;
14956
15011
  padding: 0;
@@ -15013,10 +15068,10 @@ import {
15013
15068
  } from "@raystack/apsara";
15014
15069
  import { Controller as Controller6, useForm as useForm7 } from "react-hook-form";
15015
15070
  import { zodResolver as zodResolver7 } from "@hookform/resolvers/zod";
15016
- import { useMutation as useMutation11, createConnectQueryKey as createConnectQueryKey7, useTransport as useTransport8 } from "@connectrpc/connect-query";
15017
- import { useQueryClient as useQueryClient9 } from "@tanstack/react-query";
15018
- import { FrontierServiceQueries as FrontierServiceQueries20, UpdateOrganizationRequestSchema } from "@raystack/proton/frontier";
15019
- import { create as create15 } from "@bufbuild/protobuf";
15071
+ import { useMutation as useMutation12, createConnectQueryKey as createConnectQueryKey8, useTransport as useTransport9 } from "@connectrpc/connect-query";
15072
+ import { useQueryClient as useQueryClient10 } from "@tanstack/react-query";
15073
+ import { FrontierServiceQueries as FrontierServiceQueries21, UpdateOrganizationRequestSchema } from "@raystack/proton/frontier";
15074
+ import { create as create16 } from "@bufbuild/protobuf";
15020
15075
  import { Fragment as Fragment16, jsx as jsx77, jsxs as jsxs61 } from "react/jsx-runtime";
15021
15076
  var orgUpdateSchema = external_exports.object({
15022
15077
  avatar: external_exports.string().optional(),
@@ -15057,11 +15112,11 @@ function getDefaultValue(organization, industries) {
15057
15112
  function EditOrganizationPanel({ open = false, onClose }) {
15058
15113
  const t = useTerminology();
15059
15114
  const { organization, appUrl, countries: countriesFromContext = [], organizationTypes: industries = [] } = useContext13(OrganizationContext);
15060
- const [countries, setCountries] = useState20(countriesFromContext);
15061
- const queryClient = useQueryClient9();
15062
- const transport = useTransport8();
15115
+ const [countries, setCountries] = useState21(countriesFromContext);
15116
+ const queryClient = useQueryClient10();
15117
+ const transport = useTransport9();
15063
15118
  const orgId = organization?.id || "";
15064
- useEffect10(() => {
15119
+ useEffect12(() => {
15065
15120
  if (countriesFromContext.length > 0)
15066
15121
  setCountries(countriesFromContext);
15067
15122
  }, [countriesFromContext]);
@@ -15080,11 +15135,11 @@ function EditOrganizationPanel({ open = false, onClose }) {
15080
15135
  mutateAsync: updateOrganizationMutation,
15081
15136
  error: mutationError,
15082
15137
  isPending: isSubmitting
15083
- } = useMutation11(FrontierServiceQueries20.updateOrganization, {
15138
+ } = useMutation12(FrontierServiceQueries21.updateOrganization, {
15084
15139
  onSuccess: () => {
15085
15140
  queryClient.invalidateQueries({
15086
- queryKey: createConnectQueryKey7({
15087
- schema: FrontierServiceQueries20.getOrganization,
15141
+ queryKey: createConnectQueryKey8({
15142
+ schema: FrontierServiceQueries21.getOrganization,
15088
15143
  transport,
15089
15144
  input: { id: orgId },
15090
15145
  cardinality: "finite"
@@ -15093,7 +15148,7 @@ function EditOrganizationPanel({ open = false, onClose }) {
15093
15148
  onClose();
15094
15149
  }
15095
15150
  });
15096
- useEffect10(() => {
15151
+ useEffect12(() => {
15097
15152
  if (mutationError) {
15098
15153
  if (mutationError.message?.includes("already exists")) {
15099
15154
  setError("name", { message: `${t.organization({ case: "capital" })} name already exists` });
@@ -15114,7 +15169,7 @@ function EditOrganizationPanel({ open = false, onClose }) {
15114
15169
  country: data.country
15115
15170
  }
15116
15171
  };
15117
- await updateOrganizationMutation(create15(UpdateOrganizationRequestSchema, {
15172
+ await updateOrganizationMutation(create16(UpdateOrganizationRequestSchema, {
15118
15173
  id: orgId,
15119
15174
  body: payload
15120
15175
  }));
@@ -15327,8 +15382,8 @@ import {
15327
15382
  toastManager as toastManager13
15328
15383
  } from "@raystack/apsara";
15329
15384
 
15330
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-H1InLQd04q1l/sdk/admin/views/organizations/details/edit/edit.module.css.js
15331
- var digest59 = "f97115552dd19886616d0292250225a27475f90245bd638cdde2a0f72c5fd22c";
15385
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-o8ohmLd9t994/sdk/admin/views/organizations/details/edit/edit.module.css.js
15386
+ var digest59 = "12e29b96b0359b66ab94edf4f7cd21e2556f0db2d3a429cc260a64cb84523704";
15332
15387
  var css59 = `._drawer-content_18xgg_1 {
15333
15388
  min-width: 500px;
15334
15389
  padding: 0;
@@ -15377,15 +15432,15 @@ var css59 = `._drawer-content_18xgg_1 {
15377
15432
  var edit_module_css_default3 = { "drawer-content": "_drawer-content_18xgg_1", "drawerContent": "_drawer-content_18xgg_1", "side-panel": "_side-panel_18xgg_7", "sidePanel": "_side-panel_18xgg_7", "side-panel-form": "_side-panel-form_18xgg_15", "sidePanelForm": "_side-panel-form_18xgg_15", "side-panel-content": "_side-panel-content_18xgg_22", "sidePanelContent": "_side-panel-content_18xgg_22", "side-panel-footer": "_side-panel-footer_18xgg_26", "sidePanelFooter": "_side-panel-footer_18xgg_26", "select-content": "_select-content_18xgg_31", "selectContent": "_select-content_18xgg_31" };
15378
15433
 
15379
15434
  // admin/views/organizations/details/edit/billing.tsx
15380
- import { useCallback as useCallback7, useContext as useContext14, useEffect as useEffect11, useMemo as useMemo9 } from "react";
15435
+ import { useCallback as useCallback9, useContext as useContext14, useEffect as useEffect13, useMemo as useMemo10 } from "react";
15381
15436
  import { useForm as useForm8 } from "react-hook-form";
15382
15437
  import { zodResolver as zodResolver8 } from "@hookform/resolvers/zod";
15383
- import { useMutation as useMutation12 } from "@connectrpc/connect-query";
15438
+ import { useMutation as useMutation13 } from "@connectrpc/connect-query";
15384
15439
  import {
15385
15440
  AdminServiceQueries as AdminServiceQueries15,
15386
15441
  UpdateBillingAccountDetailsRequestSchema
15387
15442
  } from "@raystack/proton/frontier";
15388
- import { create as create16 } from "@bufbuild/protobuf";
15443
+ import { create as create17 } from "@bufbuild/protobuf";
15389
15444
  import { jsx as jsx78, jsxs as jsxs62 } from "react/jsx-runtime";
15390
15445
  var billingDetailsUpdateSchema = external_exports.object({
15391
15446
  tokenPaymentType: external_exports.enum(["prepaid", "postpaid"]),
@@ -15441,7 +15496,7 @@ function EditBillingPanel({ open = false, onClose }) {
15441
15496
  } = useForm8({
15442
15497
  resolver: zodResolver8(billingDetailsUpdateSchema)
15443
15498
  });
15444
- const billingDetailsData = useMemo9(() => {
15499
+ const billingDetailsData = useMemo10(() => {
15445
15500
  const creditMin = billingAccountDetails?.creditMin || 0n;
15446
15501
  const absoluteCreditMin = creditMin < 0n ? creditMin * BigInt(-1) : creditMin;
15447
15502
  const dueInDays = billingAccountDetails?.dueInDays || 0n;
@@ -15452,12 +15507,12 @@ function EditBillingPanel({ open = false, onClose }) {
15452
15507
  dueInDays: dueInDays.toString()
15453
15508
  };
15454
15509
  }, [billingAccountDetails]);
15455
- useEffect11(() => {
15510
+ useEffect13(() => {
15456
15511
  if (billingDetailsData) {
15457
15512
  reset(billingDetailsData);
15458
15513
  }
15459
15514
  }, [billingDetailsData, reset]);
15460
- const { mutateAsync: updateBillingDetails } = useMutation12(
15515
+ const { mutateAsync: updateBillingDetails } = useMutation13(
15461
15516
  AdminServiceQueries15.updateBillingAccountDetails,
15462
15517
  {
15463
15518
  onError: (error) => {
@@ -15470,13 +15525,16 @@ function EditBillingPanel({ open = false, onClose }) {
15470
15525
  }
15471
15526
  }
15472
15527
  );
15528
+ const canSave = !!organizationId && !!billingId;
15473
15529
  const onSubmit = async (data) => {
15530
+ if (!canSave)
15531
+ return;
15474
15532
  try {
15475
15533
  const creditMinValue = data.tokenPaymentType === "prepaid" ? 0n : BigInt(data.creditMin);
15476
15534
  const dueInDaysValue = data.tokenPaymentType === "prepaid" ? 0n : BigInt(data.dueInDays);
15477
15535
  const creditMinForApi = data.tokenPaymentType === "postpaid" ? -creditMinValue : creditMinValue;
15478
15536
  await updateBillingDetails(
15479
- create16(UpdateBillingAccountDetailsRequestSchema, {
15537
+ create17(UpdateBillingAccountDetailsRequestSchema, {
15480
15538
  orgId: organizationId,
15481
15539
  id: billingId,
15482
15540
  creditMin: creditMinForApi,
@@ -15494,7 +15552,7 @@ function EditBillingPanel({ open = false, onClose }) {
15494
15552
  console.error("Failed to update billing details:", error);
15495
15553
  }
15496
15554
  };
15497
- const onValueChange = useCallback7((value) => {
15555
+ const onValueChange = useCallback9((value) => {
15498
15556
  const paymentType = value;
15499
15557
  setValue("tokenPaymentType", paymentType);
15500
15558
  if (paymentType === "prepaid") {
@@ -15603,7 +15661,7 @@ function EditBillingPanel({ open = false, onClose }) {
15603
15661
  {
15604
15662
  "data-test-id": "save-update-billing-details-button",
15605
15663
  type: "submit",
15606
- disabled: isLoading || isSubmitting,
15664
+ disabled: isLoading || !canSave || isSubmitting,
15607
15665
  loading: isSubmitting,
15608
15666
  loaderText: "Saving...",
15609
15667
  children: "Save"
@@ -15631,10 +15689,10 @@ var OrganizationDetailsLayout = ({
15631
15689
  onNavigate
15632
15690
  }) => {
15633
15691
  const t = useTerminology();
15634
- const [showSidePanel, setShowSidePanel] = useState21(true);
15635
- const [showKYCPanel, setShowKYCPanel] = useState21(false);
15636
- const [showEditOrgPanel, setShowEditOrgPanel] = useState21(false);
15637
- const [showEditBillingPanel, setShowEditBillingPanel] = useState21(false);
15692
+ const [showSidePanel, setShowSidePanel] = useState22(true);
15693
+ const [showKYCPanel, setShowKYCPanel] = useState22(false);
15694
+ const [showEditOrgPanel, setShowEditOrgPanel] = useState22(false);
15695
+ const [showEditBillingPanel, setShowEditBillingPanel] = useState22(false);
15638
15696
  function toggleSidePanel() {
15639
15697
  setShowSidePanel(!showSidePanel);
15640
15698
  }
@@ -15710,7 +15768,7 @@ var OrganizationDetailsLayout = ({
15710
15768
 
15711
15769
  // admin/views/organizations/details/index.tsx
15712
15770
  import {
15713
- FrontierServiceQueries as FrontierServiceQueries21,
15771
+ FrontierServiceQueries as FrontierServiceQueries22,
15714
15772
  GetBillingAccountRequestSchema,
15715
15773
  GetBillingBalanceRequestSchema,
15716
15774
  GetOrganizationKycResponseSchema
@@ -15729,24 +15787,26 @@ var OrganizationDetailsView = ({
15729
15787
  onNavigate,
15730
15788
  children
15731
15789
  }) => {
15732
- const [isSearchVisible, setIsSearchVisible] = useState22(false);
15733
- const [searchQuery, setSearchQuery] = useState22("");
15734
- const queryClient = useQueryClient10();
15735
- const transport = useTransport9();
15790
+ const [isSearchVisible, setIsSearchVisible] = useState23(false);
15791
+ const [searchQuery, setSearchQuery] = useState23("");
15792
+ const queryClient = useQueryClient11();
15793
+ const transport = useTransport10();
15736
15794
  const {
15737
15795
  data: organization,
15738
15796
  isLoading: isOrganizationLoading,
15739
15797
  error: organizationError
15740
- } = useQuery17(
15741
- FrontierServiceQueries21.getOrganization,
15798
+ } = useQuery18(
15799
+ FrontierServiceQueries22.getOrganization,
15742
15800
  { id: organizationId },
15743
15801
  {
15744
15802
  enabled: !!organizationId,
15803
+ // Holds the page's seed; edit and block/unblock invalidate this key.
15804
+ staleTime: SHARED_QUERY_STALE_TIME,
15745
15805
  select: (data) => data?.organization
15746
15806
  }
15747
15807
  );
15748
15808
  const getOrganizationQueryKey = [
15749
- FrontierServiceQueries21.getOrganization,
15809
+ FrontierServiceQueries22.getOrganization,
15750
15810
  { id: organizationId }
15751
15811
  ];
15752
15812
  async function updateOrganization(org) {
@@ -15756,25 +15816,25 @@ var OrganizationDetailsView = ({
15756
15816
  data: kycData,
15757
15817
  isLoading: isKYCLoading,
15758
15818
  error: kycError
15759
- } = useQuery17(
15760
- FrontierServiceQueries21.getOrganizationKyc,
15819
+ } = useQuery18(
15820
+ FrontierServiceQueries22.getOrganizationKyc,
15761
15821
  { orgId: organizationId || "" },
15762
15822
  {
15763
15823
  enabled: !!organizationId
15764
15824
  }
15765
15825
  );
15766
- const kycDetails = useMemo10(() => kycData?.organizationKyc, [kycData]);
15826
+ const kycDetails = useMemo11(() => kycData?.organizationKyc, [kycData]);
15767
15827
  function updateKYCDetails(kyc) {
15768
15828
  if (!organizationId)
15769
15829
  return;
15770
15830
  queryClient.setQueryData(
15771
- createConnectQueryKey8({
15772
- schema: FrontierServiceQueries21.getOrganizationKyc,
15831
+ createConnectQueryKey9({
15832
+ schema: FrontierServiceQueries22.getOrganizationKyc,
15773
15833
  transport,
15774
15834
  input: { orgId: organizationId },
15775
15835
  cardinality: "finite"
15776
15836
  }),
15777
- create17(GetOrganizationKycResponseSchema, { organizationKyc: kyc })
15837
+ create18(GetOrganizationKycResponseSchema, { organizationKyc: kyc })
15778
15838
  );
15779
15839
  }
15780
15840
  const { roles, isLoading: isRolesLoading } = useOrganizationRoles(
@@ -15782,29 +15842,11 @@ var OrganizationDetailsView = ({
15782
15842
  { enabled: !!organizationId }
15783
15843
  );
15784
15844
  const {
15785
- data: orgMembersMap = {},
15786
- isLoading: isOrgMembersMapLoading,
15787
- error: orgMembersError
15788
- } = useQuery17(
15789
- FrontierServiceQueries21.listOrganizationUsers,
15790
- { id: organizationId || "" },
15791
- {
15792
- enabled: !!organizationId,
15793
- select: (data) => {
15794
- const users = data?.users || [];
15795
- return users.reduce(
15796
- (acc, user) => {
15797
- const id = user.id || "";
15798
- acc[id] = user;
15799
- return acc;
15800
- },
15801
- {}
15802
- );
15803
- }
15804
- }
15805
- );
15806
- const { data: firstBillingAccountId = "", error: billingAccountsError } = useQuery17(
15807
- FrontierServiceQueries21.listBillingAccounts,
15845
+ data: firstBillingAccountId = "",
15846
+ isLoading: isBillingAccountsLoading,
15847
+ error: billingAccountsError
15848
+ } = useQuery18(
15849
+ FrontierServiceQueries22.listBillingAccounts,
15808
15850
  { orgId: organizationId || "" },
15809
15851
  {
15810
15852
  enabled: !!organizationId,
@@ -15816,9 +15858,9 @@ var OrganizationDetailsView = ({
15816
15858
  isLoading: isBillingAccountLoading,
15817
15859
  error: billingAccountError,
15818
15860
  refetch: fetchBillingAccountDetails
15819
- } = useQuery17(
15820
- FrontierServiceQueries21.getBillingAccount,
15821
- create17(GetBillingAccountRequestSchema, {
15861
+ } = useQuery18(
15862
+ FrontierServiceQueries22.getBillingAccount,
15863
+ create18(GetBillingAccountRequestSchema, {
15822
15864
  id: firstBillingAccountId,
15823
15865
  withBillingDetails: true
15824
15866
  }),
@@ -15832,14 +15874,15 @@ var OrganizationDetailsView = ({
15832
15874
  );
15833
15875
  const billingAccount = billingAccountData?.billingAccount;
15834
15876
  const billingAccountDetails = billingAccountData?.billingAccountDetails;
15877
+ const isBillingLoading = isBillingAccountsLoading || isBillingAccountLoading;
15835
15878
  const {
15836
15879
  data: tokenBalance = "0",
15837
15880
  isLoading: isTokenBalanceLoading,
15838
15881
  error: tokenBalanceError,
15839
15882
  refetch: fetchTokenBalance
15840
- } = useQuery17(
15841
- FrontierServiceQueries21.getBillingBalance,
15842
- create17(GetBillingBalanceRequestSchema, {
15883
+ } = useQuery18(
15884
+ FrontierServiceQueries22.getBillingBalance,
15885
+ create18(GetBillingBalanceRequestSchema, {
15843
15886
  id: firstBillingAccountId
15844
15887
  }),
15845
15888
  {
@@ -15847,16 +15890,13 @@ var OrganizationDetailsView = ({
15847
15890
  select: (data) => String(data?.balance?.amount || "0")
15848
15891
  }
15849
15892
  );
15850
- useEffect12(() => {
15893
+ useEffect14(() => {
15851
15894
  if (organizationError) {
15852
15895
  console.error("Failed to fetch organization:", organizationError);
15853
15896
  }
15854
15897
  if (kycError) {
15855
15898
  console.error("Failed to fetch KYC details:", kycError);
15856
15899
  }
15857
- if (orgMembersError) {
15858
- console.error("Failed to fetch organization members:", orgMembersError);
15859
- }
15860
15900
  if (billingAccountsError) {
15861
15901
  console.error("Failed to fetch billing accounts:", billingAccountsError);
15862
15902
  }
@@ -15872,12 +15912,11 @@ var OrganizationDetailsView = ({
15872
15912
  }, [
15873
15913
  organizationError,
15874
15914
  kycError,
15875
- orgMembersError,
15876
15915
  billingAccountsError,
15877
15916
  billingAccountError,
15878
15917
  tokenBalanceError
15879
15918
  ]);
15880
- const isLoading = isOrganizationLoading || isRolesLoading || isBillingAccountLoading;
15919
+ const isLoading = isOrganizationLoading || isRolesLoading;
15881
15920
  return /* @__PURE__ */ jsx80(
15882
15921
  OrganizationContext.Provider,
15883
15922
  {
@@ -15887,13 +15926,11 @@ var OrganizationDetailsView = ({
15887
15926
  roles,
15888
15927
  billingAccount,
15889
15928
  billingAccountDetails,
15890
- isBillingAccountLoading,
15929
+ isBillingAccountLoading: isBillingLoading,
15891
15930
  fetchBillingAccountDetails,
15892
15931
  tokenBalance,
15893
- isTokenBalanceLoading,
15932
+ isTokenBalanceLoading: isBillingAccountsLoading || isTokenBalanceLoading,
15894
15933
  fetchTokenBalance,
15895
- orgMembersMap,
15896
- isOrgMembersMapLoading,
15897
15934
  updateKYCDetails,
15898
15935
  kycDetails,
15899
15936
  isKYCLoading,
@@ -15935,8 +15972,8 @@ import {
15935
15972
  toastManager as toastManager16
15936
15973
  } from "@raystack/apsara";
15937
15974
 
15938
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-5KmjMYkeQhpo/sdk/admin/views/organizations/details/security/security.module.css.js
15939
- var digest60 = "b044c0116f81b7607a488951bc0c004ee9bf7c98752bf3176027032ab204883d";
15975
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-ql3rl7MpKUaf/sdk/admin/views/organizations/details/security/security.module.css.js
15976
+ var digest60 = "496336a544af8a4d9f010c5c038831cea7eeef685946ba6bf5706efd5969d019";
15940
15977
  var css60 = `._container_gfopt_1 {
15941
15978
  width: 100%;
15942
15979
  }
@@ -15991,25 +16028,25 @@ import { useContext as useContext17 } from "react";
15991
16028
 
15992
16029
  // admin/views/organizations/details/security/block-organization.tsx
15993
16030
  import { AlertDialog as AlertDialog4, Button as Button20, Flex as Flex56, Text as Text40, toastManager as toastManager14 } from "@raystack/apsara";
15994
- import { useContext as useContext15, useState as useState23 } from "react";
15995
- import { createConnectQueryKey as createConnectQueryKey9, useMutation as useMutation13, useTransport as useTransport10 } from "@connectrpc/connect-query";
15996
- import { FrontierServiceQueries as FrontierServiceQueries22, DisableOrganizationRequestSchema, EnableOrganizationRequestSchema } from "@raystack/proton/frontier";
15997
- import { create as create18 } from "@bufbuild/protobuf";
15998
- import { useQueryClient as useQueryClient11 } from "@tanstack/react-query";
16031
+ import { useContext as useContext15, useState as useState24 } from "react";
16032
+ import { createConnectQueryKey as createConnectQueryKey10, useMutation as useMutation14, useTransport as useTransport11 } from "@connectrpc/connect-query";
16033
+ import { FrontierServiceQueries as FrontierServiceQueries23, DisableOrganizationRequestSchema, EnableOrganizationRequestSchema } from "@raystack/proton/frontier";
16034
+ import { create as create19 } from "@bufbuild/protobuf";
16035
+ import { useQueryClient as useQueryClient12 } from "@tanstack/react-query";
15999
16036
  import { jsx as jsx81, jsxs as jsxs64 } from "react/jsx-runtime";
16000
16037
  var BlockOrganizationDialog = () => {
16001
16038
  const t = useTerminology();
16002
16039
  const { organization } = useContext15(OrganizationContext);
16003
- const queryClient = useQueryClient11();
16004
- const transport = useTransport10();
16005
- const [isDialogOpen, setIsDialogOpen] = useState23(false);
16006
- const { mutateAsync: disableOrganization, isPending: isDisabling } = useMutation13(
16007
- FrontierServiceQueries22.disableOrganization,
16040
+ const queryClient = useQueryClient12();
16041
+ const transport = useTransport11();
16042
+ const [isDialogOpen, setIsDialogOpen] = useState24(false);
16043
+ const { mutateAsync: disableOrganization, isPending: isDisabling } = useMutation14(
16044
+ FrontierServiceQueries23.disableOrganization,
16008
16045
  {
16009
16046
  onSuccess: async () => {
16010
16047
  await queryClient.invalidateQueries({
16011
- queryKey: createConnectQueryKey9({
16012
- schema: FrontierServiceQueries22.getOrganization,
16048
+ queryKey: createConnectQueryKey10({
16049
+ schema: FrontierServiceQueries23.getOrganization,
16013
16050
  transport,
16014
16051
  input: { id: organization?.id },
16015
16052
  cardinality: "finite"
@@ -16028,13 +16065,13 @@ var BlockOrganizationDialog = () => {
16028
16065
  }
16029
16066
  }
16030
16067
  );
16031
- const { mutateAsync: enableOrganization, isPending: isEnabling } = useMutation13(
16032
- FrontierServiceQueries22.enableOrganization,
16068
+ const { mutateAsync: enableOrganization, isPending: isEnabling } = useMutation14(
16069
+ FrontierServiceQueries23.enableOrganization,
16033
16070
  {
16034
16071
  onSuccess: async () => {
16035
16072
  await queryClient.invalidateQueries({
16036
- queryKey: createConnectQueryKey9({
16037
- schema: FrontierServiceQueries22.getOrganization,
16073
+ queryKey: createConnectQueryKey10({
16074
+ schema: FrontierServiceQueries23.getOrganization,
16038
16075
  transport,
16039
16076
  input: { id: organization?.id },
16040
16077
  cardinality: "finite"
@@ -16055,14 +16092,14 @@ var BlockOrganizationDialog = () => {
16055
16092
  );
16056
16093
  async function onBlockOrganization() {
16057
16094
  await disableOrganization(
16058
- create18(DisableOrganizationRequestSchema, {
16095
+ create19(DisableOrganizationRequestSchema, {
16059
16096
  id: organization?.id || ""
16060
16097
  })
16061
16098
  );
16062
16099
  }
16063
16100
  async function onUnblockOrganization() {
16064
16101
  await enableOrganization(
16065
- create18(EnableOrganizationRequestSchema, {
16102
+ create19(EnableOrganizationRequestSchema, {
16066
16103
  id: organization?.id || ""
16067
16104
  })
16068
16105
  );
@@ -16162,8 +16199,8 @@ import {
16162
16199
  toastManager as toastManager15
16163
16200
  } from "@raystack/apsara";
16164
16201
 
16165
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-BzXr0ciL1mjW/sdk/admin/views/organizations/details/security/security.module.css.js
16166
- var digest61 = "4f7cdde2b2fa77edaf2590530cf38e3638315bec2bd29178f64d06030bad625d";
16202
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-mfUQ9CC7cFD2/sdk/admin/views/organizations/details/security/security.module.css.js
16203
+ var digest61 = "2b82bd7df39c6c3a3d6579893a78440d46c452b3a0846d225e10235871cacc60";
16167
16204
  var css61 = `._container_gfopt_1 {
16168
16205
  width: 100%;
16169
16206
  }
@@ -16214,26 +16251,26 @@ var css61 = `._container_gfopt_1 {
16214
16251
  var security_module_css_default3 = { "container": "_container_gfopt_1", "content": "_content_gfopt_5", "domains-list": "_domains-list_gfopt_11", "domainsList": "_domains-list_gfopt_11", "domains-list-status": "_domains-list-status_gfopt_18", "domainsListStatus": "_domains-list-status_gfopt_18", "domains-list-empty": "_domains-list-empty_gfopt_22", "domainsListEmpty": "_domains-list-empty_gfopt_22", "domains-list-item": "_domains-list-item_gfopt_28", "domainsListItem": "_domains-list-item_gfopt_28" };
16215
16252
 
16216
16253
  // admin/views/organizations/details/security/domains-list.tsx
16217
- import { useContext as useContext16, useState as useState24 } from "react";
16218
- import { useMutation as useMutation14, createConnectQueryKey as createConnectQueryKey10, useTransport as useTransport11 } from "@connectrpc/connect-query";
16219
- import { useQueryClient as useQueryClient12 } from "@tanstack/react-query";
16220
- import { FrontierServiceQueries as FrontierServiceQueries23, DeleteOrganizationDomainRequestSchema } from "@raystack/proton/frontier";
16221
- import { create as create19 } from "@bufbuild/protobuf";
16254
+ import { useContext as useContext16, useState as useState25 } from "react";
16255
+ import { useMutation as useMutation15, createConnectQueryKey as createConnectQueryKey11, useTransport as useTransport12 } from "@connectrpc/connect-query";
16256
+ import { useQueryClient as useQueryClient13 } from "@tanstack/react-query";
16257
+ import { FrontierServiceQueries as FrontierServiceQueries24, DeleteOrganizationDomainRequestSchema } from "@raystack/proton/frontier";
16258
+ import { create as create20 } from "@bufbuild/protobuf";
16222
16259
  import { jsx as jsx82, jsxs as jsxs65 } from "react/jsx-runtime";
16223
16260
  var DeleteDomainDialog = ({
16224
16261
  domain
16225
16262
  }) => {
16226
16263
  const { organization } = useContext16(OrganizationContext);
16227
- const [isDialogOpen, setIsDialogOpen] = useState24(false);
16228
- const queryClient = useQueryClient12();
16229
- const transport = useTransport11();
16230
- const { mutateAsync: deleteDomain, isPending } = useMutation14(
16231
- FrontierServiceQueries23.deleteOrganizationDomain,
16264
+ const [isDialogOpen, setIsDialogOpen] = useState25(false);
16265
+ const queryClient = useQueryClient13();
16266
+ const transport = useTransport12();
16267
+ const { mutateAsync: deleteDomain, isPending } = useMutation15(
16268
+ FrontierServiceQueries24.deleteOrganizationDomain,
16232
16269
  {
16233
16270
  onSuccess: () => {
16234
16271
  queryClient.invalidateQueries({
16235
- queryKey: createConnectQueryKey10({
16236
- schema: FrontierServiceQueries23.listOrganizationDomains,
16272
+ queryKey: createConnectQueryKey11({
16273
+ schema: FrontierServiceQueries24.listOrganizationDomains,
16237
16274
  transport,
16238
16275
  input: { orgId: organization?.id || "" },
16239
16276
  cardinality: "finite"
@@ -16254,7 +16291,7 @@ var DeleteDomainDialog = ({
16254
16291
  );
16255
16292
  const handleDelete = async () => {
16256
16293
  await deleteDomain(
16257
- create19(DeleteOrganizationDomainRequestSchema, {
16294
+ create20(DeleteOrganizationDomainRequestSchema, {
16258
16295
  orgId: domain?.orgId || "",
16259
16296
  id: domain?.id || ""
16260
16297
  })
@@ -16370,13 +16407,13 @@ var DomainsList = ({
16370
16407
  };
16371
16408
 
16372
16409
  // admin/views/organizations/details/security/index.tsx
16373
- import { useQuery as useQuery18 } from "@connectrpc/connect-query";
16410
+ import { useQuery as useQuery19 } from "@connectrpc/connect-query";
16374
16411
  import {
16375
- FrontierServiceQueries as FrontierServiceQueries24,
16412
+ FrontierServiceQueries as FrontierServiceQueries25,
16376
16413
  ListOrganizationDomainsRequestSchema
16377
16414
  } from "@raystack/proton/frontier";
16378
- import { create as create20 } from "@bufbuild/protobuf";
16379
- import { useEffect as useEffect13 } from "react";
16415
+ import { create as create21 } from "@bufbuild/protobuf";
16416
+ import { useEffect as useEffect15 } from "react";
16380
16417
  import { jsx as jsx83, jsxs as jsxs66 } from "react/jsx-runtime";
16381
16418
  var AddDomainSection = () => {
16382
16419
  return /* @__PURE__ */ jsxs66(Flex58, { gap: 5, justify: "between", children: [
@@ -16403,9 +16440,9 @@ var AddDomainSection = () => {
16403
16440
  };
16404
16441
  var OrganizationSecurity = () => {
16405
16442
  const { organization } = useContext17(OrganizationContext);
16406
- const { data: domains, isLoading, error, refetch } = useQuery18(
16407
- FrontierServiceQueries24.listOrganizationDomains,
16408
- create20(ListOrganizationDomainsRequestSchema, {
16443
+ const { data: domains, isLoading, error, refetch } = useQuery19(
16444
+ FrontierServiceQueries25.listOrganizationDomains,
16445
+ create21(ListOrganizationDomainsRequestSchema, {
16409
16446
  orgId: organization?.id
16410
16447
  }),
16411
16448
  {
@@ -16413,7 +16450,7 @@ var OrganizationSecurity = () => {
16413
16450
  select: (data) => data?.domains || []
16414
16451
  }
16415
16452
  );
16416
- useEffect13(() => {
16453
+ useEffect15(() => {
16417
16454
  if (error) {
16418
16455
  toastManager16.add({
16419
16456
  title: "Something went wrong",
@@ -16446,8 +16483,8 @@ var OrganizationSecurity = () => {
16446
16483
  // admin/views/organizations/details/members/index.tsx
16447
16484
  import { AlertDialog as AlertDialog12, Button as Button27, DataTable as DataTable17, EmptyState as EmptyState16, Flex as Flex61 } from "@raystack/apsara";
16448
16485
 
16449
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-5u2MeLafo1W4/sdk/admin/views/organizations/details/members/members.module.css.js
16450
- var digest62 = "d626dcd020f3b6de0126a20e8b51332b96eaf18cc5b14378b689fc05650db929";
16486
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-7rV30ingBou1/sdk/admin/views/organizations/details/members/members.module.css.js
16487
+ var digest62 = "959ffdd22f8d4064a7307c5534e8fd7f8f08843b5a7cf06570736d35a3793a4c";
16451
16488
  var css62 = `._container_1865w_1 {
16452
16489
  width: 100%;
16453
16490
  }
@@ -16565,7 +16602,7 @@ var css62 = `._container_1865w_1 {
16565
16602
  var members_module_css_default = { "container": "_container_1865w_1", "name-column": "_name-column_1865w_5", "nameColumn": "_name-column_1865w_5", "empty-state": "_empty-state_1865w_9", "emptyState": "_empty-state_1865w_9", "empty-state-subheading": "_empty-state-subheading_1865w_13", "emptyStateSubheading": "_empty-state-subheading_1865w_13", "zero-state-container": "_zero-state-container_1865w_18", "zeroStateContainer": "_zero-state-container_1865w_18", "table": "_table_1865w_22", "table-wrapper": "_table-wrapper_1865w_27", "tableWrapper": "_table-wrapper_1865w_27", "table-header": "_table-header_1865w_33", "tableHeader": "_table-header_1865w_33", "table-action-column": "_table-action-column_1865w_38", "tableActionColumn": "_table-action-column_1865w_38", "toolbar": "_toolbar_1865w_43", "invites-dialog-content": "_invites-dialog-content_1865w_52", "invitesDialogContent": "_invites-dialog-content_1865w_52", "invites-dialog-body": "_invites-dialog-body_1865w_59", "invitesDialogBody": "_invites-dialog-body_1865w_59", "invites-table-wrapper": "_invites-table-wrapper_1865w_67", "invitesTableWrapper": "_invites-table-wrapper_1865w_67", "invites-table-scroll": "_invites-table-scroll_1865w_73", "invitesTableScroll": "_invites-table-scroll_1865w_73", "invites-action-column": "_invites-action-column_1865w_79", "invitesActionColumn": "_invites-action-column_1865w_79", "invites-remove-item": "_invites-remove-item_1865w_84", "invitesRemoveItem": "_invites-remove-item_1865w_84", "invites-email-column": "_invites-email-column_1865w_90", "invitesEmailColumn": "_invites-email-column_1865w_90" };
16566
16603
 
16567
16604
  // admin/views/organizations/details/members/index.tsx
16568
- import { useContext as useContext18, useEffect as useEffect15, useMemo as useMemo12, useState as useState27 } from "react";
16605
+ import { useContext as useContext18, useEffect as useEffect16, useState as useState27 } from "react";
16569
16606
 
16570
16607
  // admin/views/organizations/details/members/columns.tsx
16571
16608
  import {
@@ -16577,8 +16614,8 @@ import {
16577
16614
  IconButton as IconButton16
16578
16615
  } from "@raystack/apsara";
16579
16616
 
16580
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-iHXCahs6QHko/sdk/admin/views/organizations/details/members/members.module.css.js
16581
- var digest63 = "0622a30594fb953d9b3b34ae7ae9613a03227ae043395307343144cf99f4be73";
16617
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-iu9z6Q64by9T/sdk/admin/views/organizations/details/members/members.module.css.js
16618
+ var digest63 = "8ea94dbc514dc96ee819b2c27c0338d6fa28b292b9fb82811e7987a7e96f402a";
16582
16619
  var css63 = `._container_1865w_1 {
16583
16620
  width: 100%;
16584
16621
  }
@@ -16889,18 +16926,18 @@ import { useQueryClient as useQueryClient15 } from "@tanstack/react-query";
16889
16926
 
16890
16927
  // admin/views/organizations/details/members/update-role.tsx
16891
16928
  import {
16892
- FrontierServiceQueries as FrontierServiceQueries25,
16929
+ FrontierServiceQueries as FrontierServiceQueries26,
16893
16930
  SetOrganizationMemberRoleRequestSchema as SetOrganizationMemberRoleRequestSchema2
16894
16931
  } from "@raystack/proton/frontier";
16895
- import { create as create21 } from "@bufbuild/protobuf";
16896
- import { useMutation as useMutation15 } from "@connectrpc/connect-query";
16932
+ import { create as create22 } from "@bufbuild/protobuf";
16933
+ import { useMutation as useMutation16 } from "@connectrpc/connect-query";
16897
16934
  import {
16898
16935
  AlertDialog as AlertDialog7,
16899
16936
  Button as Button23,
16900
16937
  Text as Text44,
16901
16938
  toastManager as toastManager17
16902
16939
  } from "@raystack/apsara";
16903
- import { ConnectError as ConnectError3 } from "@connectrpc/connect";
16940
+ import { ConnectError as ConnectError4 } from "@connectrpc/connect";
16904
16941
  import { jsx as jsx86, jsxs as jsxs68 } from "react/jsx-runtime";
16905
16942
  var UpdateRole = ({
16906
16943
  handle,
@@ -16926,13 +16963,13 @@ function UpdateRoleContent({
16926
16963
  onClose,
16927
16964
  onRoleUpdate
16928
16965
  }) {
16929
- const { mutateAsync: setMemberRole, isPending } = useMutation15(
16930
- FrontierServiceQueries25.setOrganizationMemberRole
16966
+ const { mutateAsync: setMemberRole, isPending } = useMutation16(
16967
+ FrontierServiceQueries26.setOrganizationMemberRole
16931
16968
  );
16932
16969
  async function onSubmit() {
16933
16970
  try {
16934
16971
  await setMemberRole(
16935
- create21(SetOrganizationMemberRoleRequestSchema2, {
16972
+ create22(SetOrganizationMemberRoleRequestSchema2, {
16936
16973
  orgId: organizationId,
16937
16974
  userId: payload.user.id,
16938
16975
  roleId: payload.role.id
@@ -16947,7 +16984,7 @@ function UpdateRoleContent({
16947
16984
  } catch (error) {
16948
16985
  toastManager17.add({
16949
16986
  title: "Failed to assign role",
16950
- description: error instanceof ConnectError3 ? error.message : void 0,
16987
+ description: error instanceof ConnectError4 ? error.message : void 0,
16951
16988
  type: "error"
16952
16989
  });
16953
16990
  console.error(error);
@@ -16986,11 +17023,11 @@ function UpdateRoleContent({
16986
17023
 
16987
17024
  // admin/views/organizations/details/members/remove-member.tsx
16988
17025
  import {
16989
- FrontierServiceQueries as FrontierServiceQueries26,
17026
+ FrontierServiceQueries as FrontierServiceQueries27,
16990
17027
  RemoveOrganizationMemberRequestSchema
16991
17028
  } from "@raystack/proton/frontier";
16992
- import { create as create22 } from "@bufbuild/protobuf";
16993
- import { useMutation as useMutation16 } from "@connectrpc/connect-query";
17029
+ import { create as create23 } from "@bufbuild/protobuf";
17030
+ import { useMutation as useMutation17 } from "@connectrpc/connect-query";
16994
17031
  import { AlertDialog as AlertDialog8, Button as Button24, toastManager as toastManager18 } from "@raystack/apsara";
16995
17032
  import { jsx as jsx87, jsxs as jsxs69 } from "react/jsx-runtime";
16996
17033
  var RemoveMember = ({
@@ -17000,15 +17037,15 @@ var RemoveMember = ({
17000
17037
  onClose
17001
17038
  }) => {
17002
17039
  const t = useTerminology();
17003
- const { mutateAsync: removeOrganizationMember, isPending } = useMutation16(
17004
- FrontierServiceQueries26.removeOrganizationMember
17040
+ const { mutateAsync: removeOrganizationMember, isPending } = useMutation17(
17041
+ FrontierServiceQueries27.removeOrganizationMember
17005
17042
  );
17006
17043
  async function onSubmit() {
17007
17044
  try {
17008
17045
  if (!user)
17009
17046
  return;
17010
17047
  await removeOrganizationMember(
17011
- create22(RemoveOrganizationMemberRequestSchema, {
17048
+ create23(RemoveOrganizationMemberRequestSchema, {
17012
17049
  orgId: organizationId,
17013
17050
  principalId: user?.id || "",
17014
17051
  principalType: "app/user"
@@ -17085,32 +17122,8 @@ var RemoveMember = ({
17085
17122
  ] }) });
17086
17123
  };
17087
17124
 
17088
- // hooks/index.ts
17089
- import {
17090
- useQuery as useQuery19,
17091
- useMutation as useMutation17,
17092
- useInfiniteQuery as useInfiniteQuery5,
17093
- useTransport as useTransport12,
17094
- createConnectQueryKey as createConnectQueryKey11
17095
- } from "@connectrpc/connect-query";
17096
- import { ConnectError as ConnectError4, Code as Code3 } from "@connectrpc/connect";
17097
- import { FrontierServiceQueries as FrontierServiceQueries27 } from "@raystack/proton/frontier";
17098
- import { useQueryClient as useQueryClient13 } from "@tanstack/react-query";
17099
- import { create as create23 } from "@bufbuild/protobuf";
17100
-
17101
- // hooks/useDebouncedValue.ts
17102
- import { useEffect as useEffect14, useState as useState25 } from "react";
17103
- function useDebouncedValue(value, delay) {
17104
- const [debouncedValue, setDebouncedValue] = useState25(value);
17105
- useEffect14(() => {
17106
- const timer = setTimeout(() => setDebouncedValue(value), delay);
17107
- return () => clearTimeout(timer);
17108
- }, [value, delay]);
17109
- return debouncedValue;
17110
- }
17111
-
17112
17125
  // admin/views/organizations/details/members/invited-members-dialog.tsx
17113
- import { useMemo as useMemo11, useState as useState26 } from "react";
17126
+ import { useMemo as useMemo12, useState as useState26 } from "react";
17114
17127
  import {
17115
17128
  AlertDialog as AlertDialog11,
17116
17129
  Button as Button26,
@@ -17126,8 +17139,8 @@ import {
17126
17139
  Menu as Menu4
17127
17140
  } from "@raystack/apsara";
17128
17141
 
17129
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-ngnAkvQzUPEj/sdk/admin/views/organizations/details/members/members.module.css.js
17130
- var digest64 = "2bfa92c3e244a77a0df9b1e183a7e357eb89b7bae748c25be09336e947ec84f1";
17142
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-CP4y4Mfu1avR/sdk/admin/views/organizations/details/members/members.module.css.js
17143
+ var digest64 = "ca1861c950b200e34c4de61d5377a542fa714b3dd578c87cf396fb299523ef8a";
17131
17144
  var css64 = `._container_1865w_1 {
17132
17145
  width: 100%;
17133
17146
  }
@@ -17456,8 +17469,8 @@ function RemoveInviteContent({
17456
17469
  ] });
17457
17470
  }
17458
17471
 
17459
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-U53k4a8h6RF0/sdk/admin/views/organizations/details/members/members.module.css.js
17460
- var digest65 = "3c51f1dddb1f2618e2c745327886abf8dff5d4d79ba799f3aaa8964a49ea7884";
17472
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-AAfLmWzlqRs7/sdk/admin/views/organizations/details/members/members.module.css.js
17473
+ var digest65 = "98df85a4d45a2e936405f69070c81ec69e2450d36c4e09c0c509843682203dea";
17461
17474
  var css65 = `._container_1865w_1 {
17462
17475
  width: 100%;
17463
17476
  }
@@ -17599,7 +17612,7 @@ var InvitedMembersDialog = ({
17599
17612
  const t = useTerminology();
17600
17613
  const [isInviteDialogOpen, setIsInviteDialogOpen] = useState26(false);
17601
17614
  const { titleById } = useOrganizationRoles(organizationId);
17602
- const columns = useMemo11(
17615
+ const columns = useMemo12(
17603
17616
  () => getInvitedMembersColumns({
17604
17617
  roleTitleById: titleById,
17605
17618
  removeInviteHandle
@@ -17684,10 +17697,6 @@ import { Fragment as Fragment18, jsx as jsx91, jsxs as jsxs73 } from "react/jsx-
17684
17697
  var updateRoleDialogHandle = AlertDialog12.createHandle();
17685
17698
  var NO_INVITATIONS = [];
17686
17699
  var DEFAULT_SORT6 = { name: "orgJoinedAt", order: "desc" };
17687
- var INITIAL_QUERY5 = {
17688
- offset: 0,
17689
- limit: DEFAULT_PAGE_SIZE
17690
- };
17691
17700
  var TRANSFORM_OPTIONS2 = {
17692
17701
  fieldNameMapping: {
17693
17702
  orgJoinedAt: "org_joined_at",
@@ -17766,15 +17775,15 @@ function OrganizationMembersView() {
17766
17775
  }
17767
17776
  );
17768
17777
  const title = `${t.member({ plural: true, case: "capital" })} | ${organization?.title} | ${t.organization({ plural: true, case: "capital" })}`;
17769
- const [tableQuery, setTableQuery] = useState27(INITIAL_QUERY5);
17770
- const computedQuery = useMemo12(() => {
17771
- const tempQuery = transformDataTableQueryToRQLRequest(tableQuery, TRANSFORM_OPTIONS2);
17772
- return {
17773
- ...tempQuery,
17774
- search: searchQuery || ""
17775
- };
17776
- }, [tableQuery, searchQuery]);
17777
- const query = useDebouncedValue(computedQuery, 200);
17778
+ const {
17779
+ tableQuery,
17780
+ rqlQuery: query,
17781
+ onTableQueryChange
17782
+ } = useServerTableQuery({
17783
+ defaultSort: DEFAULT_SORT6,
17784
+ transformOptions: TRANSFORM_OPTIONS2,
17785
+ search: searchQuery || ""
17786
+ });
17778
17787
  const {
17779
17788
  data: infiniteData,
17780
17789
  isLoading,
@@ -17804,15 +17813,14 @@ function OrganizationMembersView() {
17804
17813
  const showZeroState = !isLoading && !isError && !hasActiveQuery && data.length === 0;
17805
17814
  const showToolbar = data.length > 0 || Boolean(tableQuery.filters?.length);
17806
17815
  const showInvitesBtn = invitations.length > 0;
17807
- const onTableQueryChange = (newQuery) => {
17808
- setTableQuery(newQuery);
17809
- };
17810
- const fetchMore = async () => {
17811
- if (hasNextPage && !isFetchingNextPage && !isError) {
17812
- await fetchNextPage();
17813
- }
17814
- };
17815
- useEffect15(() => {
17816
+ const fetchMore = useLoadMore({
17817
+ hasNextPage,
17818
+ isFetchingNextPage,
17819
+ isError,
17820
+ fetchNextPage,
17821
+ label: "members"
17822
+ });
17823
+ useEffect16(() => {
17816
17824
  if (invitationsError) {
17817
17825
  console.error(
17818
17826
  "Failed to fetch organization invitations:",
@@ -17820,7 +17828,7 @@ function OrganizationMembersView() {
17820
17828
  );
17821
17829
  }
17822
17830
  }, [invitationsError]);
17823
- useEffect15(() => {
17831
+ useEffect16(() => {
17824
17832
  setSearchVisibility(true);
17825
17833
  return () => {
17826
17834
  onSearchChange("");
@@ -17840,14 +17848,26 @@ function OrganizationMembersView() {
17840
17848
  handleRemoveMemberAction: openRemoveMemberDialog
17841
17849
  });
17842
17850
  async function invalidateMembersQuery() {
17843
- await queryClient.invalidateQueries({
17844
- queryKey: createConnectQueryKey13({
17845
- schema: AdminServiceQueries16.searchOrganizationUsers,
17846
- transport,
17847
- input: {},
17848
- cardinality: "infinite"
17851
+ if (!organizationId)
17852
+ return;
17853
+ await Promise.all([
17854
+ queryClient.invalidateQueries({
17855
+ queryKey: createConnectQueryKey13({
17856
+ schema: AdminServiceQueries16.searchOrganizationUsers,
17857
+ transport,
17858
+ input: { id: organizationId },
17859
+ cardinality: "infinite"
17860
+ })
17861
+ }),
17862
+ queryClient.invalidateQueries({
17863
+ queryKey: createConnectQueryKey13({
17864
+ schema: FrontierServiceQueries29.listOrganizationUsers,
17865
+ transport,
17866
+ input: { id: organizationId },
17867
+ cardinality: "finite"
17868
+ })
17849
17869
  })
17850
- });
17870
+ ]);
17851
17871
  }
17852
17872
  async function updateMember() {
17853
17873
  await invalidateMembersQuery();
@@ -17948,8 +17968,8 @@ import {
17948
17968
  Flex as Flex67
17949
17969
  } from "@raystack/apsara";
17950
17970
 
17951
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-HW5QDBmuPAwZ/sdk/admin/views/organizations/details/projects/projects.module.css.js
17952
- var digest66 = "6ea008fd8b5a7edd11cd83e37487fde63835c56e6568483035293a928d186245";
17971
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-9xjRxIj09Ofq/sdk/admin/views/organizations/details/projects/projects.module.css.js
17972
+ var digest66 = "0dd4b78fa30f32c9d48ca4bca5348045d38ea9b8193c2b6d7d7461d8321a183a";
17953
17973
  var css66 = `._container_1ky10_1 {
17954
17974
  width: 100%;
17955
17975
  }
@@ -18025,7 +18045,7 @@ var css66 = `._container_1ky10_1 {
18025
18045
  var projects_module_css_default = { "container": "_container_1ky10_1", "title-column": "_title-column_1ky10_5", "titleColumn": "_title-column_1ky10_5", "empty-state": "_empty-state_1ky10_9", "emptyState": "_empty-state_1ky10_9", "empty-state-subheading": "_empty-state-subheading_1ky10_13", "emptyStateSubheading": "_empty-state-subheading_1ky10_13", "zero-state-container": "_zero-state-container_1ky10_18", "zeroStateContainer": "_zero-state-container_1ky10_18", "table": "_table_1ky10_22", "table-wrapper": "_table-wrapper_1ky10_27", "tableWrapper": "_table-wrapper_1ky10_27", "table-header": "_table-header_1ky10_33", "tableHeader": "_table-header_1ky10_33", "table-action-column": "_table-action-column_1ky10_38", "tableActionColumn": "_table-action-column_1ky10_38", "flex1": "_flex1_1ky10_58" };
18026
18046
 
18027
18047
  // admin/views/organizations/details/projects/index.tsx
18028
- import { useContext as useContext20, useEffect as useEffect16, useMemo as useMemo15, useState as useState32 } from "react";
18048
+ import { useContext as useContext20, useEffect as useEffect17, useState as useState32 } from "react";
18029
18049
 
18030
18050
  // admin/views/organizations/details/projects/columns.tsx
18031
18051
  import {
@@ -18038,8 +18058,8 @@ import {
18038
18058
  IconButton as IconButton18
18039
18059
  } from "@raystack/apsara";
18040
18060
 
18041
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-Z6YqgHGFUscg/sdk/admin/views/organizations/details/projects/projects.module.css.js
18042
- var digest67 = "a22af045f349bbe947732cc0f82ab08342ea72057302fd72b5c984a664ee961d";
18061
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-fyqwC6QeLHWe/sdk/admin/views/organizations/details/projects/projects.module.css.js
18062
+ var digest67 = "5b1b81d7c741d7cf392b2eddc88c160bd128bc19a43e9af9bc7fec6cfd7bec9a";
18043
18063
  var css67 = `._container_1ky10_1 {
18044
18064
  width: 100%;
18045
18065
  }
@@ -18249,18 +18269,41 @@ function RenameProjectDialog({
18249
18269
  import { useState as useState29 } from "react";
18250
18270
 
18251
18271
  // admin/views/organizations/details/projects/use-add-project-members.tsx
18252
- import { useCallback as useCallback8, useContext as useContext19, useMemo as useMemo13, useState as useState28 } from "react";
18272
+ import { useCallback as useCallback10, useContext as useContext19, useMemo as useMemo13, useState as useState28 } from "react";
18253
18273
  import { toastManager as toastManager21 } from "@raystack/apsara";
18254
- import { useQuery as useQuery21, useMutation as useMutation20 } from "@connectrpc/connect-query";
18255
- import { FrontierServiceQueries as FrontierServiceQueries31, ListProjectUsersRequestSchema, ListRolesRequestSchema as ListRolesRequestSchema3, SetProjectMemberRoleRequestSchema } from "@raystack/proton/frontier";
18274
+ import { useQuery as useQuery22, useMutation as useMutation20 } from "@connectrpc/connect-query";
18275
+ import { FrontierServiceQueries as FrontierServiceQueries32, ListProjectUsersRequestSchema, ListRolesRequestSchema as ListRolesRequestSchema3, SetProjectMemberRoleRequestSchema } from "@raystack/proton/frontier";
18256
18276
  import { create as create27 } from "@bufbuild/protobuf";
18277
+
18278
+ // admin/hooks/useOrgMembersMap.ts
18279
+ import { useQuery as useQuery21 } from "@connectrpc/connect-query";
18280
+ import { FrontierServiceQueries as FrontierServiceQueries31 } from "@raystack/proton/frontier";
18281
+ var toMembersMap = (data) => (data?.users || []).reduce(
18282
+ (acc, user) => {
18283
+ acc[user.id || ""] = user;
18284
+ return acc;
18285
+ },
18286
+ {}
18287
+ );
18288
+ var useOrgMembersMap = (orgId) => useQuery21(
18289
+ FrontierServiceQueries31.listOrganizationUsers,
18290
+ { id: orgId || "" },
18291
+ {
18292
+ enabled: !!orgId,
18293
+ staleTime: SHARED_QUERY_STALE_TIME,
18294
+ select: toMembersMap
18295
+ }
18296
+ );
18297
+
18298
+ // admin/views/organizations/details/projects/use-add-project-members.tsx
18257
18299
  function useAddProjectMembers({ projectId }) {
18258
18300
  const t = useTerminology();
18259
18301
  const memberLabel = t.member({ case: "capital" });
18260
- const { orgMembersMap } = useContext19(OrganizationContext);
18302
+ const { organization } = useContext19(OrganizationContext);
18303
+ const { data: orgMembersMap = {} } = useOrgMembersMap(organization?.id);
18261
18304
  const [searchQuery, setSearchQuery] = useState28("");
18262
- const { data: projectMembers, isLoading, refetch } = useQuery21(
18263
- FrontierServiceQueries31.listProjectUsers,
18305
+ const { data: projectMembers, isLoading, refetch } = useQuery22(
18306
+ FrontierServiceQueries32.listProjectUsers,
18264
18307
  create27(ListProjectUsersRequestSchema, { id: projectId }),
18265
18308
  {
18266
18309
  enabled: !!projectId,
@@ -18283,8 +18326,8 @@ function useAddProjectMembers({ projectId }) {
18283
18326
  return name.toLowerCase().includes(searchQuery.toLowerCase());
18284
18327
  }) : nonMembers;
18285
18328
  }, [nonMembers, searchQuery]);
18286
- const { data: rolesData } = useQuery21(
18287
- FrontierServiceQueries31.listRoles,
18329
+ const { data: rolesData } = useQuery22(
18330
+ FrontierServiceQueries32.listRoles,
18288
18331
  create27(ListRolesRequestSchema3, {
18289
18332
  state: "enabled",
18290
18333
  scopes: [SCOPES.PROJECT]
@@ -18296,9 +18339,9 @@ function useAddProjectMembers({ projectId }) {
18296
18339
  [rolesData]
18297
18340
  );
18298
18341
  const { mutateAsync: setProjectMemberRole } = useMutation20(
18299
- FrontierServiceQueries31.setProjectMemberRole
18342
+ FrontierServiceQueries32.setProjectMemberRole
18300
18343
  );
18301
- const addMember = useCallback8(
18344
+ const addMember = useCallback10(
18302
18345
  async (userId) => {
18303
18346
  if (!userId || !projectId || !viewerRoleId)
18304
18347
  return;
@@ -18608,19 +18651,18 @@ function ProjectsIcon(props) {
18608
18651
 
18609
18652
  // admin/views/organizations/details/projects/members/index.tsx
18610
18653
  import { AlertDialog as AlertDialog16, DataTable as DataTable18, Dialog as Dialog10, EmptyState as EmptyState17, Flex as Flex66 } from "@raystack/apsara";
18611
- import { useCallback as useCallback9, useMemo as useMemo14, useState as useState31 } from "react";
18654
+ import { useCallback as useCallback11, useMemo as useMemo14, useState as useState31 } from "react";
18612
18655
  import {
18613
18656
  AdminServiceQueries as AdminServiceQueries17,
18614
- FrontierServiceQueries as FrontierServiceQueries34,
18657
+ FrontierServiceQueries as FrontierServiceQueries35,
18615
18658
  GetProjectRequestSchema,
18616
18659
  ListRolesRequestSchema as ListRolesRequestSchema4
18617
18660
  } from "@raystack/proton/frontier";
18618
18661
  import { create as create30 } from "@bufbuild/protobuf";
18619
- import { useQuery as useQuery22, useInfiniteQuery as useInfiniteQuery7 } from "@connectrpc/connect-query";
18620
- import { useDebouncedState as useDebouncedState4 } from "@raystack/apsara/hooks";
18662
+ import { useQuery as useQuery23, useInfiniteQuery as useInfiniteQuery7 } from "@connectrpc/connect-query";
18621
18663
 
18622
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-GZFLG24dvD2F/sdk/admin/views/organizations/details/projects/members/members.module.css.js
18623
- var digest68 = "4cb7040be9bf29089d98861e600a75e08a74f33d9577d22cc8f098f6c5f5690f";
18664
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-EwvVYzezs85P/sdk/admin/views/organizations/details/projects/members/members.module.css.js
18665
+ var digest68 = "ce9f3f7e548f80f5222c7ad0c5ed47df8cb7a6cb8c59ab2fbadf94f01ea59de3";
18624
18666
  var css68 = `._flex1_c0wok_1 {
18625
18667
  flex: 1;
18626
18668
  }
@@ -18728,8 +18770,8 @@ var css68 = `._flex1_c0wok_1 {
18728
18770
  })();
18729
18771
  var members_module_css_default5 = { "flex1": "_flex1_c0wok_1", "dialog-content": "_dialog-content_c0wok_5", "dialogContent": "_dialog-content_c0wok_5", "dialog-body": "_dialog-body_c0wok_10", "dialogBody": "_dialog-body_c0wok_10", "empty-state": "_empty-state_c0wok_14", "emptyState": "_empty-state_c0wok_14", "empty-state-subheading": "_empty-state-subheading_c0wok_18", "emptyStateSubheading": "_empty-state-subheading_c0wok_18", "table": "_table_c0wok_23", "table-wrapper": "_table-wrapper_c0wok_28", "tableWrapper": "_table-wrapper_c0wok_28", "table-header": "_table-header_c0wok_34", "tableHeader": "_table-header_c0wok_34", "table-search": "_table-search_c0wok_39", "tableSearch": "_table-search_c0wok_39", "table-content-wrapper": "_table-content-wrapper_c0wok_43", "tableContentWrapper": "_table-content-wrapper_c0wok_43", "table-action-column": "_table-action-column_c0wok_52", "tableActionColumn": "_table-action-column_c0wok_52", "table-action-dropdown": "_table-action-dropdown_c0wok_71", "tableActionDropdown": "_table-action-dropdown_c0wok_71", "action-dialog-content": "_action-dialog-content_c0wok_76", "actionDialogContent": "_action-dialog-content_c0wok_76", "add-member-dropdown": "_add-member-dropdown_c0wok_80", "addMemberDropdown": "_add-member-dropdown_c0wok_80", "add-member-dropdown-member": "_add-member-dropdown-member_c0wok_85", "addMemberDropdownMember": "_add-member-dropdown-member_c0wok_85", "add-member-dropdown-member-name": "_add-member-dropdown-member-name_c0wok_89", "addMemberDropdownMemberName": "_add-member-dropdown-member-name_c0wok_89" };
18730
18772
 
18731
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-4JBTqXi0C6g1/sdk/admin/views/organizations/details/projects/members/members.module.css.js
18732
- var digest69 = "a7cccf84ace1bb2d6c31d73835869e86f39359dcef3c9ce27143fe899d9ebcdb";
18773
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-NvcS0fAIfekn/sdk/admin/views/organizations/details/projects/members/members.module.css.js
18774
+ var digest69 = "bc2e3b7067d3121e2a31aa2443f217d6b8d140cb9f7efbb106361399c49d598d";
18733
18775
  var css69 = `._flex1_c0wok_1 {
18734
18776
  flex: 1;
18735
18777
  }
@@ -18978,8 +19020,8 @@ var getColumns14 = ({
18978
19020
  ];
18979
19021
  };
18980
19022
 
18981
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-vY8VTbzWgIvk/sdk/admin/views/organizations/details/projects/members/members.module.css.js
18982
- var digest70 = "00ddd705fdcb785e14a04ff771883dafa30f27221af48591bcf0f98c6a4e224e";
19023
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-5MKCkvbZXdTp/sdk/admin/views/organizations/details/projects/members/members.module.css.js
19024
+ var digest70 = "8771522bf9a2bf112c887ab6c88719d32ba2293e0fdc0750f8d4440d5a1ca326";
18983
19025
  var css70 = `._flex1_c0wok_1 {
18984
19026
  flex: 1;
18985
19027
  }
@@ -19089,7 +19131,7 @@ var members_module_css_default7 = { "flex1": "_flex1_c0wok_1", "dialog-content":
19089
19131
 
19090
19132
  // admin/views/organizations/details/projects/members/update-role.tsx
19091
19133
  import {
19092
- FrontierServiceQueries as FrontierServiceQueries32,
19134
+ FrontierServiceQueries as FrontierServiceQueries33,
19093
19135
  SetProjectMemberRoleRequestSchema as SetProjectMemberRoleRequestSchema2
19094
19136
  } from "@raystack/proton/frontier";
19095
19137
  import { create as create28 } from "@bufbuild/protobuf";
@@ -19127,7 +19169,7 @@ function UpdateRoleContent2({
19127
19169
  onRoleUpdate
19128
19170
  }) {
19129
19171
  const { mutateAsync: setProjectMemberRole, isPending } = useMutation21(
19130
- FrontierServiceQueries32.setProjectMemberRole
19172
+ FrontierServiceQueries33.setProjectMemberRole
19131
19173
  );
19132
19174
  async function onSubmit() {
19133
19175
  try {
@@ -19195,14 +19237,14 @@ function UpdateRoleContent2({
19195
19237
  // admin/views/organizations/details/projects/members/remove-member.tsx
19196
19238
  import { useState as useState30 } from "react";
19197
19239
  import {
19198
- FrontierServiceQueries as FrontierServiceQueries33,
19240
+ FrontierServiceQueries as FrontierServiceQueries34,
19199
19241
  RemoveProjectMemberRequestSchema
19200
19242
  } from "@raystack/proton/frontier";
19201
19243
  import { create as create29 } from "@bufbuild/protobuf";
19202
19244
  import { useMutation as useMutation22 } from "@connectrpc/connect-query";
19203
19245
 
19204
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-oBnTnA5zlI7B/sdk/admin/views/organizations/details/projects/members/members.module.css.js
19205
- var digest71 = "16d7fb619988d0301e816dffeaf8174b6fc33eef154c6dd150e95f931510a899";
19246
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-tgiw5g1P2gU7/sdk/admin/views/organizations/details/projects/members/members.module.css.js
19247
+ var digest71 = "bcdddeb91206f3d99d08b8817be7b08679e098d6f11e2dedbf7b837c7961ae91";
19206
19248
  var css71 = `._flex1_c0wok_1 {
19207
19249
  flex: 1;
19208
19250
  }
@@ -19322,7 +19364,7 @@ var RemoveMember2 = ({
19322
19364
  const t = useTerminology();
19323
19365
  const [isSubmitting, setIsSubmitting] = useState30(false);
19324
19366
  const { mutateAsync: removeProjectMember } = useMutation22(
19325
- FrontierServiceQueries33.removeProjectMember
19367
+ FrontierServiceQueries34.removeProjectMember
19326
19368
  );
19327
19369
  async function onSubmit() {
19328
19370
  try {
@@ -19426,8 +19468,8 @@ import {
19426
19468
  Text as Text49
19427
19469
  } from "@raystack/apsara";
19428
19470
 
19429
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-G1AVq1EqP5B6/sdk/admin/views/organizations/details/projects/members/members.module.css.js
19430
- var digest72 = "365a7a6cbb308a7db23c5505745f3cf4dc70a2cd13c444f0189f3ed7725d9c27";
19471
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-6oX507K8A9ub/sdk/admin/views/organizations/details/projects/members/members.module.css.js
19472
+ var digest72 = "225c357f0f2f2b11142c3d36cac070bba668406adf4215d7aed7180c02916410";
19431
19473
  var css72 = `._flex1_c0wok_1 {
19432
19474
  flex: 1;
19433
19475
  }
@@ -19617,34 +19659,31 @@ var NoMembers2 = () => {
19617
19659
  }
19618
19660
  );
19619
19661
  };
19620
- var INITIAL_QUERY6 = {
19621
- offset: 0,
19622
- limit: DEFAULT_PAGE_SIZE
19623
- };
19624
19662
  var updateRoleDialogHandle2 = AlertDialog16.createHandle();
19625
19663
  var ProjectMembersDialog = ({
19626
19664
  projectId,
19627
19665
  onClose,
19628
19666
  canAddMember
19629
19667
  }) => {
19630
- const [tableQuery, setTableQuery] = useDebouncedState4(
19631
- {
19632
- query: INITIAL_QUERY6,
19633
- rqlRequest: transformDataTableQueryToRQLRequest(INITIAL_QUERY6, {})
19634
- },
19635
- 200
19636
- );
19668
+ const {
19669
+ tableQuery,
19670
+ rqlQuery,
19671
+ onTableQueryChange
19672
+ } = useServerTableQuery({
19673
+ // This endpoint ignores sort, so keep it out of the request.
19674
+ mapQuery: (query) => ({ ...query, sort: void 0 })
19675
+ });
19637
19676
  const [removeMemberConfig, setRemoveMemberConfig] = useState31({ isOpen: false, user: null });
19638
- const { data: project, isLoading: isProjectLoading, error: projectError } = useQuery22(
19639
- FrontierServiceQueries34.getProject,
19677
+ const { data: project, isLoading: isProjectLoading, error: projectError } = useQuery23(
19678
+ FrontierServiceQueries35.getProject,
19640
19679
  create30(GetProjectRequestSchema, { id: projectId }),
19641
19680
  {
19642
19681
  enabled: !!projectId,
19643
19682
  select: (data2) => data2?.project
19644
19683
  }
19645
19684
  );
19646
- const { data: projectRoles = [], isLoading: isProjectRolesLoading, error: rolesError } = useQuery22(
19647
- FrontierServiceQueries34.listRoles,
19685
+ const { data: projectRoles = [], isLoading: isProjectRolesLoading, error: rolesError } = useQuery23(
19686
+ FrontierServiceQueries35.listRoles,
19648
19687
  create30(ListRolesRequestSchema4, { scopes: [PROJECT_NAMESPACE] }),
19649
19688
  {
19650
19689
  select: (data2) => data2?.roles || []
@@ -19659,18 +19698,19 @@ var ProjectMembersDialog = ({
19659
19698
  const {
19660
19699
  data: infiniteData,
19661
19700
  isLoading: isMembersLoading,
19701
+ isError,
19662
19702
  isFetchingNextPage,
19663
19703
  fetchNextPage,
19664
19704
  hasNextPage,
19665
19705
  refetch
19666
19706
  } = useInfiniteQuery7(
19667
19707
  AdminServiceQueries17.searchProjectUsers,
19668
- { id: projectId, query: tableQuery.rqlRequest },
19708
+ { id: projectId, query: rqlQuery },
19669
19709
  {
19670
19710
  pageParamKey: "query",
19671
19711
  getNextPageParam: (lastPage) => getConnectNextPageParam(
19672
19712
  lastPage,
19673
- { query: tableQuery.rqlRequest },
19713
+ { query: rqlQuery },
19674
19714
  "projectUsers"
19675
19715
  ),
19676
19716
  staleTime: 0,
@@ -19680,42 +19720,23 @@ var ProjectMembersDialog = ({
19680
19720
  }
19681
19721
  );
19682
19722
  const data = infiniteData?.pages?.flatMap((page) => page?.projectUsers || []) || [];
19683
- const onTableQueryChange = useCallback9((query) => {
19684
- const updatedQuery = {
19685
- ...query,
19686
- offset: 0,
19687
- limit: query.limit || DEFAULT_PAGE_SIZE,
19688
- sort: void 0
19689
- // Remove sort as it's not supported by this endpoint
19690
- };
19691
- const updatedRQLRequest = transformDataTableQueryToRQLRequest(
19692
- updatedQuery,
19693
- {}
19694
- );
19695
- setTableQuery({
19696
- query: updatedQuery,
19697
- rqlRequest: updatedRQLRequest
19698
- });
19699
- }, []);
19700
- const handleLoadMore = useCallback9(async () => {
19701
- try {
19702
- if (!hasNextPage)
19703
- return;
19704
- await fetchNextPage();
19705
- } catch (error) {
19706
- console.error("Error loading more project members:", error);
19707
- }
19708
- }, [hasNextPage, fetchNextPage]);
19723
+ const handleLoadMore = useLoadMore({
19724
+ hasNextPage,
19725
+ isFetchingNextPage,
19726
+ isError,
19727
+ fetchNextPage,
19728
+ label: "project members"
19729
+ });
19709
19730
  async function refetchMembers() {
19710
19731
  await refetch();
19711
19732
  }
19712
- const openRemoveMemberDialog = useCallback9(
19733
+ const openRemoveMemberDialog = useCallback11(
19713
19734
  (user) => {
19714
19735
  setRemoveMemberConfig({ isOpen: true, user });
19715
19736
  },
19716
19737
  []
19717
19738
  );
19718
- const closeRemoveMemberDialog = useCallback9(() => {
19739
+ const closeRemoveMemberDialog = useCallback11(() => {
19719
19740
  setRemoveMemberConfig({ isOpen: false, user: null });
19720
19741
  }, []);
19721
19742
  const columns = useMemo14(
@@ -19761,12 +19782,11 @@ var ProjectMembersDialog = ({
19761
19782
  /* @__PURE__ */ jsx99(Dialog10.Body, { className: members_module_css_default5["dialog-body"], children: /* @__PURE__ */ jsx99(
19762
19783
  DataTable18,
19763
19784
  {
19764
- query: tableQuery.query,
19785
+ query: tableQuery,
19765
19786
  columns,
19766
19787
  data,
19767
19788
  isLoading,
19768
19789
  mode: "server",
19769
- defaultSort: { name: "", order: "desc" },
19770
19790
  onTableQueryChange,
19771
19791
  onLoadMore: handleLoadMore,
19772
19792
  children: /* @__PURE__ */ jsxs81(
@@ -19810,10 +19830,6 @@ var ProjectMembersDialog = ({
19810
19830
  // admin/views/organizations/details/projects/index.tsx
19811
19831
  import { Fragment as Fragment22, jsx as jsx100, jsxs as jsxs82 } from "react/jsx-runtime";
19812
19832
  var DEFAULT_SORT7 = { name: "createdAt", order: "desc" };
19813
- var INITIAL_QUERY7 = {
19814
- offset: 0,
19815
- limit: DEFAULT_PAGE_SIZE
19816
- };
19817
19833
  var TRANSFORM_OPTIONS3 = {
19818
19834
  fieldNameMapping: {
19819
19835
  createdAt: "created_at",
@@ -19865,7 +19881,12 @@ var ErrorState2 = () => {
19865
19881
  };
19866
19882
  function OrganizationProjectsView() {
19867
19883
  const t = useTerminology();
19868
- const { organization, search, orgMembersMap, isOrgMembersMapLoading } = useContext20(OrganizationContext);
19884
+ const { organization, search } = useContext20(OrganizationContext);
19885
+ const {
19886
+ data: orgMembersMap = {},
19887
+ isLoading: isOrgMembersMapLoading,
19888
+ error: orgMembersError
19889
+ } = useOrgMembersMap(organization?.id);
19869
19890
  const {
19870
19891
  onChange: onSearchChange,
19871
19892
  setVisibility: setSearchVisibility,
@@ -19876,16 +19897,16 @@ function OrganizationProjectsView() {
19876
19897
  open: false,
19877
19898
  projectId: ""
19878
19899
  });
19879
- const [tableQuery, setTableQuery] = useState32(INITIAL_QUERY7);
19880
19900
  const title = `${t.project({ plural: true, case: "capital" })} | ${organization?.title} | ${t.organization({ plural: true, case: "capital" })}`;
19881
- const computedQuery = useMemo15(() => {
19882
- const tempQuery = transformDataTableQueryToRQLRequest(tableQuery, TRANSFORM_OPTIONS3);
19883
- return {
19884
- ...tempQuery,
19885
- search: searchQuery || ""
19886
- };
19887
- }, [tableQuery, searchQuery]);
19888
- const query = useDebouncedValue(computedQuery, 200);
19901
+ const {
19902
+ tableQuery,
19903
+ rqlQuery: query,
19904
+ onTableQueryChange
19905
+ } = useServerTableQuery({
19906
+ defaultSort: DEFAULT_SORT7,
19907
+ transformOptions: TRANSFORM_OPTIONS3,
19908
+ search: searchQuery || ""
19909
+ });
19889
19910
  const {
19890
19911
  data: infiniteData,
19891
19912
  isLoading,
@@ -19913,18 +19934,22 @@ function OrganizationProjectsView() {
19913
19934
  searchQuery?.trim() || tableQuery.filters?.length
19914
19935
  );
19915
19936
  const showZeroState = !isLoading && !isError && !hasActiveQuery && data.length === 0;
19916
- const onTableQueryChange = (newQuery) => {
19917
- setTableQuery(newQuery);
19918
- };
19919
- const fetchMore = async () => {
19920
- if (hasNextPage && !isFetchingNextPage && !isError) {
19921
- await fetchNextPage();
19922
- }
19923
- };
19937
+ const fetchMore = useLoadMore({
19938
+ hasNextPage,
19939
+ isFetchingNextPage,
19940
+ isError,
19941
+ fetchNextPage,
19942
+ label: "projects"
19943
+ });
19924
19944
  function handleProjectUpdate(project) {
19925
19945
  refetchOrgProjects();
19926
19946
  }
19927
- useEffect16(() => {
19947
+ useEffect17(() => {
19948
+ if (orgMembersError) {
19949
+ console.error("Failed to fetch organization members:", orgMembersError);
19950
+ }
19951
+ }, [orgMembersError]);
19952
+ useEffect17(() => {
19928
19953
  setSearchVisibility(true);
19929
19954
  return () => {
19930
19955
  onSearchChange("");
@@ -19992,8 +20017,8 @@ function OrganizationProjectsView() {
19992
20017
  // admin/views/organizations/details/invoices/index.tsx
19993
20018
  import { DataTable as DataTable20, EmptyState as EmptyState19, Flex as Flex68 } from "@raystack/apsara";
19994
20019
 
19995
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-2tbZqy5TGino/sdk/admin/views/organizations/details/invoices/invoices.module.css.js
19996
- var digest73 = "5b0a8b27332d87f44027b0bf908003b0332d4571fa467f4fafc19406b113419a";
20020
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-aMoF6sFhVJeI/sdk/admin/views/organizations/details/invoices/invoices.module.css.js
20021
+ var digest73 = "0ed5aa6cd4b7c22130c8fd6078a856d679cd26f1aa91127b9d16103a0a865a2b";
19997
20022
  var css73 = `._empty-state_ptbbe_1 {
19998
20023
  height: 100%;
19999
20024
  }
@@ -20071,10 +20096,10 @@ function BanknotesIcon(props) {
20071
20096
  }
20072
20097
 
20073
20098
  // admin/views/organizations/details/invoices/index.tsx
20074
- import { useContext as useContext21, useEffect as useEffect17, useMemo as useMemo16, useState as useState33 } from "react";
20099
+ import { useContext as useContext21, useEffect as useEffect18 } from "react";
20075
20100
 
20076
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-9f2hsdzvWw06/sdk/admin/views/organizations/details/invoices/invoices.module.css.js
20077
- var digest74 = "9a8411f14ef2f6d5805931cafe54acf29e869a2defc2e3e8d3b1389a4d474da0";
20101
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-l4nOg5JQGxkj/sdk/admin/views/organizations/details/invoices/invoices.module.css.js
20102
+ var digest74 = "accdf065e8f55d8dd6bee75f7794bd6eae7f7d59ad99a459fb48da18ee7db7c7";
20078
20103
  var css74 = `._empty-state_ptbbe_1 {
20079
20104
  height: 100%;
20080
20105
  }
@@ -20201,14 +20226,10 @@ var getColumns15 = ({
20201
20226
  ];
20202
20227
 
20203
20228
  // admin/views/organizations/details/invoices/index.tsx
20204
- import { FrontierServiceQueries as FrontierServiceQueries35 } from "@raystack/proton/frontier";
20229
+ import { FrontierServiceQueries as FrontierServiceQueries36 } from "@raystack/proton/frontier";
20205
20230
  import { useInfiniteQuery as useInfiniteQuery9 } from "@connectrpc/connect-query";
20206
20231
  import { jsx as jsx103, jsxs as jsxs83 } from "react/jsx-runtime";
20207
20232
  var DEFAULT_SORT8 = { name: "createdAt", order: "desc" };
20208
- var INITIAL_QUERY8 = {
20209
- offset: 0,
20210
- limit: DEFAULT_PAGE_SIZE
20211
- };
20212
20233
  var TRANSFORM_OPTIONS4 = {
20213
20234
  fieldNameMapping: {
20214
20235
  createdAt: "created_at",
@@ -20286,19 +20307,17 @@ function OrganizationInvoicesView() {
20286
20307
  setVisibility: setSearchVisibility,
20287
20308
  query: searchQuery
20288
20309
  } = search;
20289
- const [tableQuery, setTableQuery] = useState33(INITIAL_QUERY8);
20290
20310
  const title = `Invoices | ${organization?.title} | ${t.organization({ plural: true, case: "capital" })}`;
20291
- const computedQuery = useMemo16(() => {
20292
- const tempQuery = transformDataTableQueryToRQLRequest(
20293
- convertAmountFiltersToCents(tableQuery),
20294
- TRANSFORM_OPTIONS4
20295
- );
20296
- return {
20297
- ...tempQuery,
20298
- search: searchQuery || ""
20299
- };
20300
- }, [tableQuery, searchQuery]);
20301
- const query = useDebouncedValue(computedQuery, 200);
20311
+ const {
20312
+ tableQuery,
20313
+ rqlQuery: query,
20314
+ onTableQueryChange
20315
+ } = useServerTableQuery({
20316
+ defaultSort: DEFAULT_SORT8,
20317
+ transformOptions: TRANSFORM_OPTIONS4,
20318
+ search: searchQuery || "",
20319
+ mapQuery: convertAmountFiltersToCents
20320
+ });
20302
20321
  const {
20303
20322
  data: infiniteData,
20304
20323
  isLoading,
@@ -20307,7 +20326,7 @@ function OrganizationInvoicesView() {
20307
20326
  hasNextPage,
20308
20327
  isError
20309
20328
  } = useInfiniteQuery9(
20310
- FrontierServiceQueries35.searchOrganizationInvoices,
20329
+ FrontierServiceQueries36.searchOrganizationInvoices,
20311
20330
  { id: organizationId, query },
20312
20331
  {
20313
20332
  enabled: !!organizationId,
@@ -20330,15 +20349,14 @@ function OrganizationInvoicesView() {
20330
20349
  );
20331
20350
  const showZeroState = !isLoading && !isError && !hasActiveQuery && data.length === 0;
20332
20351
  const groupCountMap = infiniteData ? getGroupCountMapFromFirstPage(infiniteData) : {};
20333
- const onTableQueryChange = (newQuery) => {
20334
- setTableQuery(newQuery);
20335
- };
20336
- const fetchMore = async () => {
20337
- if (hasNextPage && !isFetchingNextPage && !isError) {
20338
- await fetchNextPage();
20339
- }
20340
- };
20341
- useEffect17(() => {
20352
+ const fetchMore = useLoadMore({
20353
+ hasNextPage,
20354
+ isFetchingNextPage,
20355
+ isError,
20356
+ fetchNextPage,
20357
+ label: "invoices"
20358
+ });
20359
+ useEffect18(() => {
20342
20360
  setSearchVisibility(true);
20343
20361
  return () => {
20344
20362
  onSearchChange("");
@@ -20381,8 +20399,8 @@ function OrganizationInvoicesView() {
20381
20399
  // admin/views/organizations/details/tokens/index.tsx
20382
20400
  import { DataTable as DataTable21, EmptyState as EmptyState20, Flex as Flex70 } from "@raystack/apsara";
20383
20401
 
20384
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-y0lS4UDImvTf/sdk/admin/views/organizations/details/tokens/tokens.module.css.js
20385
- var digest75 = "4af319896ac756b9d16d1381b6c93d493a77d9e197ece7b159042998c2cd9b39";
20402
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-tcvR4kgBfg3h/sdk/admin/views/organizations/details/tokens/tokens.module.css.js
20403
+ var digest75 = "b0028a6c7a913a1cc851165ab8f425e177f5a7e9fbccbddf242d00aaee570fbe";
20386
20404
  var css75 = `._empty-state_sg42h_1 {
20387
20405
  height: 100%;
20388
20406
  }
@@ -20442,12 +20460,12 @@ var tokens_module_css_default = { "empty-state": "_empty-state_sg42h_1", "emptyS
20442
20460
 
20443
20461
  // admin/views/organizations/details/tokens/index.tsx
20444
20462
  import { CoinIcon as CoinIcon2 } from "@raystack/apsara/icons";
20445
- import { useContext as useContext22, useEffect as useEffect18, useMemo as useMemo17, useState as useState34 } from "react";
20446
- import { FrontierServiceQueries as FrontierServiceQueries36 } from "@raystack/proton/frontier";
20463
+ import { useContext as useContext22, useEffect as useEffect19, useMemo as useMemo15 } from "react";
20464
+ import { FrontierServiceQueries as FrontierServiceQueries37 } from "@raystack/proton/frontier";
20447
20465
  import { useInfiniteQuery as useInfiniteQuery10 } from "@connectrpc/connect-query";
20448
20466
 
20449
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-6EMOK0DSmHNV/sdk/admin/views/organizations/details/tokens/tokens.module.css.js
20450
- var digest76 = "351c2fef08e641f0410a2747e3972ef0a90395572d16cfc3d60a3a73fadc2594";
20467
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-ORVN5zqPU9Fj/sdk/admin/views/organizations/details/tokens/tokens.module.css.js
20468
+ var digest76 = "1b4e480926ea7571b1500438be780a5150d7f998c6dc1594835345f22a329464";
20451
20469
  var css76 = `._empty-state_sg42h_1 {
20452
20470
  height: 100%;
20453
20471
  }
@@ -20589,10 +20607,6 @@ var getColumns16 = ({ t }) => {
20589
20607
  // admin/views/organizations/details/tokens/index.tsx
20590
20608
  import { jsx as jsx105, jsxs as jsxs85 } from "react/jsx-runtime";
20591
20609
  var DEFAULT_SORT9 = { name: "createdAt", order: "desc" };
20592
- var INITIAL_QUERY9 = {
20593
- offset: 0,
20594
- limit: DEFAULT_PAGE_SIZE
20595
- };
20596
20610
  var TRANSFORM_OPTIONS5 = {
20597
20611
  fieldNameMapping: {
20598
20612
  createdAt: "created_at",
@@ -20653,16 +20667,16 @@ function OrganizationTokensView() {
20653
20667
  setVisibility: setSearchVisibility,
20654
20668
  query: searchQuery
20655
20669
  } = search;
20656
- const [tableQuery, setTableQuery] = useState34(INITIAL_QUERY9);
20657
20670
  const title = `Tokens | ${organization?.title} | ${t.organization({ plural: true, case: "capital" })}`;
20658
- const computedQuery = useMemo17(() => {
20659
- const tempQuery = transformDataTableQueryToRQLRequest(tableQuery, TRANSFORM_OPTIONS5);
20660
- return {
20661
- ...tempQuery,
20662
- search: searchQuery || ""
20663
- };
20664
- }, [tableQuery, searchQuery]);
20665
- const query = useDebouncedValue(computedQuery, 200);
20671
+ const {
20672
+ tableQuery,
20673
+ rqlQuery: query,
20674
+ onTableQueryChange
20675
+ } = useServerTableQuery({
20676
+ defaultSort: DEFAULT_SORT9,
20677
+ transformOptions: TRANSFORM_OPTIONS5,
20678
+ search: searchQuery || ""
20679
+ });
20666
20680
  const {
20667
20681
  data: infiniteData,
20668
20682
  isLoading,
@@ -20671,7 +20685,7 @@ function OrganizationTokensView() {
20671
20685
  hasNextPage,
20672
20686
  isError
20673
20687
  } = useInfiniteQuery10(
20674
- FrontierServiceQueries36.searchOrganizationTokens,
20688
+ FrontierServiceQueries37.searchOrganizationTokens,
20675
20689
  { id: organizationId, query },
20676
20690
  {
20677
20691
  enabled: !!organizationId,
@@ -20693,22 +20707,21 @@ function OrganizationTokensView() {
20693
20707
  searchQuery?.trim() || tableQuery.filters?.length
20694
20708
  );
20695
20709
  const showZeroState = !isLoading && !isError && !hasActiveQuery && data.length === 0;
20696
- const onTableQueryChange = (newQuery) => {
20697
- setTableQuery(newQuery);
20698
- };
20699
- const fetchMore = async () => {
20700
- if (hasNextPage && !isFetchingNextPage && !isError) {
20701
- await fetchNextPage();
20702
- }
20703
- };
20704
- useEffect18(() => {
20710
+ const fetchMore = useLoadMore({
20711
+ hasNextPage,
20712
+ isFetchingNextPage,
20713
+ isError,
20714
+ fetchNextPage,
20715
+ label: "tokens"
20716
+ });
20717
+ useEffect19(() => {
20705
20718
  setSearchVisibility(true);
20706
20719
  return () => {
20707
20720
  onSearchChange("");
20708
20721
  setSearchVisibility(false);
20709
20722
  };
20710
20723
  }, [setSearchVisibility, onSearchChange]);
20711
- const columns = useMemo17(() => getColumns16({ t }), [t]);
20724
+ const columns = useMemo15(() => getColumns16({ t }), [t]);
20712
20725
  return /* @__PURE__ */ jsxs85(Flex70, { justify: "center", children: [
20713
20726
  /* @__PURE__ */ jsx105(PageTitle, { title }),
20714
20727
  /* @__PURE__ */ jsx105(
@@ -20744,8 +20757,8 @@ function OrganizationTokensView() {
20744
20757
  // admin/views/organizations/details/apis/index.tsx
20745
20758
  import { DataTable as DataTable22, EmptyState as EmptyState21, Flex as Flex72 } from "@raystack/apsara";
20746
20759
 
20747
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-HD6KZjI5Pfk3/sdk/admin/views/organizations/details/apis/apis.module.css.js
20748
- var digest77 = "bedb9790cc6af04ce9a605736de282e7ac424c9c5c46b1dade767ce50455be30";
20760
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-uE25ZNB1DmjD/sdk/admin/views/organizations/details/apis/apis.module.css.js
20761
+ var digest77 = "842d0bdbebffb1e684237992c5add9b7ad5d158a379f5aa71d6b52a94976197d";
20749
20762
  var css77 = `._empty-state_1819g_1 {
20750
20763
  height: 100%;
20751
20764
  }
@@ -20828,13 +20841,13 @@ var css77 = `._empty-state_1819g_1 {
20828
20841
  var apis_module_css_default = { "empty-state": "_empty-state_1819g_1", "emptyState": "_empty-state_1819g_1", "empty-state-subheading": "_empty-state-subheading_1819g_5", "emptyStateSubheading": "_empty-state-subheading_1819g_5", "zero-state-container": "_zero-state-container_1819g_10", "zeroStateContainer": "_zero-state-container_1819g_10", "table": "_table_1819g_14", "table-wrapper": "_table-wrapper_1819g_19", "tableWrapper": "_table-wrapper_1819g_19", "table-header": "_table-header_1819g_25", "tableHeader": "_table-header_1819g_25", "first-column": "_first-column_1819g_30", "firstColumn": "_first-column_1819g_30", "details-dialog": "_details-dialog_1819g_34", "detailsDialog": "_details-dialog_1819g_34", "skeleton": "_skeleton_1819g_42", "tab-root": "_tab-root_1819g_46", "tabRoot": "_tab-root_1819g_46", "tab-content": "_tab-content_1819g_51", "tabContent": "_tab-content_1819g_51", "list-item": "_list-item_1819g_56", "listItem": "_list-item_1819g_56", "dialog-body": "_dialog-body_1819g_64", "dialogBody": "_dialog-body_1819g_64" };
20829
20842
 
20830
20843
  // admin/views/organizations/details/apis/index.tsx
20831
- import { useCallback as useCallback11, useContext as useContext23, useEffect as useEffect20, useMemo as useMemo19, useState as useState35 } from "react";
20844
+ import { useCallback as useCallback13, useContext as useContext23, useEffect as useEffect21, useMemo as useMemo17, useState as useState33 } from "react";
20832
20845
 
20833
20846
  // admin/views/organizations/details/apis/columns.tsx
20834
20847
  import { Text as Text51 } from "@raystack/apsara";
20835
20848
 
20836
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-nsU0UFdDV2wA/sdk/admin/views/organizations/details/apis/apis.module.css.js
20837
- var digest78 = "dbe977915f8cfe547ecef5f8fa408500303b403329370fbd4782bce9c3ec3282";
20849
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-QXAVJtBZ0QUk/sdk/admin/views/organizations/details/apis/apis.module.css.js
20850
+ var digest78 = "3eb0436bd40962e5cc72af20fa7e28cc06c7213da7d83d4ff2af86d4d3b6201b";
20838
20851
  var css78 = `._empty-state_1819g_1 {
20839
20852
  height: 100%;
20840
20853
  }
@@ -20959,8 +20972,8 @@ function getColumns17(options) {
20959
20972
  // admin/views/organizations/details/apis/details-dialog.tsx
20960
20973
  import { Dialog as Dialog11, Flex as Flex71, Skeleton as Skeleton7, Tabs, Text as Text52, toastManager as toastManager24 } from "@raystack/apsara";
20961
20974
 
20962
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-G9B1lIz66jHl/sdk/admin/views/organizations/details/apis/apis.module.css.js
20963
- var digest79 = "d4d8992b567ca81dc85c0e2bf1713c55014736403bcdc637bf3ec0a866a98b01";
20975
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-2BOs7Y6akROS/sdk/admin/views/organizations/details/apis/apis.module.css.js
20976
+ var digest79 = "f0c88b383bc280f867699f6a19b6205b3b4c9a2d5e01f3937c596bb56d50fbc0";
20964
20977
  var css79 = `._empty-state_1819g_1 {
20965
20978
  height: 100%;
20966
20979
  }
@@ -21043,10 +21056,10 @@ var css79 = `._empty-state_1819g_1 {
21043
21056
  var apis_module_css_default3 = { "empty-state": "_empty-state_1819g_1", "emptyState": "_empty-state_1819g_1", "empty-state-subheading": "_empty-state-subheading_1819g_5", "emptyStateSubheading": "_empty-state-subheading_1819g_5", "zero-state-container": "_zero-state-container_1819g_10", "zeroStateContainer": "_zero-state-container_1819g_10", "table": "_table_1819g_14", "table-wrapper": "_table-wrapper_1819g_19", "tableWrapper": "_table-wrapper_1819g_19", "table-header": "_table-header_1819g_25", "tableHeader": "_table-header_1819g_25", "first-column": "_first-column_1819g_30", "firstColumn": "_first-column_1819g_30", "details-dialog": "_details-dialog_1819g_34", "detailsDialog": "_details-dialog_1819g_34", "skeleton": "_skeleton_1819g_42", "tab-root": "_tab-root_1819g_46", "tabRoot": "_tab-root_1819g_46", "tab-content": "_tab-content_1819g_51", "tabContent": "_tab-content_1819g_51", "list-item": "_list-item_1819g_56", "listItem": "_list-item_1819g_56", "dialog-body": "_dialog-body_1819g_64", "dialogBody": "_dialog-body_1819g_64" };
21044
21057
 
21045
21058
  // admin/views/organizations/details/apis/details-dialog.tsx
21046
- import { useCallback as useCallback10, useEffect as useEffect19, useMemo as useMemo18 } from "react";
21047
- import { useQuery as useQuery23 } from "@connectrpc/connect-query";
21059
+ import { useCallback as useCallback12, useEffect as useEffect20, useMemo as useMemo16 } from "react";
21060
+ import { useQuery as useQuery24 } from "@connectrpc/connect-query";
21048
21061
  import {
21049
- FrontierServiceQueries as FrontierServiceQueries37,
21062
+ FrontierServiceQueries as FrontierServiceQueries38,
21050
21063
  ListServiceUserProjectsRequestSchema,
21051
21064
  ListServiceUserTokensRequestSchema
21052
21065
  } from "@raystack/proton/frontier";
@@ -21058,14 +21071,14 @@ var ServiceUserDetailsDialog = ({
21058
21071
  }) => {
21059
21072
  const t = useTerminology();
21060
21073
  const { id = "", orgId = "", title = "" } = serviceUser || {};
21061
- const projectsRequest = useMemo18(
21074
+ const projectsRequest = useMemo16(
21062
21075
  () => create31(ListServiceUserProjectsRequestSchema, {
21063
21076
  orgId,
21064
21077
  id
21065
21078
  }),
21066
21079
  [orgId, id]
21067
21080
  );
21068
- const tokensRequest = useMemo18(
21081
+ const tokensRequest = useMemo16(
21069
21082
  () => create31(ListServiceUserTokensRequestSchema, {
21070
21083
  orgId,
21071
21084
  id
@@ -21076,7 +21089,7 @@ var ServiceUserDetailsDialog = ({
21076
21089
  data: projects = [],
21077
21090
  isLoading: isProjectLoading,
21078
21091
  error: projectError
21079
- } = useQuery23(FrontierServiceQueries37.listServiceUserProjects, projectsRequest, {
21092
+ } = useQuery24(FrontierServiceQueries38.listServiceUserProjects, projectsRequest, {
21080
21093
  enabled: !!orgId && !!id,
21081
21094
  select: (data) => data?.projects || []
21082
21095
  });
@@ -21084,11 +21097,11 @@ var ServiceUserDetailsDialog = ({
21084
21097
  data: tokens = [],
21085
21098
  isLoading: isTokenLoading,
21086
21099
  error: tokenError
21087
- } = useQuery23(FrontierServiceQueries37.listServiceUserTokens, tokensRequest, {
21100
+ } = useQuery24(FrontierServiceQueries38.listServiceUserTokens, tokensRequest, {
21088
21101
  enabled: !!orgId && !!id,
21089
21102
  select: (data) => data?.tokens || []
21090
21103
  });
21091
- useEffect19(() => {
21104
+ useEffect20(() => {
21092
21105
  if (projectError) {
21093
21106
  toastManager24.add({
21094
21107
  title: "Something went wrong",
@@ -21106,7 +21119,7 @@ var ServiceUserDetailsDialog = ({
21106
21119
  console.error("Unable to fetch tokens:", tokenError);
21107
21120
  }
21108
21121
  }, [projectError, tokenError]);
21109
- const onOpenChange = useCallback10(
21122
+ const onOpenChange = useCallback12(
21110
21123
  (val) => {
21111
21124
  if (!val) {
21112
21125
  onClose();
@@ -21216,10 +21229,6 @@ var ErrorState5 = () => {
21216
21229
  );
21217
21230
  };
21218
21231
  var DEFAULT_SORT10 = { name: "createdAt", order: "desc" };
21219
- var INITIAL_QUERY10 = {
21220
- offset: 0,
21221
- limit: DEFAULT_PAGE_SIZE
21222
- };
21223
21232
  var TRANSFORM_OPTIONS6 = {
21224
21233
  fieldNameMapping: {
21225
21234
  createdAt: "created_at"
@@ -21234,20 +21243,20 @@ function OrganizationApisView() {
21234
21243
  setVisibility: setSearchVisibility,
21235
21244
  query: searchQuery
21236
21245
  } = search;
21237
- const [tableQuery, setTableQuery] = useState35(INITIAL_QUERY10);
21238
- const computedQuery = useMemo19(() => {
21239
- const tempQuery = transformDataTableQueryToRQLRequest(tableQuery, TRANSFORM_OPTIONS6);
21240
- return {
21241
- ...tempQuery,
21242
- search: searchQuery || ""
21243
- };
21244
- }, [tableQuery, searchQuery]);
21245
- const query = useDebouncedValue(computedQuery, 200);
21246
- const [selectedServiceUser, setSelectedServiceUser] = useState35(
21246
+ const {
21247
+ tableQuery,
21248
+ rqlQuery: query,
21249
+ onTableQueryChange
21250
+ } = useServerTableQuery({
21251
+ defaultSort: DEFAULT_SORT10,
21252
+ transformOptions: TRANSFORM_OPTIONS6,
21253
+ search: searchQuery || ""
21254
+ });
21255
+ const [selectedServiceUser, setSelectedServiceUser] = useState33(
21247
21256
  null
21248
21257
  );
21249
21258
  const title = `API | ${organization?.title} | ${t.organization({ plural: true, case: "capital" })}`;
21250
- useEffect20(() => {
21259
+ useEffect21(() => {
21251
21260
  setSearchVisibility(true);
21252
21261
  return () => {
21253
21262
  onSearchChange("");
@@ -21280,27 +21289,22 @@ function OrganizationApisView() {
21280
21289
  }
21281
21290
  );
21282
21291
  const data = infiniteData?.pages?.flatMap((page) => page?.organizationServiceUsers || []) || [];
21283
- const onTableQueryChange = (newQuery) => {
21284
- setTableQuery(newQuery);
21285
- };
21286
- const handleLoadMore = async () => {
21287
- try {
21288
- if (!hasNextPage)
21289
- return;
21290
- await fetchNextPage();
21291
- } catch (error2) {
21292
- console.error("Error loading more service users:", error2);
21293
- }
21294
- };
21292
+ const handleLoadMore = useLoadMore({
21293
+ hasNextPage,
21294
+ isFetchingNextPage,
21295
+ isError,
21296
+ fetchNextPage,
21297
+ label: "service users"
21298
+ });
21295
21299
  const loading = isLoading || isFetchingNextPage;
21296
21300
  const hasActiveQuery = Boolean(
21297
21301
  searchQuery?.trim() || tableQuery.filters?.length
21298
21302
  );
21299
21303
  const showZeroState = !isLoading && !isError && !hasActiveQuery && data.length === 0;
21300
- const onDialogClose = useCallback11(() => {
21304
+ const onDialogClose = useCallback13(() => {
21301
21305
  setSelectedServiceUser(null);
21302
21306
  }, []);
21303
- const onRowClick = useCallback11(
21307
+ const onRowClick = useCallback13(
21304
21308
  (row) => {
21305
21309
  setSelectedServiceUser(row);
21306
21310
  },
@@ -21309,7 +21313,7 @@ function OrganizationApisView() {
21309
21313
  if (isError) {
21310
21314
  console.error("ConnectRPC Error:", error);
21311
21315
  }
21312
- const columns = useMemo19(
21316
+ const columns = useMemo17(
21313
21317
  () => getColumns17({
21314
21318
  groupCountMap: infiniteData ? getGroupCountMapFromFirstPage(infiniteData) : {},
21315
21319
  t
@@ -21358,11 +21362,11 @@ function OrganizationApisView() {
21358
21362
 
21359
21363
  // admin/views/organizations/details/pat/index.tsx
21360
21364
  import { DataTable as DataTable23, EmptyState as EmptyState22, Flex as Flex75 } from "@raystack/apsara";
21361
- import { useCallback as useCallback12, useContext as useContext24, useEffect as useEffect21, useMemo as useMemo21, useState as useState36 } from "react";
21362
- import { useInfiniteQuery as useInfiniteQuery12, useQuery as useQuery25 } from "@connectrpc/connect-query";
21365
+ import { useCallback as useCallback14, useContext as useContext24, useEffect as useEffect22, useMemo as useMemo19, useState as useState34 } from "react";
21366
+ import { useInfiniteQuery as useInfiniteQuery12, useQuery as useQuery26 } from "@connectrpc/connect-query";
21363
21367
  import {
21364
21368
  AdminServiceQueries as AdminServiceQueries20,
21365
- FrontierServiceQueries as FrontierServiceQueries39
21369
+ FrontierServiceQueries as FrontierServiceQueries40
21366
21370
  } from "@raystack/proton/frontier";
21367
21371
 
21368
21372
  // admin/views/organizations/details/pat/columns.tsx
@@ -21384,8 +21388,8 @@ var getInitials = function(name = "") {
21384
21388
  return initials;
21385
21389
  };
21386
21390
 
21387
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-UcFYkJX6jxn6/sdk/admin/views/organizations/details/pat/pat.module.css.js
21388
- var digest80 = "6ac1f9a465d3bb20741c32b0dd1b1f8edbd43b4be8a7e90709fa10d09970d767";
21391
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-8taIxPDNgi24/sdk/admin/views/organizations/details/pat/pat.module.css.js
21392
+ var digest80 = "d0eb85e618a470c65c5b8f4432e9eecf2c0db935d83b7f783e87ac45917e76c5";
21389
21393
  var css80 = `._empty-state_3m4sa_1 {
21390
21394
  height: 100%;
21391
21395
  }
@@ -21540,7 +21544,7 @@ function getColumns18({
21540
21544
  }
21541
21545
 
21542
21546
  // admin/views/organizations/details/pat/components/pat-details-dialog.tsx
21543
- import { useMemo as useMemo20 } from "react";
21547
+ import { useMemo as useMemo18 } from "react";
21544
21548
  import {
21545
21549
  Dialog as Dialog12,
21546
21550
  Flex as Flex74,
@@ -21548,13 +21552,13 @@ import {
21548
21552
  Tabs as Tabs2,
21549
21553
  Text as Text54
21550
21554
  } from "@raystack/apsara";
21551
- import { useQuery as useQuery24 } from "@connectrpc/connect-query";
21555
+ import { useQuery as useQuery25 } from "@connectrpc/connect-query";
21552
21556
  import {
21553
- FrontierServiceQueries as FrontierServiceQueries38
21557
+ FrontierServiceQueries as FrontierServiceQueries39
21554
21558
  } from "@raystack/proton/frontier";
21555
21559
 
21556
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-Wkg1FL1c9zoX/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.module.css.js
21557
- var digest81 = "f583242979c79c9b6182644a3d0198dc2466b9c198bfe6235c1081a8b3567c02";
21560
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-6NdgqeE3Vfp1/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.module.css.js
21561
+ var digest81 = "938dca9ea1ddefcf77ea5e8a95b7f3e397fec8f9cd0a00dcb422cc19f5fff8f3";
21558
21562
  var css81 = `._details-dialog_1dwlo_1 {
21559
21563
  width: 100%;
21560
21564
  max-width: 400px;
@@ -21628,25 +21632,25 @@ function PatDetailsDialog({
21628
21632
  }) {
21629
21633
  const t = useTerminology();
21630
21634
  const open = pat !== null;
21631
- const projectScope = useMemo20(
21635
+ const projectScope = useMemo18(
21632
21636
  () => pat?.scopes?.find((s) => s.resourceType === SCOPES.PROJECT),
21633
21637
  [pat]
21634
21638
  );
21635
- const orgScope = useMemo20(
21639
+ const orgScope = useMemo18(
21636
21640
  () => pat?.scopes?.find((s) => s.resourceType === SCOPES.ORG),
21637
21641
  [pat]
21638
21642
  );
21639
- const scopeProjectIds = useMemo20(() => projectScope?.resourceIds ?? [], [projectScope]);
21640
- const scopeProjects = useMemo20(
21643
+ const scopeProjectIds = useMemo18(() => projectScope?.resourceIds ?? [], [projectScope]);
21644
+ const scopeProjects = useMemo18(
21641
21645
  () => scopeProjectIds.map((id) => projectsMap[id]).filter((p) => Boolean(p)),
21642
21646
  [scopeProjectIds, projectsMap]
21643
21647
  );
21644
- const { data: rolesData, isLoading: isRolesLoading } = useQuery24(
21645
- FrontierServiceQueries38.listRolesForPAT,
21648
+ const { data: rolesData, isLoading: isRolesLoading } = useQuery25(
21649
+ FrontierServiceQueries39.listRolesForPAT,
21646
21650
  { scopes: [SCOPES.ORG, SCOPES.PROJECT] },
21647
21651
  { enabled: open }
21648
21652
  );
21649
- const rolesMap = useMemo20(() => {
21653
+ const rolesMap = useMemo18(() => {
21650
21654
  const map = {};
21651
21655
  (rolesData?.roles ?? []).forEach((role) => {
21652
21656
  if (role.id)
@@ -21745,8 +21749,8 @@ function PatDetailsDialog({
21745
21749
  ] }) });
21746
21750
  }
21747
21751
 
21748
- // esbuild-css-modules-plugin-namespace:/tmp/tmp-2091-iC9KEfv4vIPV/sdk/admin/views/organizations/details/pat/pat.module.css.js
21749
- var digest82 = "d53d58dbd9505caea0e9e792e89f3f25e1f7393d65f191774cc5226938c9fdaf";
21752
+ // esbuild-css-modules-plugin-namespace:/tmp/tmp-2174-k16wRItoVZ8A/sdk/admin/views/organizations/details/pat/pat.module.css.js
21753
+ var digest82 = "7a3d8577047f1315986b7dc4df73cc6ff05566236c5e20e7e4affb572fd3a94f";
21750
21754
  var css82 = `._empty-state_3m4sa_1 {
21751
21755
  height: 100%;
21752
21756
  }
@@ -21807,10 +21811,6 @@ var pat_module_css_default2 = { "empty-state": "_empty-state_3m4sa_1", "emptySta
21807
21811
  // admin/views/organizations/details/pat/index.tsx
21808
21812
  import { jsx as jsx111, jsxs as jsxs90 } from "react/jsx-runtime";
21809
21813
  var DEFAULT_SORT11 = { name: "createdAt", order: "desc" };
21810
- var INITIAL_QUERY11 = {
21811
- offset: 0,
21812
- limit: DEFAULT_PAGE_SIZE
21813
- };
21814
21814
  var TRANSFORM_OPTIONS7 = {
21815
21815
  fieldNameMapping: {
21816
21816
  createdAt: "created_at",
@@ -21868,20 +21868,17 @@ function OrganizationPatView() {
21868
21868
  setVisibility: setSearchVisibility,
21869
21869
  query: searchQuery
21870
21870
  } = search;
21871
- const [tableQuery, setTableQuery] = useState36(INITIAL_QUERY11);
21872
- const [selectedPat, setSelectedPat] = useState36(null);
21871
+ const [selectedPat, setSelectedPat] = useState34(null);
21873
21872
  const title = `PAT | ${organization?.title} | ${t.organization({ plural: true, case: "capital" })}`;
21874
- const computedQuery = useMemo21(() => {
21875
- const tempQuery = transformDataTableQueryToRQLRequest(
21876
- tableQuery,
21877
- TRANSFORM_OPTIONS7
21878
- );
21879
- return {
21880
- ...tempQuery,
21881
- search: searchQuery || ""
21882
- };
21883
- }, [tableQuery, searchQuery]);
21884
- const query = useDebouncedValue(computedQuery, 200);
21873
+ const {
21874
+ tableQuery,
21875
+ rqlQuery: query,
21876
+ onTableQueryChange
21877
+ } = useServerTableQuery({
21878
+ defaultSort: DEFAULT_SORT11,
21879
+ transformOptions: TRANSFORM_OPTIONS7,
21880
+ search: searchQuery || ""
21881
+ });
21885
21882
  const {
21886
21883
  data: infiniteData,
21887
21884
  isLoading,
@@ -21902,15 +21899,15 @@ function OrganizationPatView() {
21902
21899
  retryDelay: 1e3
21903
21900
  }
21904
21901
  );
21905
- const { data: projects = [] } = useQuery25(
21906
- FrontierServiceQueries39.listOrganizationProjects,
21902
+ const { data: projects = [] } = useQuery26(
21903
+ FrontierServiceQueries40.listOrganizationProjects,
21907
21904
  { id: organizationId, state: "", withMemberCount: false },
21908
21905
  {
21909
21906
  enabled: !!organizationId,
21910
21907
  select: (data2) => data2?.projects || []
21911
21908
  }
21912
21909
  );
21913
- const projectsMap = useMemo21(
21910
+ const projectsMap = useMemo19(
21914
21911
  () => projects.reduce(
21915
21912
  (acc, project) => {
21916
21913
  if (project.id)
@@ -21921,7 +21918,7 @@ function OrganizationPatView() {
21921
21918
  ),
21922
21919
  [projects]
21923
21920
  );
21924
- const data = useMemo21(
21921
+ const data = useMemo19(
21925
21922
  () => infiniteData?.pages?.flatMap((page) => page?.organizationPats ?? []) ?? [],
21926
21923
  [infiniteData]
21927
21924
  );
@@ -21930,32 +21927,31 @@ function OrganizationPatView() {
21930
21927
  searchQuery?.trim() || tableQuery.filters?.length
21931
21928
  );
21932
21929
  const showZeroState = !isLoading && !isError && !hasActiveQuery && data.length === 0;
21933
- const onTableQueryChange = (newQuery) => {
21934
- setTableQuery(newQuery);
21935
- };
21936
- const fetchMore = async () => {
21937
- if (hasNextPage && !isFetchingNextPage && !isError) {
21938
- await fetchNextPage();
21939
- }
21940
- };
21941
- useEffect21(() => {
21930
+ const fetchMore = useLoadMore({
21931
+ hasNextPage,
21932
+ isFetchingNextPage,
21933
+ isError,
21934
+ fetchNextPage,
21935
+ label: "personal access tokens"
21936
+ });
21937
+ useEffect22(() => {
21942
21938
  setSearchVisibility(true);
21943
21939
  return () => {
21944
21940
  onSearchChange("");
21945
21941
  setSearchVisibility(false);
21946
21942
  };
21947
21943
  }, [setSearchVisibility, onSearchChange]);
21948
- const columns = useMemo21(
21944
+ const columns = useMemo19(
21949
21945
  () => getColumns18({ projectsMap }),
21950
21946
  [projectsMap]
21951
21947
  );
21952
- const onRowClick = useCallback12(
21948
+ const onRowClick = useCallback14(
21953
21949
  (row) => {
21954
21950
  setSelectedPat(row);
21955
21951
  },
21956
21952
  []
21957
21953
  );
21958
- const onDialogClose = useCallback12(() => {
21954
+ const onDialogClose = useCallback14(() => {
21959
21955
  setSelectedPat(null);
21960
21956
  }, []);
21961
21957
  return /* @__PURE__ */ jsxs90(Flex75, { justify: "center", children: [