@axcode/axcloud-sdk 0.4.0-dev.f5f8764 → 0.4.0-dev.f9603ab

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.mjs CHANGED
@@ -77,6 +77,26 @@ async function submitForm(apiUrl, submission) {
77
77
  throw primaryError;
78
78
  }
79
79
  }
80
+ async function getMembershipSections(apiUrl, options) {
81
+ const baseUrl = apiUrl.replace(/\/$/, "");
82
+ const response = await fetch(
83
+ `${baseUrl}/public/membership-sections?site=${encodeURIComponent(options.site)}`,
84
+ {
85
+ method: "GET",
86
+ headers: { "X-Api-Key": options.apiKey },
87
+ signal: options.signal
88
+ }
89
+ );
90
+ if (!response.ok) {
91
+ const error = await response.json().catch(() => ({}));
92
+ throw new Error(error.message || `Membership sections request failed (${response.status})`);
93
+ }
94
+ const result = await response.json().catch(() => ({}));
95
+ const sections = Array.isArray(result?.sections) ? result.sections : [];
96
+ return sections.filter(
97
+ (section) => !!section && typeof section.id === "string" && typeof section.name === "string"
98
+ ).map(({ id, name }) => ({ id, name }));
99
+ }
80
100
  function createFormHelper(config) {
81
101
  return {
82
102
  /**
@@ -109,6 +129,14 @@ function createFormHelper(config) {
109
129
  email,
110
130
  data
111
131
  }),
132
+ /**
133
+ * List the sections offered in the membership application
134
+ */
135
+ getMembershipSections: (options = {}) => getMembershipSections(config.apiUrl, {
136
+ apiKey: config.apiKey,
137
+ site: config.site,
138
+ signal: options.signal
139
+ }),
112
140
  /**
113
141
  * Generic submit function
114
142
  */
@@ -1537,6 +1565,6 @@ function LinkedAccountsList({
1537
1565
  ] });
1538
1566
  }
1539
1567
 
1540
- export { AxCloudProvider, LinkedAccountsList, LoginButton, LogoutButton, ModuleGate, ProtectedRoute, castVote, castVoteWithCode, checkEligibility, checkVotingCode, createFormHelper, getBallot, getVotingReceipt, submitForm, useAuth, useAvatar, useBranding, useCodeBallot, useDocumentDownload, useDocuments, useFormStats, useForms, useLinkedAccounts, useLogo, useMedia, useMediaList, useMemberDocumentDownload, useMemberDocumentFolders, useMemberDocuments, useModuleAccess, useMySection, useNews, useOrg, useSections, useUpdateFormSubmission, useUpdateMyProfile, useUser, userHasAllPermissions, userHasAnyPermission, userHasPermission };
1568
+ export { AxCloudProvider, LinkedAccountsList, LoginButton, LogoutButton, ModuleGate, ProtectedRoute, castVote, castVoteWithCode, checkEligibility, checkVotingCode, createFormHelper, getBallot, getMembershipSections, getVotingReceipt, submitForm, useAuth, useAvatar, useBranding, useCodeBallot, useDocumentDownload, useDocuments, useFormStats, useForms, useLinkedAccounts, useLogo, useMedia, useMediaList, useMemberDocumentDownload, useMemberDocumentFolders, useMemberDocuments, useModuleAccess, useMySection, useNews, useOrg, useSections, useUpdateFormSubmission, useUpdateMyProfile, useUser, userHasAllPermissions, userHasAnyPermission, userHasPermission };
1541
1569
  //# sourceMappingURL=index.mjs.map
1542
1570
  //# sourceMappingURL=index.mjs.map