@axcode/axcloud-sdk 0.1.6 → 0.1.7-dev.332678a
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 +67 -5
- package/dist/index.d.mts +537 -2
- package/dist/index.d.ts +537 -2
- package/dist/index.js +495 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +478 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -124,7 +124,7 @@ var AxCloudClient = class {
|
|
|
124
124
|
*/
|
|
125
125
|
shouldAttachApiKey(path) {
|
|
126
126
|
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
127
|
-
return normalized.startsWith("/public/") || normalized.startsWith("/api/public/") || normalized.startsWith("/content/public/");
|
|
127
|
+
return normalized.startsWith("/public/") || normalized.startsWith("/api/public/") || normalized.startsWith("/content/public/") || normalized.startsWith("/media/public/") || normalized.startsWith("/documents/public/") || normalized.startsWith("/barnsport/public/") || normalized.startsWith("/api/barnsport/public/");
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* Make an authenticated request
|
|
@@ -433,6 +433,98 @@ function createFormHelper(config) {
|
|
|
433
433
|
})
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
|
+
|
|
437
|
+
// src/core/voting.ts
|
|
438
|
+
function baseOf(votingApiUrl) {
|
|
439
|
+
return votingApiUrl.replace(/\/$/, "");
|
|
440
|
+
}
|
|
441
|
+
async function readJson(response) {
|
|
442
|
+
const json = await response.json().catch(() => ({}));
|
|
443
|
+
if (json && typeof json === "object" && "success" in json && "data" in json) {
|
|
444
|
+
return json.data;
|
|
445
|
+
}
|
|
446
|
+
return json;
|
|
447
|
+
}
|
|
448
|
+
async function ensureOk(response) {
|
|
449
|
+
if (!response.ok) {
|
|
450
|
+
const body = await response.json().catch(() => ({}));
|
|
451
|
+
const message = body && (body.error || body.message) || `Request failed with status ${response.status}`;
|
|
452
|
+
throw new Error(message);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
async function checkVotingCode(votingApiUrl, params) {
|
|
456
|
+
const response = await fetch(
|
|
457
|
+
`${baseOf(votingApiUrl)}/public/organizations/${params.orgId}/polls/${params.pollId}/eligibility`,
|
|
458
|
+
{
|
|
459
|
+
method: "POST",
|
|
460
|
+
headers: { "Content-Type": "application/json" },
|
|
461
|
+
body: JSON.stringify({ code: params.code })
|
|
462
|
+
}
|
|
463
|
+
);
|
|
464
|
+
await ensureOk(response);
|
|
465
|
+
return readJson(response);
|
|
466
|
+
}
|
|
467
|
+
async function castVoteWithCode(votingApiUrl, params) {
|
|
468
|
+
const response = await fetch(
|
|
469
|
+
`${baseOf(votingApiUrl)}/public/organizations/${params.orgId}/polls/${params.pollId}/vote`,
|
|
470
|
+
{
|
|
471
|
+
method: "POST",
|
|
472
|
+
headers: { "Content-Type": "application/json" },
|
|
473
|
+
body: JSON.stringify({ code: params.code, selected_options: params.selectedOptions, rankings: params.rankings })
|
|
474
|
+
}
|
|
475
|
+
);
|
|
476
|
+
await ensureOk(response);
|
|
477
|
+
return readJson(response);
|
|
478
|
+
}
|
|
479
|
+
async function getVotingReceipt(votingApiUrl, params) {
|
|
480
|
+
const response = await fetch(
|
|
481
|
+
`${baseOf(votingApiUrl)}/public/organizations/${params.orgId}/polls/${params.pollId}/receipt`,
|
|
482
|
+
{
|
|
483
|
+
method: "POST",
|
|
484
|
+
headers: { "Content-Type": "application/json" },
|
|
485
|
+
body: JSON.stringify({ code: params.code })
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
await ensureOk(response);
|
|
489
|
+
return readJson(response);
|
|
490
|
+
}
|
|
491
|
+
function authHeaders(accessToken) {
|
|
492
|
+
return { "Content-Type": "application/json", Authorization: `Bearer ${accessToken}` };
|
|
493
|
+
}
|
|
494
|
+
async function getBallot(votingApiUrl, params) {
|
|
495
|
+
const base = `${baseOf(votingApiUrl)}/organizations/${params.orgId}/polls/${params.pollId}`;
|
|
496
|
+
const pollResp = await fetch(base, { headers: authHeaders(params.accessToken) });
|
|
497
|
+
await ensureOk(pollResp);
|
|
498
|
+
const poll = await readJson(pollResp);
|
|
499
|
+
let candidates = [];
|
|
500
|
+
if (poll.poll_type === "election") {
|
|
501
|
+
const candResp = await fetch(`${base}/candidates`, { headers: authHeaders(params.accessToken) });
|
|
502
|
+
await ensureOk(candResp);
|
|
503
|
+
const data = await readJson(candResp);
|
|
504
|
+
candidates = data.candidates || [];
|
|
505
|
+
}
|
|
506
|
+
return { ...poll, candidates };
|
|
507
|
+
}
|
|
508
|
+
async function checkEligibility(votingApiUrl, params) {
|
|
509
|
+
const response = await fetch(
|
|
510
|
+
`${baseOf(votingApiUrl)}/organizations/${params.orgId}/polls/${params.pollId}/eligibility`,
|
|
511
|
+
{ headers: authHeaders(params.accessToken) }
|
|
512
|
+
);
|
|
513
|
+
await ensureOk(response);
|
|
514
|
+
return readJson(response);
|
|
515
|
+
}
|
|
516
|
+
async function castVote(votingApiUrl, params) {
|
|
517
|
+
const response = await fetch(
|
|
518
|
+
`${baseOf(votingApiUrl)}/organizations/${params.orgId}/polls/${params.pollId}/vote`,
|
|
519
|
+
{
|
|
520
|
+
method: "POST",
|
|
521
|
+
headers: authHeaders(params.accessToken),
|
|
522
|
+
body: JSON.stringify({ selected_options: params.selectedOptions, rankings: params.rankings })
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
await ensureOk(response);
|
|
526
|
+
return readJson(response);
|
|
527
|
+
}
|
|
436
528
|
var AxCloudContext = react.createContext(null);
|
|
437
529
|
function useAxCloudContext() {
|
|
438
530
|
const context = react.useContext(AxCloudContext);
|
|
@@ -521,14 +613,15 @@ function AxCloudProvider({
|
|
|
521
613
|
clientId: auth0.clientId,
|
|
522
614
|
authorizationParams: {
|
|
523
615
|
redirect_uri: auth0.redirectUri,
|
|
524
|
-
audience: auth0.audience
|
|
616
|
+
audience: auth0.audience,
|
|
617
|
+
...auth0.organization ? { organization: auth0.organization } : {}
|
|
525
618
|
},
|
|
526
619
|
children: /* @__PURE__ */ jsxRuntime.jsx(AxCloudInnerProvider, { config, timeout, children })
|
|
527
620
|
}
|
|
528
621
|
) });
|
|
529
622
|
}
|
|
530
623
|
function useAuth() {
|
|
531
|
-
const { config } = useAxCloudContext();
|
|
624
|
+
const { config, client } = useAxCloudContext();
|
|
532
625
|
const {
|
|
533
626
|
isAuthenticated,
|
|
534
627
|
isLoading,
|
|
@@ -544,10 +637,15 @@ function useAuth() {
|
|
|
544
637
|
return loginWithRedirect({
|
|
545
638
|
appState: {
|
|
546
639
|
returnTo: options?.returnTo || window.location.pathname
|
|
547
|
-
}
|
|
640
|
+
},
|
|
641
|
+
...config.auth0.organization ? {
|
|
642
|
+
authorizationParams: {
|
|
643
|
+
organization: config.auth0.organization
|
|
644
|
+
}
|
|
645
|
+
} : {}
|
|
548
646
|
});
|
|
549
647
|
},
|
|
550
|
-
[loginWithRedirect]
|
|
648
|
+
[config.auth0.organization, loginWithRedirect]
|
|
551
649
|
);
|
|
552
650
|
const logout = react.useCallback(
|
|
553
651
|
(options) => {
|
|
@@ -566,6 +664,60 @@ function useAuth() {
|
|
|
566
664
|
return void 0;
|
|
567
665
|
}
|
|
568
666
|
}, [getAccessTokenSilently]);
|
|
667
|
+
const refreshUser = react.useCallback(async () => {
|
|
668
|
+
await getAccessTokenSilently({ cacheMode: "off" });
|
|
669
|
+
const claims = await getIdTokenClaims();
|
|
670
|
+
return claims?.email_verified === true;
|
|
671
|
+
}, [getAccessTokenSilently, getIdTokenClaims]);
|
|
672
|
+
const requestEmailVerification = react.useCallback(
|
|
673
|
+
async (options) => {
|
|
674
|
+
if (!isAuthenticated || !auth0User) {
|
|
675
|
+
return {
|
|
676
|
+
success: false,
|
|
677
|
+
status: "failed",
|
|
678
|
+
message: "You must be signed in to verify your email."
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
if (auth0User.email_verified === true) {
|
|
682
|
+
return {
|
|
683
|
+
success: true,
|
|
684
|
+
status: "already_verified",
|
|
685
|
+
message: "Your email address is already verified."
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
try {
|
|
689
|
+
const response = await client.post("/email/identity/verification-email", {
|
|
690
|
+
return_to: options?.returnTo || window.location.href
|
|
691
|
+
});
|
|
692
|
+
const data = response.data || {};
|
|
693
|
+
return {
|
|
694
|
+
success: true,
|
|
695
|
+
status: data.status || "sent",
|
|
696
|
+
message: data.message || "A verification email has been sent.",
|
|
697
|
+
...data.retry_after_seconds !== void 0 ? { retryAfterSeconds: data.retry_after_seconds } : {}
|
|
698
|
+
};
|
|
699
|
+
} catch (requestError) {
|
|
700
|
+
if (isAxCloudError(requestError) && requestError.status === 429) {
|
|
701
|
+
const responseDetails = requestError.details?.details;
|
|
702
|
+
const retryAfterSeconds = Number(
|
|
703
|
+
responseDetails && typeof responseDetails === "object" ? responseDetails.retry_after_seconds : void 0
|
|
704
|
+
);
|
|
705
|
+
return {
|
|
706
|
+
success: false,
|
|
707
|
+
status: "rate_limited",
|
|
708
|
+
message: "Please wait before requesting another verification email.",
|
|
709
|
+
...Number.isFinite(retryAfterSeconds) ? { retryAfterSeconds } : {}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
return {
|
|
713
|
+
success: false,
|
|
714
|
+
status: "failed",
|
|
715
|
+
message: "Failed to send the verification email. Please try again."
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
[auth0User, client, isAuthenticated]
|
|
720
|
+
);
|
|
569
721
|
const getAuth0Client = react.useCallback(() => {
|
|
570
722
|
return {
|
|
571
723
|
loginWithRedirect,
|
|
@@ -639,13 +791,17 @@ function useAuth() {
|
|
|
639
791
|
id: auth0User.sub || "",
|
|
640
792
|
email: auth0User.email || "",
|
|
641
793
|
name: auth0User.name || "",
|
|
642
|
-
avatar: auth0User.picture
|
|
794
|
+
avatar: auth0User.picture,
|
|
795
|
+
...typeof auth0User.email_verified === "boolean" ? { emailVerified: auth0User.email_verified } : {}
|
|
643
796
|
} : null,
|
|
797
|
+
needsEmailVerification: isAuthenticated && auth0User?.email_verified === false,
|
|
644
798
|
login,
|
|
645
799
|
logout,
|
|
646
800
|
// Escape hatch for advanced use cases
|
|
647
801
|
getAccessToken,
|
|
648
802
|
getAuth0Client,
|
|
803
|
+
refreshUser,
|
|
804
|
+
requestEmailVerification,
|
|
649
805
|
// Password management
|
|
650
806
|
requestPasswordReset
|
|
651
807
|
};
|
|
@@ -743,6 +899,7 @@ function useNews(options = {}) {
|
|
|
743
899
|
search,
|
|
744
900
|
sortBy = "publishedAt",
|
|
745
901
|
sortOrder = "desc",
|
|
902
|
+
lang,
|
|
746
903
|
publicOnly = false
|
|
747
904
|
} = options;
|
|
748
905
|
const usePublicEndpoint = isPublicMode || publicOnly;
|
|
@@ -759,7 +916,8 @@ function useNews(options = {}) {
|
|
|
759
916
|
sectionId,
|
|
760
917
|
search,
|
|
761
918
|
sortBy,
|
|
762
|
-
sortOrder
|
|
919
|
+
sortOrder,
|
|
920
|
+
lang
|
|
763
921
|
],
|
|
764
922
|
queryFn: async () => {
|
|
765
923
|
const endpoint = usePublicEndpoint ? `/content/public/${orgId}/news` : `/content/members/${orgId}/news`;
|
|
@@ -771,7 +929,8 @@ function useNews(options = {}) {
|
|
|
771
929
|
sectionId,
|
|
772
930
|
search,
|
|
773
931
|
sortBy,
|
|
774
|
-
sortOrder
|
|
932
|
+
sortOrder,
|
|
933
|
+
lang
|
|
775
934
|
});
|
|
776
935
|
},
|
|
777
936
|
staleTime: 1e3 * 60 * 5
|
|
@@ -1000,6 +1159,76 @@ function useUpdateFormSubmission() {
|
|
|
1000
1159
|
}
|
|
1001
1160
|
});
|
|
1002
1161
|
}
|
|
1162
|
+
function useCodeBallot({ pollId, votingApiUrl }) {
|
|
1163
|
+
const { orgId, config } = useAxCloudContext();
|
|
1164
|
+
const baseUrl = votingApiUrl || `${config.apiUrl.replace(/\/$/, "")}/voting`;
|
|
1165
|
+
const [stage, setStage] = react.useState("enter_code");
|
|
1166
|
+
const [code, setCode] = react.useState("");
|
|
1167
|
+
const [ballot, setBallot] = react.useState(null);
|
|
1168
|
+
const [receipt, setReceipt] = react.useState(null);
|
|
1169
|
+
const [reason, setReason] = react.useState(void 0);
|
|
1170
|
+
const [loading, setLoading] = react.useState(false);
|
|
1171
|
+
const [error, setError] = react.useState(null);
|
|
1172
|
+
const validateCode = react.useCallback(
|
|
1173
|
+
async (inputCode) => {
|
|
1174
|
+
setLoading(true);
|
|
1175
|
+
setError(null);
|
|
1176
|
+
try {
|
|
1177
|
+
const result = await checkVotingCode(baseUrl, { orgId, pollId, code: inputCode });
|
|
1178
|
+
setCode(inputCode);
|
|
1179
|
+
setReason(result.reason);
|
|
1180
|
+
if (result.has_voted) {
|
|
1181
|
+
const r = await getVotingReceipt(baseUrl, { orgId, pollId, code: inputCode }).catch(() => null);
|
|
1182
|
+
setReceipt(r);
|
|
1183
|
+
setStage("already_voted");
|
|
1184
|
+
} else if (result.eligible && result.ballot) {
|
|
1185
|
+
setBallot(result.ballot);
|
|
1186
|
+
setStage("ballot");
|
|
1187
|
+
} else {
|
|
1188
|
+
setError(result.reason || "This code cannot be used to vote right now.");
|
|
1189
|
+
}
|
|
1190
|
+
return result;
|
|
1191
|
+
} catch (e) {
|
|
1192
|
+
setError(e instanceof Error ? e.message : "Failed to validate code");
|
|
1193
|
+
return null;
|
|
1194
|
+
} finally {
|
|
1195
|
+
setLoading(false);
|
|
1196
|
+
}
|
|
1197
|
+
},
|
|
1198
|
+
[baseUrl, orgId, pollId]
|
|
1199
|
+
);
|
|
1200
|
+
const submitVote = react.useCallback(
|
|
1201
|
+
async (selectedOptions, rankings) => {
|
|
1202
|
+
setLoading(true);
|
|
1203
|
+
setError(null);
|
|
1204
|
+
try {
|
|
1205
|
+
await castVoteWithCode(baseUrl, { orgId, pollId, code, selectedOptions, rankings });
|
|
1206
|
+
const r = await getVotingReceipt(baseUrl, { orgId, pollId, code }).catch(() => null);
|
|
1207
|
+
setReceipt(r);
|
|
1208
|
+
setStage("submitted");
|
|
1209
|
+
return true;
|
|
1210
|
+
} catch (e) {
|
|
1211
|
+
setError(e instanceof Error ? e.message : "Failed to submit vote");
|
|
1212
|
+
return false;
|
|
1213
|
+
} finally {
|
|
1214
|
+
setLoading(false);
|
|
1215
|
+
}
|
|
1216
|
+
},
|
|
1217
|
+
[baseUrl, orgId, pollId, code]
|
|
1218
|
+
);
|
|
1219
|
+
const reset = react.useCallback(() => {
|
|
1220
|
+
setStage("enter_code");
|
|
1221
|
+
setCode("");
|
|
1222
|
+
setBallot(null);
|
|
1223
|
+
setReceipt(null);
|
|
1224
|
+
setReason(void 0);
|
|
1225
|
+
setError(null);
|
|
1226
|
+
}, []);
|
|
1227
|
+
return react.useMemo(
|
|
1228
|
+
() => ({ stage, code, ballot, receipt, reason, loading, error, validateCode, submitVote, reset }),
|
|
1229
|
+
[stage, code, ballot, receipt, reason, loading, error, validateCode, submitVote, reset]
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1003
1232
|
var LINKED_ACCOUNTS_QUERY_KEY = ["axcloud", "linked-accounts"];
|
|
1004
1233
|
function useLinkedAccounts() {
|
|
1005
1234
|
const { client, stage } = useAxCloudContext();
|
|
@@ -1158,6 +1387,245 @@ function useMedia(mediaId) {
|
|
|
1158
1387
|
refetch: query.refetch
|
|
1159
1388
|
};
|
|
1160
1389
|
}
|
|
1390
|
+
function buildDocumentParams(options) {
|
|
1391
|
+
return {
|
|
1392
|
+
search: options?.search,
|
|
1393
|
+
tags: options?.tags?.join(","),
|
|
1394
|
+
limit: options?.limit
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
function useDocuments(options) {
|
|
1398
|
+
const { client, orgId } = useAxCloudContext();
|
|
1399
|
+
const params = buildDocumentParams(options);
|
|
1400
|
+
const query = reactQuery.useQuery({
|
|
1401
|
+
queryKey: ["axcloud", "documents", "list", orgId, options],
|
|
1402
|
+
queryFn: async () => {
|
|
1403
|
+
return client.get(`/documents/public/${orgId}/documents`, params);
|
|
1404
|
+
},
|
|
1405
|
+
staleTime: 1e3 * 60 * 5
|
|
1406
|
+
});
|
|
1407
|
+
return {
|
|
1408
|
+
documents: query.data?.items ?? [],
|
|
1409
|
+
items: query.data?.items ?? [],
|
|
1410
|
+
count: query.data?.count ?? 0,
|
|
1411
|
+
isLoading: query.isLoading,
|
|
1412
|
+
isError: query.isError,
|
|
1413
|
+
error: query.error,
|
|
1414
|
+
refetch: query.refetch
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
function useDocumentDownload(documentId) {
|
|
1418
|
+
const { client, orgId } = useAxCloudContext();
|
|
1419
|
+
const query = reactQuery.useQuery({
|
|
1420
|
+
queryKey: ["axcloud", "documents", "download", orgId, documentId],
|
|
1421
|
+
queryFn: async () => {
|
|
1422
|
+
return client.get(
|
|
1423
|
+
`/documents/public/${orgId}/documents/${encodeURIComponent(documentId || "")}/download`
|
|
1424
|
+
);
|
|
1425
|
+
},
|
|
1426
|
+
enabled: !!documentId,
|
|
1427
|
+
staleTime: 1e3 * 60 * 10,
|
|
1428
|
+
gcTime: 1e3 * 60 * 14
|
|
1429
|
+
});
|
|
1430
|
+
return {
|
|
1431
|
+
url: query.data?.url ?? null,
|
|
1432
|
+
documentUrl: query.data?.url ?? null,
|
|
1433
|
+
filename: query.data?.filename ?? null,
|
|
1434
|
+
mimeType: query.data?.mimeType ?? null,
|
|
1435
|
+
expiresIn: query.data?.expiresIn ?? null,
|
|
1436
|
+
isLoading: query.isLoading,
|
|
1437
|
+
isError: query.isError,
|
|
1438
|
+
error: query.error,
|
|
1439
|
+
refetch: query.refetch
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
function useMemberDocuments(options) {
|
|
1443
|
+
const { client, orgId } = useAxCloudContext();
|
|
1444
|
+
const params = buildDocumentParams(options);
|
|
1445
|
+
const folderId = options?.folderId;
|
|
1446
|
+
const query = reactQuery.useQuery({
|
|
1447
|
+
queryKey: ["axcloud", "documents", "member", "list", orgId, options],
|
|
1448
|
+
queryFn: async () => {
|
|
1449
|
+
return client.get(`/documents/members/${orgId}/documents`, params);
|
|
1450
|
+
},
|
|
1451
|
+
staleTime: 1e3 * 60 * 5
|
|
1452
|
+
});
|
|
1453
|
+
const allItems = query.data?.items ?? [];
|
|
1454
|
+
const items = folderId ? allItems.filter((doc) => doc.folder_ids?.includes(folderId)) : allItems;
|
|
1455
|
+
return {
|
|
1456
|
+
documents: items,
|
|
1457
|
+
items,
|
|
1458
|
+
count: folderId ? items.length : query.data?.count ?? 0,
|
|
1459
|
+
isLoading: query.isLoading,
|
|
1460
|
+
isError: query.isError,
|
|
1461
|
+
error: query.error,
|
|
1462
|
+
refetch: query.refetch
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
function useMemberDocumentFolders() {
|
|
1466
|
+
const { client, orgId } = useAxCloudContext();
|
|
1467
|
+
const query = reactQuery.useQuery({
|
|
1468
|
+
queryKey: ["axcloud", "documents", "member", "folders", orgId],
|
|
1469
|
+
queryFn: async () => {
|
|
1470
|
+
return client.get(
|
|
1471
|
+
`/documents/members/${orgId}/document-folders`
|
|
1472
|
+
);
|
|
1473
|
+
},
|
|
1474
|
+
staleTime: 1e3 * 60 * 5
|
|
1475
|
+
});
|
|
1476
|
+
return {
|
|
1477
|
+
folders: query.data?.folders ?? [],
|
|
1478
|
+
isLoading: query.isLoading,
|
|
1479
|
+
isError: query.isError,
|
|
1480
|
+
error: query.error,
|
|
1481
|
+
refetch: query.refetch
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
function useMemberDocumentDownload(documentId) {
|
|
1485
|
+
const { client, orgId } = useAxCloudContext();
|
|
1486
|
+
const query = reactQuery.useQuery({
|
|
1487
|
+
queryKey: ["axcloud", "documents", "member", "download", orgId, documentId],
|
|
1488
|
+
queryFn: async () => {
|
|
1489
|
+
return client.get(
|
|
1490
|
+
`/documents/members/${orgId}/documents/${encodeURIComponent(documentId || "")}/download`
|
|
1491
|
+
);
|
|
1492
|
+
},
|
|
1493
|
+
enabled: !!documentId,
|
|
1494
|
+
staleTime: 1e3 * 60 * 10,
|
|
1495
|
+
gcTime: 1e3 * 60 * 14
|
|
1496
|
+
});
|
|
1497
|
+
return {
|
|
1498
|
+
url: query.data?.url ?? null,
|
|
1499
|
+
documentUrl: query.data?.url ?? null,
|
|
1500
|
+
filename: query.data?.filename ?? null,
|
|
1501
|
+
mimeType: query.data?.mimeType ?? null,
|
|
1502
|
+
expiresIn: query.data?.expiresIn ?? null,
|
|
1503
|
+
isLoading: query.isLoading,
|
|
1504
|
+
isError: query.isError,
|
|
1505
|
+
error: query.error,
|
|
1506
|
+
refetch: query.refetch
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
function useBarnsportMunicipalities() {
|
|
1510
|
+
const { client, orgId } = useAxCloudContext();
|
|
1511
|
+
const query = reactQuery.useQuery({
|
|
1512
|
+
queryKey: ["axcloud", "barnsport", "municipalities", orgId],
|
|
1513
|
+
queryFn: () => client.get(
|
|
1514
|
+
`/barnsport/public/${orgId}/municipalities`
|
|
1515
|
+
),
|
|
1516
|
+
staleTime: 1e3 * 60 * 30
|
|
1517
|
+
});
|
|
1518
|
+
return {
|
|
1519
|
+
municipalities: query.data?.items ?? [],
|
|
1520
|
+
count: query.data?.count ?? 0,
|
|
1521
|
+
isLoading: query.isLoading,
|
|
1522
|
+
isError: query.isError,
|
|
1523
|
+
error: query.error,
|
|
1524
|
+
refetch: query.refetch
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
function useBarnsportSports() {
|
|
1528
|
+
const { client, orgId } = useAxCloudContext();
|
|
1529
|
+
const query = reactQuery.useQuery({
|
|
1530
|
+
queryKey: ["axcloud", "barnsport", "sports", orgId],
|
|
1531
|
+
queryFn: () => client.get(
|
|
1532
|
+
`/barnsport/public/${orgId}/sports`
|
|
1533
|
+
),
|
|
1534
|
+
staleTime: 1e3 * 60 * 30
|
|
1535
|
+
});
|
|
1536
|
+
return {
|
|
1537
|
+
sports: query.data?.items ?? [],
|
|
1538
|
+
count: query.data?.count ?? 0,
|
|
1539
|
+
isLoading: query.isLoading,
|
|
1540
|
+
isError: query.isError,
|
|
1541
|
+
error: query.error,
|
|
1542
|
+
refetch: query.refetch
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
function useBarnsportSport(slug) {
|
|
1546
|
+
const { client, orgId } = useAxCloudContext();
|
|
1547
|
+
const query = reactQuery.useQuery({
|
|
1548
|
+
queryKey: ["axcloud", "barnsport", "sport", orgId, slug],
|
|
1549
|
+
queryFn: () => client.get(
|
|
1550
|
+
`/barnsport/public/${orgId}/sports/${slug || ""}`
|
|
1551
|
+
),
|
|
1552
|
+
enabled: Boolean(slug),
|
|
1553
|
+
staleTime: 1e3 * 60 * 15
|
|
1554
|
+
});
|
|
1555
|
+
return {
|
|
1556
|
+
sport: query.data?.sport ?? null,
|
|
1557
|
+
isLoading: query.isLoading,
|
|
1558
|
+
isError: query.isError,
|
|
1559
|
+
error: query.error,
|
|
1560
|
+
refetch: query.refetch
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
function useBarnsportActivities(filters = {}) {
|
|
1564
|
+
const { client, orgId } = useAxCloudContext();
|
|
1565
|
+
const params = { ...filters };
|
|
1566
|
+
const query = reactQuery.useQuery({
|
|
1567
|
+
queryKey: ["axcloud", "barnsport", "activities", orgId, filters],
|
|
1568
|
+
queryFn: () => client.get(
|
|
1569
|
+
`/barnsport/public/${orgId}/activities`,
|
|
1570
|
+
params
|
|
1571
|
+
),
|
|
1572
|
+
staleTime: 1e3 * 60 * 5
|
|
1573
|
+
});
|
|
1574
|
+
return {
|
|
1575
|
+
activities: query.data?.items ?? [],
|
|
1576
|
+
count: query.data?.count ?? 0,
|
|
1577
|
+
nextCursor: query.data?.nextCursor ?? null,
|
|
1578
|
+
isLoading: query.isLoading,
|
|
1579
|
+
isError: query.isError,
|
|
1580
|
+
error: query.error,
|
|
1581
|
+
refetch: query.refetch
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
function useBarnsportActivity(slug) {
|
|
1585
|
+
const { client, orgId } = useAxCloudContext();
|
|
1586
|
+
const query = reactQuery.useQuery({
|
|
1587
|
+
queryKey: ["axcloud", "barnsport", "activity", orgId, slug],
|
|
1588
|
+
queryFn: () => client.get(
|
|
1589
|
+
`/barnsport/public/${orgId}/activities/${slug || ""}`
|
|
1590
|
+
),
|
|
1591
|
+
enabled: Boolean(slug),
|
|
1592
|
+
staleTime: 1e3 * 60 * 5
|
|
1593
|
+
});
|
|
1594
|
+
return {
|
|
1595
|
+
activity: query.data?.activity ?? null,
|
|
1596
|
+
isLoading: query.isLoading,
|
|
1597
|
+
isError: query.isError,
|
|
1598
|
+
error: query.error,
|
|
1599
|
+
refetch: query.refetch
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
function useBarnsportSitemap(baseUrl) {
|
|
1603
|
+
const { client, orgId } = useAxCloudContext();
|
|
1604
|
+
const query = reactQuery.useQuery({
|
|
1605
|
+
queryKey: ["axcloud", "barnsport", "sitemap", orgId, baseUrl],
|
|
1606
|
+
queryFn: () => client.get(`/barnsport/public/${orgId}/sitemap`, {
|
|
1607
|
+
baseUrl
|
|
1608
|
+
}),
|
|
1609
|
+
staleTime: 1e3 * 60 * 15
|
|
1610
|
+
});
|
|
1611
|
+
return {
|
|
1612
|
+
sitemap: query.data ?? null,
|
|
1613
|
+
urls: query.data?.urls ?? [],
|
|
1614
|
+
isLoading: query.isLoading,
|
|
1615
|
+
isError: query.isError,
|
|
1616
|
+
error: query.error,
|
|
1617
|
+
refetch: query.refetch
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
function useSubmitBarnsportInterest() {
|
|
1621
|
+
const { client, orgId } = useAxCloudContext();
|
|
1622
|
+
return reactQuery.useMutation({
|
|
1623
|
+
mutationFn: (submission) => client.post(
|
|
1624
|
+
`/barnsport/public/${orgId}/interest`,
|
|
1625
|
+
submission
|
|
1626
|
+
)
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1161
1629
|
function LoginButton({
|
|
1162
1630
|
children = "Log in",
|
|
1163
1631
|
returnTo,
|
|
@@ -1409,31 +1877,50 @@ exports.LoginButton = LoginButton;
|
|
|
1409
1877
|
exports.LogoutButton = LogoutButton;
|
|
1410
1878
|
exports.ModuleGate = ModuleGate;
|
|
1411
1879
|
exports.ProtectedRoute = ProtectedRoute;
|
|
1880
|
+
exports.castVote = castVote;
|
|
1881
|
+
exports.castVoteWithCode = castVoteWithCode;
|
|
1882
|
+
exports.checkEligibility = checkEligibility;
|
|
1883
|
+
exports.checkVotingCode = checkVotingCode;
|
|
1412
1884
|
exports.createClient = createClient;
|
|
1413
1885
|
exports.createContentSlotReader = createContentSlotReader;
|
|
1414
1886
|
exports.createFormHelper = createFormHelper;
|
|
1887
|
+
exports.getBallot = getBallot;
|
|
1415
1888
|
exports.getClient = getClient;
|
|
1416
1889
|
exports.getContentSlotMap = getContentSlotMap;
|
|
1890
|
+
exports.getVotingReceipt = getVotingReceipt;
|
|
1417
1891
|
exports.isAxCloudError = isAxCloudError;
|
|
1418
1892
|
exports.submitForm = submitForm;
|
|
1419
1893
|
exports.useAuth = useAuth;
|
|
1420
1894
|
exports.useAvatar = useAvatar;
|
|
1421
1895
|
exports.useAxCloudContext = useAxCloudContext;
|
|
1896
|
+
exports.useBarnsportActivities = useBarnsportActivities;
|
|
1897
|
+
exports.useBarnsportActivity = useBarnsportActivity;
|
|
1898
|
+
exports.useBarnsportMunicipalities = useBarnsportMunicipalities;
|
|
1899
|
+
exports.useBarnsportSitemap = useBarnsportSitemap;
|
|
1900
|
+
exports.useBarnsportSport = useBarnsportSport;
|
|
1901
|
+
exports.useBarnsportSports = useBarnsportSports;
|
|
1422
1902
|
exports.useBranding = useBranding;
|
|
1903
|
+
exports.useCodeBallot = useCodeBallot;
|
|
1423
1904
|
exports.useContent = useContent;
|
|
1424
1905
|
exports.useContentItem = useContentItem;
|
|
1906
|
+
exports.useDocumentDownload = useDocumentDownload;
|
|
1907
|
+
exports.useDocuments = useDocuments;
|
|
1425
1908
|
exports.useFormStats = useFormStats;
|
|
1426
1909
|
exports.useForms = useForms;
|
|
1427
1910
|
exports.useLinkedAccounts = useLinkedAccounts;
|
|
1428
1911
|
exports.useLogo = useLogo;
|
|
1429
1912
|
exports.useMedia = useMedia;
|
|
1430
1913
|
exports.useMediaList = useMediaList;
|
|
1914
|
+
exports.useMemberDocumentDownload = useMemberDocumentDownload;
|
|
1915
|
+
exports.useMemberDocumentFolders = useMemberDocumentFolders;
|
|
1916
|
+
exports.useMemberDocuments = useMemberDocuments;
|
|
1431
1917
|
exports.useModuleAccess = useModuleAccess;
|
|
1432
1918
|
exports.useMySection = useMySection;
|
|
1433
1919
|
exports.useNews = useNews;
|
|
1434
1920
|
exports.useOrg = useOrg;
|
|
1435
1921
|
exports.usePageContent = usePageContent;
|
|
1436
1922
|
exports.useSections = useSections;
|
|
1923
|
+
exports.useSubmitBarnsportInterest = useSubmitBarnsportInterest;
|
|
1437
1924
|
exports.useUpdateFormSubmission = useUpdateFormSubmission;
|
|
1438
1925
|
exports.useUser = useUser;
|
|
1439
1926
|
exports.userHasAllPermissions = userHasAllPermissions;
|