subos-frontend 1.0.33 → 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) => {
@@ -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);