subos-frontend 1.0.32 → 1.0.34

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
@@ -107,7 +107,6 @@ var getHeaders = () => {
107
107
  };
108
108
  var ENDPOINTS = {
109
109
  PLANS: "/plans",
110
- PAYMENTS: "/api/payments",
111
110
  CHECKOUT: "/checkout",
112
111
  SUBSCRIPTION: "/subscription",
113
112
  CUSTOMER: "/customer",
@@ -197,7 +196,13 @@ var subscriptionApi = {
197
196
  }
198
197
  };
199
198
  var customerApi = {
200
- getCustomer: (externalId) => apiRequest(`${ENDPOINTS.CUSTOMER}/${externalId}`, "GET", void 0, { projectId: getDefaultProjectId() })
199
+ getCustomer: (externalId) => apiRequest(`${ENDPOINTS.CUSTOMER}/${externalId}`, "GET", void 0, { projectId: getDefaultProjectId() }),
200
+ createPortalSession: (externalId, returnUrl) => apiRequest(
201
+ `${ENDPOINTS.CUSTOMER}/${externalId}/portal`,
202
+ "POST",
203
+ { returnUrl },
204
+ { projectId: getDefaultProjectId() }
205
+ )
201
206
  };
202
207
  var transactionApi = {
203
208
  getTransactions: (externalId, filters) => {
@@ -349,7 +354,7 @@ var filterPlansByTier = (plans, tierFilter) => {
349
354
  };
350
355
  var isPlanPopular = (plan) => {
351
356
  const planName = plan.name.toLowerCase();
352
- return planName.includes("growth");
357
+ return planName.includes("scale");
353
358
  };
354
359
  var getPlanDescription = (plan) => {
355
360
  const planName = plan.name.toLowerCase();
@@ -746,31 +751,6 @@ var useCancelSubscription = ({
746
751
  reset
747
752
  };
748
753
  };
749
- async function apiRequest2(endpoint, method = "GET", data) {
750
- try {
751
- const url = `${getApiBaseUrl()}${endpoint}`;
752
- const options = {
753
- method,
754
- headers: getHeaders(),
755
- credentials: "include"
756
- };
757
- if (data) {
758
- options.body = JSON.stringify(data);
759
- }
760
- const response = await fetch(url, options);
761
- const result = await response.json();
762
- if (!response.ok) {
763
- return { success: false, error: result.message || "An error occurred" };
764
- }
765
- return { success: true, data: result };
766
- } catch (error) {
767
- console.error("API request failed:", error);
768
- return {
769
- success: false,
770
- error: error instanceof Error ? error.message : "Unknown error occurred"
771
- };
772
- }
773
- }
774
754
  var useCustomerPortal = ({
775
755
  onSuccess,
776
756
  onError
@@ -789,10 +769,9 @@ var useCustomerPortal = ({
789
769
  setError(null);
790
770
  try {
791
771
  const returnUrl = `${window.location.origin}/dashboard`;
792
- const response = await apiRequest2(
793
- `${ENDPOINTS.CUSTOMER}/${externalId}/portal`,
794
- "POST",
795
- { returnUrl }
772
+ const response = await customerApi.createPortalSession(
773
+ externalId,
774
+ returnUrl
796
775
  );
797
776
  const portalResponse = response.data;
798
777
  const portalUrl = ((_a = portalResponse == null ? void 0 : portalResponse.data) == null ? void 0 : _a.url) ?? (portalResponse == null ? void 0 : portalResponse.url);
@@ -1470,7 +1449,15 @@ var PaymentCancelView = ({ details }) => {
1470
1449
  ] });
1471
1450
  };
1472
1451
  var PaymentCancelView_default = PaymentCancelView;
1473
- var PaymentSuccessView = ({ details }) => {
1452
+ var PaymentSuccessView = ({
1453
+ details,
1454
+ planName,
1455
+ planAmount,
1456
+ planCurrency = "USD",
1457
+ invoiceDownloadUrl,
1458
+ dashboardUrl = "/dashboard",
1459
+ supportUrl = "/support"
1460
+ }) => {
1474
1461
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-md mx-auto bg-white rounded-lg shadow-md overflow-hidden", children: [
1475
1462
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-gradient-to-r from-green-500 to-green-600 text-white p-6 text-center", children: [
1476
1463
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-4xl mb-2", children: "\u2705" }),
@@ -1485,9 +1472,18 @@ var PaymentSuccessView = ({ details }) => {
1485
1472
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600", children: "Payment Gateway" }),
1486
1473
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium capitalize", children: details.gateway })
1487
1474
  ] }),
1488
- details.sessionId && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
1489
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600", children: "Session ID" }),
1490
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium font-mono text-sm", children: details.sessionId })
1475
+ planName && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
1476
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600", children: "Plan" }),
1477
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: planName })
1478
+ ] }),
1479
+ planAmount && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
1480
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600", children: "Amount" }),
1481
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
1482
+ "$",
1483
+ planAmount,
1484
+ " ",
1485
+ planCurrency
1486
+ ] })
1491
1487
  ] }),
1492
1488
  details.paymentId && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
1493
1489
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600", children: "Payment ID" }),
@@ -1507,32 +1503,40 @@ var PaymentSuccessView = ({ details }) => {
1507
1503
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-blue-900 mb-2", children: "What's Next?" }),
1508
1504
  /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "text-sm text-blue-800 space-y-1", children: [
1509
1505
  /* @__PURE__ */ jsxRuntime.jsx("li", { children: "\u2022 You'll receive a confirmation email shortly" }),
1510
- /* @__PURE__ */ jsxRuntime.jsx("li", { children: "\u2022 Your subscription/purchase is now active" }),
1506
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "\u2022 Your subscription is now active" }),
1511
1507
  /* @__PURE__ */ jsxRuntime.jsx("li", { children: "\u2022 Access your dashboard to manage your account" })
1512
1508
  ] })
1513
1509
  ] }),
1514
1510
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1515
- /* @__PURE__ */ jsxRuntime.jsx(
1511
+ invoiceDownloadUrl ? /* @__PURE__ */ jsxRuntime.jsx(
1512
+ "a",
1513
+ {
1514
+ href: invoiceDownloadUrl,
1515
+ download: true,
1516
+ className: "w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-md transition-colors block text-center",
1517
+ children: "Download Invoice"
1518
+ }
1519
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
1516
1520
  "button",
1517
1521
  {
1518
- onClick: () => window.location.href = "/dashboard",
1522
+ onClick: () => window.location.href = dashboardUrl,
1519
1523
  className: "w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-md transition-colors",
1520
- children: "Go to Dashboard"
1524
+ children: "Download Invoice"
1521
1525
  }
1522
1526
  ),
1523
1527
  /* @__PURE__ */ jsxRuntime.jsx(
1524
1528
  "button",
1525
1529
  {
1526
- onClick: () => window.location.href = "/",
1530
+ onClick: () => window.location.href = dashboardUrl,
1527
1531
  className: "w-full bg-gray-100 hover:bg-gray-200 text-gray-700 font-medium py-3 px-4 rounded-md transition-colors",
1528
- children: "Return Home"
1532
+ children: "Go to Dashboard"
1529
1533
  }
1530
1534
  )
1531
1535
  ] }),
1532
1536
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-6 text-center", children: /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-gray-500", children: [
1533
1537
  "Need help?",
1534
1538
  " ",
1535
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: "/support", className: "text-blue-600 hover:text-blue-700", children: "Contact Support" })
1539
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: supportUrl, className: "text-blue-600 hover:text-blue-700", children: "Contact Support" })
1536
1540
  ] }) })
1537
1541
  ] })
1538
1542
  ] });
@@ -2770,7 +2774,7 @@ var UpgradeSummary = ({
2770
2774
  e.currentTarget.style.boxShadow = "0 4px 12px rgba(239, 68, 68, 0.3)";
2771
2775
  } : void 0,
2772
2776
  title: isShowingCurrentPlan ? "This is your current active plan" : void 0,
2773
- children: loading ? "Loading..." : isShowingCurrentPlan ? "Current Plan" : "Upgrade Now"
2777
+ children: loading ? "Loading..." : isShowingCurrentPlan ? "Current Plan" : (checkoutInfo == null ? void 0 : checkoutInfo.proration) === 0 ? "Confirm Changes" : "Upgrade Now"
2774
2778
  }
2775
2779
  )
2776
2780
  ] })