subos-frontend 1.0.58 → 1.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -533,15 +533,17 @@ var applyFrontendPagination = (transactions, filters) => {
533
533
  const startIndex = (currentPage - 1) * limit;
534
534
  const endIndex = startIndex + limit;
535
535
  const paginatedTransactions = transactions.slice(startIndex, endIndex);
536
+ const totalPages = Math.max(1, Math.ceil(transactions.length / limit));
537
+ const adjustedCurrentPage = Math.min(currentPage, totalPages);
536
538
  return {
537
539
  data: paginatedTransactions,
538
540
  meta: {
539
- currentPage,
540
- totalPages: Math.ceil(transactions.length / limit),
541
+ currentPage: adjustedCurrentPage,
542
+ totalPages,
541
543
  totalItems: transactions.length,
542
544
  itemsPerPage: limit,
543
545
  hasNextPage: endIndex < transactions.length,
544
- hasPreviousPage: currentPage > 1
546
+ hasPreviousPage: adjustedCurrentPage > 1
545
547
  }
546
548
  };
547
549
  };
@@ -574,15 +576,10 @@ var useTransactions = ({
574
576
  if (Array.isArray(response.data)) {
575
577
  setIsBackendPaginated(false);
576
578
  setAllTransactions(response.data);
577
- setTransactions(response.data);
578
- setMeta({
579
- currentPage: 1,
580
- totalPages: 1,
581
- totalItems: response.data.length,
582
- itemsPerPage: response.data.length,
583
- hasNextPage: false,
584
- hasPreviousPage: false
585
- });
579
+ const filteredTransactions = applyFrontendFilters(response.data, filters);
580
+ const paginatedResult = applyFrontendPagination(filteredTransactions, filters);
581
+ setTransactions(paginatedResult.data);
582
+ setMeta(paginatedResult.meta);
586
583
  } else {
587
584
  setIsBackendPaginated(true);
588
585
  const paginatedData = response.data;
@@ -2050,6 +2047,9 @@ var TransactionPagination = ({
2050
2047
  }) => {
2051
2048
  const { currentPage, totalPages, totalItems, itemsPerPage, hasNextPage, hasPreviousPage } = pagination;
2052
2049
  const getVisiblePages = () => {
2050
+ if (totalPages <= 1) {
2051
+ return [1];
2052
+ }
2053
2053
  const delta = 2;
2054
2054
  const range = [];
2055
2055
  const rangeWithDots = [];
@@ -2071,9 +2071,6 @@ var TransactionPagination = ({
2071
2071
  };
2072
2072
  const startItem = (currentPage - 1) * itemsPerPage + 1;
2073
2073
  const endItem = Math.min(currentPage * itemsPerPage, totalItems);
2074
- if (totalPages <= 1) {
2075
- return null;
2076
- }
2077
2074
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex flex-col sm:flex-row items-center justify-between space-y-3 sm:space-y-0 ${className}`, children: [
2078
2075
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col sm:flex-row items-center space-y-2 sm:space-y-0 sm:space-x-4", children: [
2079
2076
  showInfo && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-gray-700", children: [
@@ -2106,10 +2103,10 @@ var TransactionPagination = ({
2106
2103
  "button",
2107
2104
  {
2108
2105
  onClick: () => onPageChange(currentPage - 1),
2109
- disabled: !hasPreviousPage,
2106
+ disabled: !hasPreviousPage || totalPages <= 1,
2110
2107
  className: `
2111
2108
  px-3 py-2 text-sm font-medium rounded-md
2112
- ${hasPreviousPage ? "text-gray-500 bg-white border border-gray-300 hover:bg-gray-50 hover:text-gray-700" : "text-gray-300 bg-white border border-gray-300 cursor-not-allowed"}
2109
+ ${hasPreviousPage && totalPages > 1 ? "text-gray-500 bg-white border border-gray-300 hover:bg-gray-50 hover:text-gray-700" : "text-gray-300 bg-white border border-gray-300 cursor-not-allowed"}
2113
2110
  `,
2114
2111
  children: "Previous"
2115
2112
  }
@@ -2129,10 +2126,10 @@ var TransactionPagination = ({
2129
2126
  "button",
2130
2127
  {
2131
2128
  onClick: () => onPageChange(currentPage + 1),
2132
- disabled: !hasNextPage,
2129
+ disabled: !hasNextPage || totalPages <= 1,
2133
2130
  className: `
2134
2131
  px-3 py-2 text-sm font-medium rounded-md
2135
- ${hasNextPage ? "text-gray-500 bg-white border border-gray-300 hover:bg-gray-50 hover:text-gray-700" : "text-gray-300 bg-white border border-gray-300 cursor-not-allowed"}
2132
+ ${hasNextPage && totalPages > 1 ? "text-gray-500 bg-white border border-gray-300 hover:bg-gray-50 hover:text-gray-700" : "text-gray-300 bg-white border border-gray-300 cursor-not-allowed"}
2136
2133
  `,
2137
2134
  children: "Next"
2138
2135
  }
@@ -2233,7 +2230,7 @@ var TransactionModal = ({
2233
2230
  pagination: meta,
2234
2231
  onPageChange: handlePageChange,
2235
2232
  onLimitChange: handleLimitChange,
2236
- pageSizeOptions: [5, 10, 25, 50]
2233
+ pageSizeOptions: [5, 10, 20, 25, 50]
2237
2234
  }
2238
2235
  )
2239
2236
  ] }),
@@ -2548,13 +2545,13 @@ var SubscriptionActionButtons = ({
2548
2545
  if (canceledOn) {
2549
2546
  return {
2550
2547
  disabled: true,
2551
- tooltip: "Your renewal is already cancelled, it will get cancelled on end of cycle"
2548
+ tooltip: "Renewal already canceled \u2014 it will end after this billing cycle."
2552
2549
  };
2553
2550
  }
2554
2551
  if (((_b = subscription.plan) == null ? void 0 : _b.fixedCost) === 0) {
2555
2552
  return {
2556
2553
  disabled: true,
2557
- tooltip: "You are on base plan it cannot be canceled"
2554
+ tooltip: "You\u2019re on a starter/free-trial plan \u2014 there\u2019s no active renewal to cancel."
2558
2555
  };
2559
2556
  }
2560
2557
  return { disabled: false, tooltip: void 0 };