@axcode/axcloud-sdk 0.4.0-dev.539050f → 0.4.0-dev.88ecf17
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/README.md +27 -1
- package/dist/barnsport.d.mts +5 -4
- package/dist/barnsport.d.ts +5 -4
- package/dist/index.d.mts +63 -10
- package/dist/index.d.ts +63 -10
- package/dist/index.js +44 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -11
- package/dist/index.mjs.map +1 -1
- package/dist/public.d.mts +4 -3
- package/dist/public.d.ts +4 -3
- package/dist/{useBarnsport-DHyNF9GM.d.mts → useBarnsport-3NwAFn3h.d.mts} +2 -1
- package/dist/{useBarnsport-DHyNF9GM.d.ts → useBarnsport-3NwAFn3h.d.ts} +2 -1
- package/dist/{useContent-CGI1l3Gs.d.ts → useContent-BULNVLEx.d.ts} +2 -1
- package/dist/{useContent-DLoyqAWH.d.mts → useContent-qNaQd8Xi.d.mts} +2 -1
- package/package.json +8 -8
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
|
*/
|
|
@@ -413,7 +441,8 @@ function useAuth() {
|
|
|
413
441
|
}
|
|
414
442
|
}, [getAccessTokenSilently]);
|
|
415
443
|
const refreshUser = useCallback(async () => {
|
|
416
|
-
await getAccessTokenSilently({ cacheMode: "off" });
|
|
444
|
+
const token = await getAccessTokenSilently({ cacheMode: "off" });
|
|
445
|
+
if (!token) return false;
|
|
417
446
|
const claims = await getIdTokenClaims();
|
|
418
447
|
return claims?.email_verified === true;
|
|
419
448
|
}, [getAccessTokenSilently, getIdTokenClaims]);
|
|
@@ -859,17 +888,18 @@ function useSections() {
|
|
|
859
888
|
refetch: query.refetch
|
|
860
889
|
};
|
|
861
890
|
}
|
|
891
|
+
var FORMS_ADMIN_PATH = "/forms/admin";
|
|
862
892
|
function useForms(options = {}) {
|
|
863
|
-
const { client,
|
|
893
|
+
const { client, orgId } = useAxCloudContext();
|
|
864
894
|
const { formType, status, limit = 50, cursor } = options;
|
|
865
895
|
const query = useQuery({
|
|
866
|
-
queryKey: ["axcloud", "forms", "submissions",
|
|
896
|
+
queryKey: ["axcloud", "forms", "submissions", orgId, formType, status, limit, cursor],
|
|
867
897
|
queryFn: async () => {
|
|
868
|
-
const params = { limit };
|
|
898
|
+
const params = { org_id: orgId, limit };
|
|
869
899
|
if (formType) params.form_type = formType;
|
|
870
900
|
if (status) params.status = status;
|
|
871
901
|
if (cursor) params.cursor = cursor;
|
|
872
|
-
return client.get(
|
|
902
|
+
return client.get(`${FORMS_ADMIN_PATH}/submissions`, params);
|
|
873
903
|
},
|
|
874
904
|
staleTime: 1e3 * 30
|
|
875
905
|
// 30 seconds
|
|
@@ -886,12 +916,12 @@ function useForms(options = {}) {
|
|
|
886
916
|
};
|
|
887
917
|
}
|
|
888
918
|
function useFormStats(options = {}) {
|
|
889
|
-
const { client,
|
|
919
|
+
const { client, orgId } = useAxCloudContext();
|
|
890
920
|
const { days = 30 } = options;
|
|
891
921
|
const query = useQuery({
|
|
892
|
-
queryKey: ["axcloud", "forms", "stats",
|
|
922
|
+
queryKey: ["axcloud", "forms", "stats", orgId, days],
|
|
893
923
|
queryFn: async () => {
|
|
894
|
-
return client.get(
|
|
924
|
+
return client.get(`${FORMS_ADMIN_PATH}/stats`, { org_id: orgId, days });
|
|
895
925
|
},
|
|
896
926
|
staleTime: 1e3 * 60 * 5
|
|
897
927
|
// 5 minutes
|
|
@@ -907,7 +937,7 @@ function useFormStats(options = {}) {
|
|
|
907
937
|
};
|
|
908
938
|
}
|
|
909
939
|
function useUpdateFormSubmission() {
|
|
910
|
-
const { client,
|
|
940
|
+
const { client, orgId } = useAxCloudContext();
|
|
911
941
|
const queryClient = useQueryClient();
|
|
912
942
|
return useMutation({
|
|
913
943
|
mutationFn: async ({
|
|
@@ -915,7 +945,10 @@ function useUpdateFormSubmission() {
|
|
|
915
945
|
status,
|
|
916
946
|
notes
|
|
917
947
|
}) => {
|
|
918
|
-
return client.patch(
|
|
948
|
+
return client.patch(
|
|
949
|
+
`${FORMS_ADMIN_PATH}/submissions/${encodeURIComponent(submissionId)}?org_id=${encodeURIComponent(orgId)}`,
|
|
950
|
+
{ status, notes }
|
|
951
|
+
);
|
|
919
952
|
},
|
|
920
953
|
onSuccess: () => {
|
|
921
954
|
queryClient.invalidateQueries({ queryKey: ["axcloud", "forms"] });
|
|
@@ -1533,6 +1566,6 @@ function LinkedAccountsList({
|
|
|
1533
1566
|
] });
|
|
1534
1567
|
}
|
|
1535
1568
|
|
|
1536
|
-
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 };
|
|
1569
|
+
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 };
|
|
1537
1570
|
//# sourceMappingURL=index.mjs.map
|
|
1538
1571
|
//# sourceMappingURL=index.mjs.map
|