@axcode/axcloud-sdk 0.2.0-dev.1e6c3d5 → 0.2.0-dev.4fb9e07
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 -0
- package/dist/barnsport.d.mts +39 -0
- package/dist/barnsport.d.ts +39 -0
- package/dist/barnsport.js +73 -0
- package/dist/barnsport.js.map +1 -0
- package/dist/barnsport.mjs +4 -0
- package/dist/barnsport.mjs.map +1 -0
- package/dist/chunk-2IVJTMRB.js +519 -0
- package/dist/chunk-2IVJTMRB.js.map +1 -0
- package/dist/chunk-7IPCZJ5Q.mjs +273 -0
- package/dist/chunk-7IPCZJ5Q.mjs.map +1 -0
- package/dist/chunk-7K5N3DQ4.js +231 -0
- package/dist/chunk-7K5N3DQ4.js.map +1 -0
- package/dist/chunk-CACQMQCJ.mjs +506 -0
- package/dist/chunk-CACQMQCJ.mjs.map +1 -0
- package/dist/chunk-PMMCOWL3.mjs +223 -0
- package/dist/chunk-PMMCOWL3.mjs.map +1 -0
- package/dist/chunk-ZOQAXLCZ.js +290 -0
- package/dist/chunk-ZOQAXLCZ.js.map +1 -0
- package/dist/client-FOpKwe3e.d.mts +75 -0
- package/dist/client-FOpKwe3e.d.ts +75 -0
- package/dist/index.d.mts +41 -819
- package/dist/index.d.ts +41 -819
- package/dist/index.js +130 -889
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -839
- package/dist/index.mjs.map +1 -1
- package/dist/public.d.mts +27 -0
- package/dist/public.d.ts +27 -0
- package/dist/public.js +131 -0
- package/dist/public.js.map +1 -0
- package/dist/public.mjs +99 -0
- package/dist/public.mjs.map +1 -0
- package/dist/useBarnsport-DHyNF9GM.d.mts +639 -0
- package/dist/useBarnsport-DHyNF9GM.d.ts +639 -0
- package/dist/useContent-1WbKvPY4.d.mts +508 -0
- package/dist/useContent-Cl7dvERE.d.ts +508 -0
- package/package.json +15 -5
package/dist/index.mjs
CHANGED
|
@@ -1,426 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useContent, useAnalyticsRuntime } from './chunk-CACQMQCJ.mjs';
|
|
2
|
+
export { createContentSlotReader, fetchAnalyticsPublicConfig, getContentSlotMap, isAllowedAnalyticsEvent, isLocalAnalyticsHostname, sanitizeAnalyticsEventData, sanitizeAnalyticsPath, useAnalytics, useAnalyticsRuntime, useContent, useContentItem, usePageContent } from './chunk-CACQMQCJ.mjs';
|
|
3
|
+
export { useBarnsportActivities, useBarnsportActivity, useBarnsportMunicipalities, useBarnsportSitemap, useBarnsportSport, useBarnsportSports, useSubmitBarnsportInterest } from './chunk-7IPCZJ5Q.mjs';
|
|
4
|
+
import { useAxCloudContext, isAxCloudError, AxCloudClient, AxCloudContext } from './chunk-PMMCOWL3.mjs';
|
|
5
|
+
export { AxCloudClient, AxCloudError, createClient, getClient, isAxCloudError, useAxCloudContext } from './chunk-PMMCOWL3.mjs';
|
|
6
|
+
import { useState, useMemo, useCallback, useLayoutEffect, useRef } from 'react';
|
|
2
7
|
import { Auth0Provider, useAuth0 } from '@auth0/auth0-react';
|
|
3
8
|
import { QueryClientProvider, useQuery, useQueryClient, useMutation, QueryClient } from '@tanstack/react-query';
|
|
4
9
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
10
|
|
|
6
|
-
// src/core/errors.ts
|
|
7
|
-
var AxCloudError = class _AxCloudError extends Error {
|
|
8
|
-
constructor(message, code, status, details) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.name = "AxCloudError";
|
|
11
|
-
this.code = code;
|
|
12
|
-
this.status = status;
|
|
13
|
-
this.details = details;
|
|
14
|
-
const ErrorWithCapture = Error;
|
|
15
|
-
if (ErrorWithCapture.captureStackTrace) {
|
|
16
|
-
ErrorWithCapture.captureStackTrace(this, _AxCloudError);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
static fromResponse(status, body) {
|
|
20
|
-
const details = typeof body === "object" ? body : void 0;
|
|
21
|
-
const message = (typeof details?.message === "string" ? details.message : void 0) || (typeof details?.error === "string" ? details.error : void 0);
|
|
22
|
-
switch (status) {
|
|
23
|
-
case 401:
|
|
24
|
-
return new _AxCloudError(
|
|
25
|
-
message || "Authentication required",
|
|
26
|
-
"UNAUTHORIZED",
|
|
27
|
-
status,
|
|
28
|
-
details
|
|
29
|
-
);
|
|
30
|
-
case 403:
|
|
31
|
-
return new _AxCloudError(message || "Access denied", "FORBIDDEN", status, details);
|
|
32
|
-
case 404:
|
|
33
|
-
return new _AxCloudError(message || "Resource not found", "NOT_FOUND", status, details);
|
|
34
|
-
case 422:
|
|
35
|
-
return new _AxCloudError(
|
|
36
|
-
message || "Validation failed",
|
|
37
|
-
"VALIDATION_ERROR",
|
|
38
|
-
status,
|
|
39
|
-
details
|
|
40
|
-
);
|
|
41
|
-
default:
|
|
42
|
-
if (status >= 500) {
|
|
43
|
-
return new _AxCloudError(message || "Server error", "SERVER_ERROR", status, details);
|
|
44
|
-
}
|
|
45
|
-
return new _AxCloudError(message || "An error occurred", "UNKNOWN_ERROR", status, details);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
static networkError(originalError) {
|
|
49
|
-
const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
50
|
-
const message = isDev && originalError?.message ? originalError.message : "Network request failed";
|
|
51
|
-
return new _AxCloudError(
|
|
52
|
-
message,
|
|
53
|
-
"NETWORK_ERROR",
|
|
54
|
-
0,
|
|
55
|
-
isDev ? { originalError: originalError?.message } : void 0
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
static timeoutError(timeoutMs) {
|
|
59
|
-
return new _AxCloudError(`Request timed out after ${timeoutMs}ms`, "TIMEOUT_ERROR", 0, {
|
|
60
|
-
timeout: timeoutMs
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
function isAxCloudError(error) {
|
|
65
|
-
return error instanceof AxCloudError;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// src/core/client.ts
|
|
69
|
-
var AxCloudClient = class {
|
|
70
|
-
constructor(config) {
|
|
71
|
-
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
72
|
-
this.getAccessToken = config.getAccessToken;
|
|
73
|
-
this.apiKey = config.apiKey;
|
|
74
|
-
this.defaultTimeout = config.timeout ?? 3e4;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Update the access token getter (used when auth state changes)
|
|
78
|
-
*/
|
|
79
|
-
setAccessTokenGetter(getter) {
|
|
80
|
-
this.getAccessToken = getter;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Build URL with query parameters
|
|
84
|
-
*/
|
|
85
|
-
buildUrl(path, params) {
|
|
86
|
-
const url = new URL(`${this.baseUrl}${path}`);
|
|
87
|
-
if (params) {
|
|
88
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
89
|
-
if (value !== void 0) {
|
|
90
|
-
url.searchParams.append(key, String(value));
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return url.toString();
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* API key should only be sent to public endpoints.
|
|
98
|
-
* This avoids leaking public keys to authenticated/internal routes.
|
|
99
|
-
*/
|
|
100
|
-
shouldAttachApiKey(path) {
|
|
101
|
-
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
102
|
-
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/");
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Make an authenticated request
|
|
106
|
-
*/
|
|
107
|
-
async request(path, options = {}) {
|
|
108
|
-
const { body, params, headers: customHeaders, timeout, ...restOptions } = options;
|
|
109
|
-
const headers = {
|
|
110
|
-
"Content-Type": "application/json"
|
|
111
|
-
};
|
|
112
|
-
if (customHeaders) {
|
|
113
|
-
const customHeadersRecord = customHeaders;
|
|
114
|
-
Object.assign(headers, customHeadersRecord);
|
|
115
|
-
}
|
|
116
|
-
if (this.apiKey && this.shouldAttachApiKey(path)) {
|
|
117
|
-
headers["x-api-key"] = this.apiKey;
|
|
118
|
-
}
|
|
119
|
-
if (this.getAccessToken) {
|
|
120
|
-
try {
|
|
121
|
-
const token = await this.getAccessToken();
|
|
122
|
-
if (token) {
|
|
123
|
-
headers["Authorization"] = `Bearer ${token}`;
|
|
124
|
-
}
|
|
125
|
-
} catch (error) {
|
|
126
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
|
|
127
|
-
console.warn(
|
|
128
|
-
"[AxCloud SDK] Failed to fetch access token:",
|
|
129
|
-
error instanceof Error ? error.message : error
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const url = this.buildUrl(path, params);
|
|
135
|
-
const controller = new AbortController();
|
|
136
|
-
const requestTimeout = timeout ?? this.defaultTimeout;
|
|
137
|
-
const timeoutId = setTimeout(() => controller.abort(), requestTimeout);
|
|
138
|
-
try {
|
|
139
|
-
const response = await fetch(url, {
|
|
140
|
-
...restOptions,
|
|
141
|
-
headers,
|
|
142
|
-
body: body ? JSON.stringify(body) : void 0,
|
|
143
|
-
signal: controller.signal
|
|
144
|
-
});
|
|
145
|
-
const contentType = response.headers.get("content-type");
|
|
146
|
-
const isJson = contentType?.includes("application/json");
|
|
147
|
-
if (!response.ok) {
|
|
148
|
-
const errorBody = isJson ? await response.json().catch(() => null) : null;
|
|
149
|
-
throw AxCloudError.fromResponse(response.status, errorBody);
|
|
150
|
-
}
|
|
151
|
-
if (response.status === 204) {
|
|
152
|
-
return {};
|
|
153
|
-
}
|
|
154
|
-
return isJson ? await response.json() : {};
|
|
155
|
-
} catch (error) {
|
|
156
|
-
if (error instanceof AxCloudError) {
|
|
157
|
-
throw error;
|
|
158
|
-
}
|
|
159
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
160
|
-
throw AxCloudError.timeoutError(requestTimeout);
|
|
161
|
-
}
|
|
162
|
-
throw AxCloudError.networkError(error instanceof Error ? error : void 0);
|
|
163
|
-
} finally {
|
|
164
|
-
clearTimeout(timeoutId);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* GET request
|
|
169
|
-
*/
|
|
170
|
-
get(path, params) {
|
|
171
|
-
return this.request(path, { method: "GET", params });
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* POST request
|
|
175
|
-
*/
|
|
176
|
-
post(path, body) {
|
|
177
|
-
return this.request(path, { method: "POST", body });
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* PUT request
|
|
181
|
-
*/
|
|
182
|
-
put(path, body) {
|
|
183
|
-
return this.request(path, { method: "PUT", body });
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* PATCH request
|
|
187
|
-
*/
|
|
188
|
-
patch(path, body) {
|
|
189
|
-
return this.request(path, { method: "PATCH", body });
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* DELETE request
|
|
193
|
-
*/
|
|
194
|
-
delete(path) {
|
|
195
|
-
return this.request(path, { method: "DELETE" });
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
var clientRegistry = /* @__PURE__ */ new WeakMap();
|
|
199
|
-
function createClient(config, key) {
|
|
200
|
-
const client = new AxCloudClient(config);
|
|
201
|
-
if (key) {
|
|
202
|
-
clientRegistry.set(key, client);
|
|
203
|
-
}
|
|
204
|
-
return client;
|
|
205
|
-
}
|
|
206
|
-
function getClient(key) {
|
|
207
|
-
if (key) {
|
|
208
|
-
const client = clientRegistry.get(key);
|
|
209
|
-
if (client) {
|
|
210
|
-
return client;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
throw new Error("AxCloud client not found. Make sure AxCloudProvider is mounted and use useAxCloudContext() to get the client.");
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// src/core/analytics.ts
|
|
217
|
-
var EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]{1,63}$/;
|
|
218
|
-
var PROPERTY_KEY_PATTERN = /^[a-z][a-z0-9_]{0,47}$/;
|
|
219
|
-
var SENSITIVE_PROPERTY_PATTERN = /(^|_)(auth0|email|name|password|query|search|secret|token|trace|user|userid)($|_)/;
|
|
220
|
-
var EMAIL_VALUE_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
221
|
-
var OPAQUE_SEGMENT_PATTERNS = [
|
|
222
|
-
/^[0-9a-f]{8}-[0-9a-f-]{27,}$/i,
|
|
223
|
-
/^(org|user|section|document|content|poll|invitation|invite|trace|chan)[_-][a-z0-9_-]+$/i,
|
|
224
|
-
/^[a-f0-9]{20,}$/i,
|
|
225
|
-
/^[a-z0-9_-]{32,}$/i
|
|
226
|
-
];
|
|
227
|
-
var scriptLoads = /* @__PURE__ */ new Map();
|
|
228
|
-
function isLocalAnalyticsHostname(hostname) {
|
|
229
|
-
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
230
|
-
}
|
|
231
|
-
function sanitizeAnalyticsPath(pathname, customNormalizer) {
|
|
232
|
-
const rawPath = pathname.split(/[?#]/, 1)[0] || "/";
|
|
233
|
-
const normalizedInput = rawPath.startsWith("/") ? rawPath : `/${rawPath}`;
|
|
234
|
-
const custom = customNormalizer?.(normalizedInput);
|
|
235
|
-
if (custom === null) return null;
|
|
236
|
-
const path = custom ?? normalizedInput;
|
|
237
|
-
const cleanPath = path.split(/[?#]/, 1)[0] || "/";
|
|
238
|
-
const segments = cleanPath.split("/").map((segment) => {
|
|
239
|
-
if (!segment) return segment;
|
|
240
|
-
let decoded = segment;
|
|
241
|
-
try {
|
|
242
|
-
decoded = decodeURIComponent(segment);
|
|
243
|
-
} catch {
|
|
244
|
-
}
|
|
245
|
-
return OPAQUE_SEGMENT_PATTERNS.some((pattern) => pattern.test(decoded)) ? ":id" : segment;
|
|
246
|
-
});
|
|
247
|
-
return segments.join("/") || "/";
|
|
248
|
-
}
|
|
249
|
-
function sanitizeAnalyticsEventData(data) {
|
|
250
|
-
if (!data) return void 0;
|
|
251
|
-
const sanitized = {};
|
|
252
|
-
for (const [rawKey, rawValue] of Object.entries(data).slice(0, 20)) {
|
|
253
|
-
const key = rawKey.trim().toLowerCase();
|
|
254
|
-
if (!PROPERTY_KEY_PATTERN.test(key) || SENSITIVE_PROPERTY_PATTERN.test(key)) continue;
|
|
255
|
-
if (typeof rawValue === "string") {
|
|
256
|
-
const value = rawValue.trim();
|
|
257
|
-
if (!value || value.length > 100 || EMAIL_VALUE_PATTERN.test(value)) continue;
|
|
258
|
-
sanitized[key] = value;
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
if (typeof rawValue === "number" && Number.isFinite(rawValue)) {
|
|
262
|
-
sanitized[key] = rawValue;
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
if (typeof rawValue === "boolean") sanitized[key] = rawValue;
|
|
266
|
-
}
|
|
267
|
-
return Object.keys(sanitized).length > 0 ? sanitized : void 0;
|
|
268
|
-
}
|
|
269
|
-
function isAllowedAnalyticsEvent(eventName, allowedEvents) {
|
|
270
|
-
return EVENT_NAME_PATTERN.test(eventName) && Boolean(allowedEvents?.includes(eventName));
|
|
271
|
-
}
|
|
272
|
-
async function fetchAnalyticsPublicConfig(input) {
|
|
273
|
-
const baseUrl = input.apiUrl.replace(/\/$/, "");
|
|
274
|
-
const url = new URL(`${baseUrl}/analytics/public/config`);
|
|
275
|
-
url.searchParams.set("orgId", input.orgId);
|
|
276
|
-
url.searchParams.set("siteKey", input.siteKey);
|
|
277
|
-
url.searchParams.set("stage", input.stage);
|
|
278
|
-
url.searchParams.set("hostname", input.hostname);
|
|
279
|
-
const response = await fetch(url, {
|
|
280
|
-
method: "GET",
|
|
281
|
-
headers: { Accept: "application/json" },
|
|
282
|
-
signal: input.signal
|
|
283
|
-
});
|
|
284
|
-
if (!response.ok) throw new Error(`Analytics configuration returned ${response.status}`);
|
|
285
|
-
return response.json();
|
|
286
|
-
}
|
|
287
|
-
function loadAnalyticsScript(config, doc = document) {
|
|
288
|
-
if (!config.enabled || !config.websiteId || !config.scriptUrl) {
|
|
289
|
-
return Promise.reject(new Error("Analytics tracker configuration is incomplete"));
|
|
290
|
-
}
|
|
291
|
-
const key = `${config.scriptUrl}|${config.websiteId}`;
|
|
292
|
-
const existingPromise = scriptLoads.get(key);
|
|
293
|
-
if (existingPromise) return existingPromise;
|
|
294
|
-
const existing = doc.querySelector(
|
|
295
|
-
`script[data-axcloud-analytics-site="${config.websiteId}"]`
|
|
296
|
-
);
|
|
297
|
-
if (existing && doc.defaultView?.umami) {
|
|
298
|
-
return Promise.resolve();
|
|
299
|
-
}
|
|
300
|
-
const promise = new Promise((resolve, reject) => {
|
|
301
|
-
const script = existing || doc.createElement("script");
|
|
302
|
-
const onLoad = () => resolve();
|
|
303
|
-
const onError = () => reject(new Error("Analytics tracker failed to load"));
|
|
304
|
-
script.addEventListener("load", onLoad, { once: true });
|
|
305
|
-
script.addEventListener("error", onError, { once: true });
|
|
306
|
-
if (!existing) {
|
|
307
|
-
script.src = config.scriptUrl;
|
|
308
|
-
script.defer = true;
|
|
309
|
-
script.dataset.websiteId = config.websiteId;
|
|
310
|
-
script.dataset.axcloudAnalyticsSite = config.websiteId;
|
|
311
|
-
script.dataset.autoTrack = String(config.autoTrack === true);
|
|
312
|
-
if (config.hostUrl) script.dataset.hostUrl = config.hostUrl;
|
|
313
|
-
if (config.domains?.length) script.dataset.domains = config.domains.join(",");
|
|
314
|
-
if (config.respectDoNotTrack !== false) script.dataset.doNotTrack = "true";
|
|
315
|
-
if (config.excludeSearch !== false) script.dataset.excludeSearch = "true";
|
|
316
|
-
if (config.excludeHash !== false) script.dataset.excludeHash = "true";
|
|
317
|
-
doc.head.appendChild(script);
|
|
318
|
-
}
|
|
319
|
-
}).catch((error) => {
|
|
320
|
-
scriptLoads.delete(key);
|
|
321
|
-
throw error;
|
|
322
|
-
});
|
|
323
|
-
scriptLoads.set(key, promise);
|
|
324
|
-
return promise;
|
|
325
|
-
}
|
|
326
|
-
function sendAnalyticsPageView(pathname, options, targetWindow = window) {
|
|
327
|
-
const path = sanitizeAnalyticsPath(pathname, options.normalizePath);
|
|
328
|
-
const umami = targetWindow.umami;
|
|
329
|
-
if (!path || !umami) return false;
|
|
330
|
-
umami.track({ url: path, title: targetWindow.document.title });
|
|
331
|
-
return true;
|
|
332
|
-
}
|
|
333
|
-
function sendAnalyticsEvent(eventName, data, allowedEvents, targetWindow = window) {
|
|
334
|
-
const umami = targetWindow.umami;
|
|
335
|
-
if (!umami || !isAllowedAnalyticsEvent(eventName, allowedEvents)) return false;
|
|
336
|
-
umami.track(eventName, sanitizeAnalyticsEventData(data));
|
|
337
|
-
return true;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// src/core/contentSlots.ts
|
|
341
|
-
var SLOT_ATTRIBUTE_KEYS = ["slot", "field", "key", "name"];
|
|
342
|
-
function getContentSlotMap(content) {
|
|
343
|
-
const fields = isRecord(content?.fields) ? { ...content?.fields } : {};
|
|
344
|
-
for (const block of content?.blocks || []) {
|
|
345
|
-
const slot = getBlockSlot(block);
|
|
346
|
-
if (!slot) continue;
|
|
347
|
-
if (!(slot in fields)) fields[slot] = blockToSlotValue(block);
|
|
348
|
-
}
|
|
349
|
-
return fields;
|
|
350
|
-
}
|
|
351
|
-
function createContentSlotReader(content) {
|
|
352
|
-
const fields = getContentSlotMap(content);
|
|
353
|
-
const value = (key, fallback) => {
|
|
354
|
-
return key in fields ? fields[key] : fallback;
|
|
355
|
-
};
|
|
356
|
-
const unsafeHtml = (key, fallback = "") => stringifySlotValue(value(key, fallback));
|
|
357
|
-
return {
|
|
358
|
-
fields,
|
|
359
|
-
value,
|
|
360
|
-
text: (key, fallback = "") => stringifySlotValue(value(key, fallback)),
|
|
361
|
-
html: unsafeHtml,
|
|
362
|
-
unsafeHtml,
|
|
363
|
-
list: (key, fallback = []) => slotValueToList(value(key, fallback)),
|
|
364
|
-
image: (key, fallback) => slotValueToImage(value(key, fallback))
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
function getBlockSlot(block) {
|
|
368
|
-
const attributes = block.attributes || {};
|
|
369
|
-
for (const key of SLOT_ATTRIBUTE_KEYS) {
|
|
370
|
-
const value = attributes[key];
|
|
371
|
-
if (typeof value === "string" && value.trim()) return value.trim();
|
|
372
|
-
}
|
|
373
|
-
return void 0;
|
|
374
|
-
}
|
|
375
|
-
function blockToSlotValue(block) {
|
|
376
|
-
if (block.attributes && "value" in block.attributes) {
|
|
377
|
-
return block.attributes.value;
|
|
378
|
-
}
|
|
379
|
-
if (block.type === "list") {
|
|
380
|
-
return Array.isArray(block.items) ? block.items : [];
|
|
381
|
-
}
|
|
382
|
-
if (block.type === "image" && block.url) {
|
|
383
|
-
return {
|
|
384
|
-
url: block.url,
|
|
385
|
-
alt: block.alt,
|
|
386
|
-
caption: block.caption
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
return block.content ?? "";
|
|
390
|
-
}
|
|
391
|
-
function stringifySlotValue(value) {
|
|
392
|
-
if (value === void 0 || value === null) return "";
|
|
393
|
-
if (typeof value === "string") return value;
|
|
394
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
395
|
-
if (Array.isArray(value)) return value.map((item) => stringifySlotValue(item)).filter(Boolean).join("\n");
|
|
396
|
-
return "";
|
|
397
|
-
}
|
|
398
|
-
function slotValueToList(value) {
|
|
399
|
-
if (Array.isArray(value)) {
|
|
400
|
-
return value.map((item) => stringifySlotValue(item)).filter(Boolean);
|
|
401
|
-
}
|
|
402
|
-
if (typeof value === "string") {
|
|
403
|
-
return value.split(/\r?\n/).map((item) => item.trim()).filter(Boolean);
|
|
404
|
-
}
|
|
405
|
-
return [];
|
|
406
|
-
}
|
|
407
|
-
function slotValueToImage(value) {
|
|
408
|
-
if (isRecord(value) && typeof value.url === "string") {
|
|
409
|
-
return {
|
|
410
|
-
url: value.url,
|
|
411
|
-
alt: typeof value.alt === "string" ? value.alt : void 0,
|
|
412
|
-
caption: typeof value.caption === "string" ? value.caption : void 0
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
if (typeof value === "string" && value) {
|
|
416
|
-
return { url: value };
|
|
417
|
-
}
|
|
418
|
-
return void 0;
|
|
419
|
-
}
|
|
420
|
-
function isRecord(value) {
|
|
421
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
11
|
// src/core/types.ts
|
|
425
12
|
function userHasPermission(user, permission) {
|
|
426
13
|
if (user.permissions && user.permissions.length > 0) {
|
|
@@ -626,135 +213,6 @@ async function castVote(votingApiUrl, params) {
|
|
|
626
213
|
await ensureOk(response);
|
|
627
214
|
return readJson(response);
|
|
628
215
|
}
|
|
629
|
-
var AxCloudContext = createContext(null);
|
|
630
|
-
function useAxCloudContext() {
|
|
631
|
-
const context = useContext(AxCloudContext);
|
|
632
|
-
if (!context) {
|
|
633
|
-
throw new Error("useAxCloudContext must be used within a AxCloudProvider");
|
|
634
|
-
}
|
|
635
|
-
return context;
|
|
636
|
-
}
|
|
637
|
-
var NAVIGATION_EVENT = "axcloud-sdk:navigation";
|
|
638
|
-
var historySubscriberCount = 0;
|
|
639
|
-
var originalPushState = null;
|
|
640
|
-
var originalReplaceState = null;
|
|
641
|
-
function subscribeToNavigation(callback) {
|
|
642
|
-
if (typeof window === "undefined") return () => void 0;
|
|
643
|
-
if (historySubscriberCount === 0) {
|
|
644
|
-
originalPushState = window.history.pushState.bind(window.history);
|
|
645
|
-
originalReplaceState = window.history.replaceState.bind(window.history);
|
|
646
|
-
window.history.pushState = ((...args) => {
|
|
647
|
-
originalPushState?.(...args);
|
|
648
|
-
window.dispatchEvent(new Event(NAVIGATION_EVENT));
|
|
649
|
-
});
|
|
650
|
-
window.history.replaceState = ((...args) => {
|
|
651
|
-
originalReplaceState?.(...args);
|
|
652
|
-
window.dispatchEvent(new Event(NAVIGATION_EVENT));
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
historySubscriberCount += 1;
|
|
656
|
-
window.addEventListener("popstate", callback);
|
|
657
|
-
window.addEventListener(NAVIGATION_EVENT, callback);
|
|
658
|
-
return () => {
|
|
659
|
-
window.removeEventListener("popstate", callback);
|
|
660
|
-
window.removeEventListener(NAVIGATION_EVENT, callback);
|
|
661
|
-
historySubscriberCount = Math.max(0, historySubscriberCount - 1);
|
|
662
|
-
if (historySubscriberCount === 0) {
|
|
663
|
-
if (originalPushState) window.history.pushState = originalPushState;
|
|
664
|
-
if (originalReplaceState) window.history.replaceState = originalReplaceState;
|
|
665
|
-
originalPushState = null;
|
|
666
|
-
originalReplaceState = null;
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
function doNotTrackEnabled(config) {
|
|
671
|
-
if (config.respectDoNotTrack === false || typeof navigator === "undefined") return false;
|
|
672
|
-
return navigator.doNotTrack === "1";
|
|
673
|
-
}
|
|
674
|
-
function useAnalyticsRuntime(config) {
|
|
675
|
-
const [enabled, setEnabled] = useState(false);
|
|
676
|
-
const [ready, setReady] = useState(false);
|
|
677
|
-
const publicConfigRef = useRef(null);
|
|
678
|
-
const optionsRef = useRef(config.analytics);
|
|
679
|
-
optionsRef.current = config.analytics;
|
|
680
|
-
const trackPageView = useCallback(
|
|
681
|
-
(pathname) => {
|
|
682
|
-
if (!ready || !optionsRef.current || typeof window === "undefined") return false;
|
|
683
|
-
return sendAnalyticsPageView(pathname || window.location.pathname, optionsRef.current);
|
|
684
|
-
},
|
|
685
|
-
[ready]
|
|
686
|
-
);
|
|
687
|
-
const track = useCallback(
|
|
688
|
-
(eventName, data) => {
|
|
689
|
-
if (!ready || typeof window === "undefined") return false;
|
|
690
|
-
return sendAnalyticsEvent(eventName, data, publicConfigRef.current?.allowedEvents);
|
|
691
|
-
},
|
|
692
|
-
[ready]
|
|
693
|
-
);
|
|
694
|
-
useEffect(() => {
|
|
695
|
-
const options = config.analytics;
|
|
696
|
-
setEnabled(false);
|
|
697
|
-
setReady(false);
|
|
698
|
-
publicConfigRef.current = null;
|
|
699
|
-
if (!options?.enabled || !options.siteKey || typeof window === "undefined") return void 0;
|
|
700
|
-
if (isLocalAnalyticsHostname(window.location.hostname) && !options.trackLocalhost)
|
|
701
|
-
return void 0;
|
|
702
|
-
const controller = new AbortController();
|
|
703
|
-
let cancelled = false;
|
|
704
|
-
let unsubscribe = () => void 0;
|
|
705
|
-
const initialize = async () => {
|
|
706
|
-
try {
|
|
707
|
-
const publicConfig = await fetchAnalyticsPublicConfig({
|
|
708
|
-
apiUrl: config.apiUrl,
|
|
709
|
-
orgId: config.orgId,
|
|
710
|
-
siteKey: options.siteKey,
|
|
711
|
-
stage: config.stage,
|
|
712
|
-
hostname: window.location.hostname,
|
|
713
|
-
signal: controller.signal
|
|
714
|
-
});
|
|
715
|
-
if (cancelled || !publicConfig.enabled || doNotTrackEnabled(publicConfig)) return;
|
|
716
|
-
publicConfigRef.current = publicConfig;
|
|
717
|
-
setEnabled(true);
|
|
718
|
-
await loadAnalyticsScript(publicConfig);
|
|
719
|
-
if (cancelled) return;
|
|
720
|
-
setReady(true);
|
|
721
|
-
if (!publicConfig.autoTrack) {
|
|
722
|
-
const trackCurrentPage = () => {
|
|
723
|
-
sendAnalyticsPageView(window.location.pathname, options);
|
|
724
|
-
};
|
|
725
|
-
trackCurrentPage();
|
|
726
|
-
unsubscribe = subscribeToNavigation(trackCurrentPage);
|
|
727
|
-
}
|
|
728
|
-
} catch (error) {
|
|
729
|
-
if (!cancelled && !(error instanceof Error && error.name === "AbortError")) {
|
|
730
|
-
setEnabled(false);
|
|
731
|
-
setReady(false);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
void initialize();
|
|
736
|
-
return () => {
|
|
737
|
-
cancelled = true;
|
|
738
|
-
controller.abort();
|
|
739
|
-
unsubscribe();
|
|
740
|
-
};
|
|
741
|
-
}, [
|
|
742
|
-
config.analytics?.enabled,
|
|
743
|
-
config.analytics?.siteKey,
|
|
744
|
-
config.analytics?.trackLocalhost,
|
|
745
|
-
config.analytics?.normalizePath,
|
|
746
|
-
config.apiUrl,
|
|
747
|
-
config.orgId,
|
|
748
|
-
config.stage
|
|
749
|
-
]);
|
|
750
|
-
return useMemo(
|
|
751
|
-
() => ({ enabled, ready, track, trackPageView }),
|
|
752
|
-
[enabled, ready, track, trackPageView]
|
|
753
|
-
);
|
|
754
|
-
}
|
|
755
|
-
function useAnalytics() {
|
|
756
|
-
return useAxCloudContext().analytics;
|
|
757
|
-
}
|
|
758
216
|
|
|
759
217
|
// src/react/auth/auth0Invitation.ts
|
|
760
218
|
var AUTH0_INVITATION_PATTERN = /^[A-Za-z0-9_-]{1,2048}$/;
|
|
@@ -1341,176 +799,6 @@ function useOrg() {
|
|
|
1341
799
|
};
|
|
1342
800
|
}
|
|
1343
801
|
|
|
1344
|
-
// src/react/contentQueryPolicy.ts
|
|
1345
|
-
var CONTENT_STALE_TIME_MS = 6e4;
|
|
1346
|
-
function shouldRetryContentRequest(failureCount, error) {
|
|
1347
|
-
if (isAxCloudError(error) && error.status >= 400 && error.status < 500) {
|
|
1348
|
-
return false;
|
|
1349
|
-
}
|
|
1350
|
-
return failureCount < 2;
|
|
1351
|
-
}
|
|
1352
|
-
function normalizeContentCollectionType(contentType) {
|
|
1353
|
-
switch (contentType.toLowerCase()) {
|
|
1354
|
-
case "news":
|
|
1355
|
-
return "news";
|
|
1356
|
-
case "page":
|
|
1357
|
-
case "pages":
|
|
1358
|
-
return "pages";
|
|
1359
|
-
case "event":
|
|
1360
|
-
case "events":
|
|
1361
|
-
return "events";
|
|
1362
|
-
default:
|
|
1363
|
-
throw new Error(`Unsupported AxCloud content collection type: ${contentType}`);
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
function normalizeContentDetailType(contentType) {
|
|
1367
|
-
switch (contentType.toLowerCase()) {
|
|
1368
|
-
case "news":
|
|
1369
|
-
return "news";
|
|
1370
|
-
case "page":
|
|
1371
|
-
case "pages":
|
|
1372
|
-
return "page";
|
|
1373
|
-
case "event":
|
|
1374
|
-
case "events":
|
|
1375
|
-
return "event";
|
|
1376
|
-
default:
|
|
1377
|
-
throw new Error(`Unsupported AxCloud content detail type: ${contentType}`);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
function getContentAccessState(context, publicOnly) {
|
|
1381
|
-
if (publicOnly) {
|
|
1382
|
-
return { mode: "public", enabled: true, subject: "anonymous" };
|
|
1383
|
-
}
|
|
1384
|
-
const isLoading = context.isAuthLoading ?? false;
|
|
1385
|
-
if (isLoading) {
|
|
1386
|
-
return { mode: "pending", enabled: false, subject: "auth-loading" };
|
|
1387
|
-
}
|
|
1388
|
-
const hasExplicitAuthState = typeof context.isAuthenticated === "boolean";
|
|
1389
|
-
const isAuthenticated = context.isAuthenticated ?? !context.isPublicMode;
|
|
1390
|
-
if (!isAuthenticated) {
|
|
1391
|
-
return { mode: "public", enabled: true, subject: "anonymous" };
|
|
1392
|
-
}
|
|
1393
|
-
if (hasExplicitAuthState && !context.authSubject) {
|
|
1394
|
-
return { mode: "pending", enabled: false, subject: "auth-subject-pending" };
|
|
1395
|
-
}
|
|
1396
|
-
const subject = context.authSubject || "legacy-authenticated-session";
|
|
1397
|
-
return { mode: "member", enabled: Boolean(subject), subject };
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
// src/react/hooks/useContent.ts
|
|
1401
|
-
function useContent(contentType, options = {}) {
|
|
1402
|
-
const context = useAxCloudContext();
|
|
1403
|
-
const { client, config, orgId, stage } = context;
|
|
1404
|
-
const collectionType = normalizeContentCollectionType(contentType);
|
|
1405
|
-
const {
|
|
1406
|
-
publicOnly = false,
|
|
1407
|
-
page = 1,
|
|
1408
|
-
pageSize = 20,
|
|
1409
|
-
search,
|
|
1410
|
-
sortBy = collectionType === "news" ? "publishedAt" : "createdAt",
|
|
1411
|
-
sortOrder = "desc",
|
|
1412
|
-
tags,
|
|
1413
|
-
lang
|
|
1414
|
-
} = options;
|
|
1415
|
-
const access = getContentAccessState(context, publicOnly);
|
|
1416
|
-
const deliveryScope = access.mode === "member" ? "members" : "public";
|
|
1417
|
-
const params = {
|
|
1418
|
-
page,
|
|
1419
|
-
pageSize,
|
|
1420
|
-
search,
|
|
1421
|
-
sort: sortBy,
|
|
1422
|
-
order: sortOrder,
|
|
1423
|
-
tags: tags?.length ? tags.join(",") : void 0,
|
|
1424
|
-
lang
|
|
1425
|
-
};
|
|
1426
|
-
const query = useQuery({
|
|
1427
|
-
queryKey: [
|
|
1428
|
-
"axcloud",
|
|
1429
|
-
"content",
|
|
1430
|
-
"collection",
|
|
1431
|
-
stage,
|
|
1432
|
-
config.apiUrl,
|
|
1433
|
-
orgId,
|
|
1434
|
-
access.mode,
|
|
1435
|
-
access.subject,
|
|
1436
|
-
collectionType,
|
|
1437
|
-
params
|
|
1438
|
-
],
|
|
1439
|
-
queryFn: () => client.get(
|
|
1440
|
-
`/content/${deliveryScope}/${orgId}/${collectionType}`,
|
|
1441
|
-
params
|
|
1442
|
-
),
|
|
1443
|
-
enabled: access.enabled,
|
|
1444
|
-
staleTime: CONTENT_STALE_TIME_MS,
|
|
1445
|
-
refetchOnWindowFocus: true,
|
|
1446
|
-
retry: shouldRetryContentRequest
|
|
1447
|
-
});
|
|
1448
|
-
const items = query.data?.items ?? [];
|
|
1449
|
-
return {
|
|
1450
|
-
data: items,
|
|
1451
|
-
count: query.data?.count ?? items.length,
|
|
1452
|
-
total: query.data?.total ?? items.length,
|
|
1453
|
-
page: query.data?.page ?? page,
|
|
1454
|
-
pageSize: query.data?.pageSize ?? pageSize,
|
|
1455
|
-
hasMore: query.data?.hasMore ?? false,
|
|
1456
|
-
nextCursor: query.data?.nextCursor,
|
|
1457
|
-
isLoading: access.mode === "pending" || query.isLoading,
|
|
1458
|
-
isFetching: query.isFetching,
|
|
1459
|
-
isError: query.isError,
|
|
1460
|
-
error: query.error,
|
|
1461
|
-
refetch: query.refetch
|
|
1462
|
-
};
|
|
1463
|
-
}
|
|
1464
|
-
function useContentItem(contentType, idOrSlug, options = {}) {
|
|
1465
|
-
const context = useAxCloudContext();
|
|
1466
|
-
const { client, config, orgId, stage } = context;
|
|
1467
|
-
const detailType = normalizeContentDetailType(contentType);
|
|
1468
|
-
const { publicOnly = false, lang } = options;
|
|
1469
|
-
const access = getContentAccessState(context, publicOnly);
|
|
1470
|
-
const deliveryScope = access.mode === "member" ? "members" : "public";
|
|
1471
|
-
const query = useQuery({
|
|
1472
|
-
queryKey: [
|
|
1473
|
-
"axcloud",
|
|
1474
|
-
"content",
|
|
1475
|
-
"item",
|
|
1476
|
-
stage,
|
|
1477
|
-
config.apiUrl,
|
|
1478
|
-
orgId,
|
|
1479
|
-
access.mode,
|
|
1480
|
-
access.subject,
|
|
1481
|
-
detailType,
|
|
1482
|
-
idOrSlug,
|
|
1483
|
-
lang
|
|
1484
|
-
],
|
|
1485
|
-
queryFn: () => {
|
|
1486
|
-
const encodedIdOrSlug = encodeURIComponent(idOrSlug);
|
|
1487
|
-
const endpoint = `/content/${deliveryScope}/${orgId}/items/${detailType}/${encodedIdOrSlug}`;
|
|
1488
|
-
return lang ? client.get(endpoint, { lang }) : client.get(endpoint);
|
|
1489
|
-
},
|
|
1490
|
-
enabled: access.enabled && Boolean(idOrSlug),
|
|
1491
|
-
staleTime: CONTENT_STALE_TIME_MS,
|
|
1492
|
-
refetchOnWindowFocus: true,
|
|
1493
|
-
retry: shouldRetryContentRequest
|
|
1494
|
-
});
|
|
1495
|
-
return {
|
|
1496
|
-
data: query.data ?? null,
|
|
1497
|
-
isLoading: access.mode === "pending" || query.isLoading,
|
|
1498
|
-
isFetching: query.isFetching,
|
|
1499
|
-
isError: query.isError,
|
|
1500
|
-
error: query.error,
|
|
1501
|
-
refetch: query.refetch
|
|
1502
|
-
};
|
|
1503
|
-
}
|
|
1504
|
-
function usePageContent(slug, options = {}) {
|
|
1505
|
-
const state = useContentItem("page", slug, options);
|
|
1506
|
-
const reader = useMemo(() => createContentSlotReader(state.data), [state.data]);
|
|
1507
|
-
return {
|
|
1508
|
-
...state,
|
|
1509
|
-
page: state.data,
|
|
1510
|
-
...reader
|
|
1511
|
-
};
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
802
|
// src/react/hooks/useNews.ts
|
|
1515
803
|
function useNews(options = {}) {
|
|
1516
804
|
return useContent("news", options);
|
|
@@ -1980,126 +1268,6 @@ function useMemberDocumentDownload(documentId) {
|
|
|
1980
1268
|
refetch: query.refetch
|
|
1981
1269
|
};
|
|
1982
1270
|
}
|
|
1983
|
-
function useBarnsportMunicipalities() {
|
|
1984
|
-
const { client, orgId } = useAxCloudContext();
|
|
1985
|
-
const query = useQuery({
|
|
1986
|
-
queryKey: ["axcloud", "barnsport", "municipalities", orgId],
|
|
1987
|
-
queryFn: () => client.get(
|
|
1988
|
-
`/barnsport/public/${orgId}/municipalities`
|
|
1989
|
-
),
|
|
1990
|
-
staleTime: 1e3 * 60 * 30
|
|
1991
|
-
});
|
|
1992
|
-
return {
|
|
1993
|
-
municipalities: query.data?.items ?? [],
|
|
1994
|
-
count: query.data?.count ?? 0,
|
|
1995
|
-
isLoading: query.isLoading,
|
|
1996
|
-
isError: query.isError,
|
|
1997
|
-
error: query.error,
|
|
1998
|
-
refetch: query.refetch
|
|
1999
|
-
};
|
|
2000
|
-
}
|
|
2001
|
-
function useBarnsportSports() {
|
|
2002
|
-
const { client, orgId } = useAxCloudContext();
|
|
2003
|
-
const query = useQuery({
|
|
2004
|
-
queryKey: ["axcloud", "barnsport", "sports", orgId],
|
|
2005
|
-
queryFn: () => client.get(
|
|
2006
|
-
`/barnsport/public/${orgId}/sports`
|
|
2007
|
-
),
|
|
2008
|
-
staleTime: 1e3 * 60 * 30
|
|
2009
|
-
});
|
|
2010
|
-
return {
|
|
2011
|
-
sports: query.data?.items ?? [],
|
|
2012
|
-
count: query.data?.count ?? 0,
|
|
2013
|
-
isLoading: query.isLoading,
|
|
2014
|
-
isError: query.isError,
|
|
2015
|
-
error: query.error,
|
|
2016
|
-
refetch: query.refetch
|
|
2017
|
-
};
|
|
2018
|
-
}
|
|
2019
|
-
function useBarnsportSport(slug) {
|
|
2020
|
-
const { client, orgId } = useAxCloudContext();
|
|
2021
|
-
const query = useQuery({
|
|
2022
|
-
queryKey: ["axcloud", "barnsport", "sport", orgId, slug],
|
|
2023
|
-
queryFn: () => client.get(
|
|
2024
|
-
`/barnsport/public/${orgId}/sports/${slug || ""}`
|
|
2025
|
-
),
|
|
2026
|
-
enabled: Boolean(slug),
|
|
2027
|
-
staleTime: 1e3 * 60 * 15
|
|
2028
|
-
});
|
|
2029
|
-
return {
|
|
2030
|
-
sport: query.data?.sport ?? null,
|
|
2031
|
-
isLoading: query.isLoading,
|
|
2032
|
-
isError: query.isError,
|
|
2033
|
-
error: query.error,
|
|
2034
|
-
refetch: query.refetch
|
|
2035
|
-
};
|
|
2036
|
-
}
|
|
2037
|
-
function useBarnsportActivities(filters = {}) {
|
|
2038
|
-
const { client, orgId } = useAxCloudContext();
|
|
2039
|
-
const params = { ...filters };
|
|
2040
|
-
const query = useQuery({
|
|
2041
|
-
queryKey: ["axcloud", "barnsport", "activities", orgId, filters],
|
|
2042
|
-
queryFn: () => client.get(
|
|
2043
|
-
`/barnsport/public/${orgId}/activities`,
|
|
2044
|
-
params
|
|
2045
|
-
),
|
|
2046
|
-
staleTime: 1e3 * 60 * 5
|
|
2047
|
-
});
|
|
2048
|
-
return {
|
|
2049
|
-
activities: query.data?.items ?? [],
|
|
2050
|
-
count: query.data?.count ?? 0,
|
|
2051
|
-
nextCursor: query.data?.nextCursor ?? null,
|
|
2052
|
-
isLoading: query.isLoading,
|
|
2053
|
-
isError: query.isError,
|
|
2054
|
-
error: query.error,
|
|
2055
|
-
refetch: query.refetch
|
|
2056
|
-
};
|
|
2057
|
-
}
|
|
2058
|
-
function useBarnsportActivity(slug) {
|
|
2059
|
-
const { client, orgId } = useAxCloudContext();
|
|
2060
|
-
const query = useQuery({
|
|
2061
|
-
queryKey: ["axcloud", "barnsport", "activity", orgId, slug],
|
|
2062
|
-
queryFn: () => client.get(
|
|
2063
|
-
`/barnsport/public/${orgId}/activities/${slug || ""}`
|
|
2064
|
-
),
|
|
2065
|
-
enabled: Boolean(slug),
|
|
2066
|
-
staleTime: 1e3 * 60 * 5
|
|
2067
|
-
});
|
|
2068
|
-
return {
|
|
2069
|
-
activity: query.data?.activity ?? null,
|
|
2070
|
-
isLoading: query.isLoading,
|
|
2071
|
-
isError: query.isError,
|
|
2072
|
-
error: query.error,
|
|
2073
|
-
refetch: query.refetch
|
|
2074
|
-
};
|
|
2075
|
-
}
|
|
2076
|
-
function useBarnsportSitemap(baseUrl) {
|
|
2077
|
-
const { client, orgId } = useAxCloudContext();
|
|
2078
|
-
const query = useQuery({
|
|
2079
|
-
queryKey: ["axcloud", "barnsport", "sitemap", orgId, baseUrl],
|
|
2080
|
-
queryFn: () => client.get(`/barnsport/public/${orgId}/sitemap`, {
|
|
2081
|
-
baseUrl
|
|
2082
|
-
}),
|
|
2083
|
-
staleTime: 1e3 * 60 * 15
|
|
2084
|
-
});
|
|
2085
|
-
return {
|
|
2086
|
-
sitemap: query.data ?? null,
|
|
2087
|
-
urls: query.data?.urls ?? [],
|
|
2088
|
-
isLoading: query.isLoading,
|
|
2089
|
-
isError: query.isError,
|
|
2090
|
-
error: query.error,
|
|
2091
|
-
refetch: query.refetch
|
|
2092
|
-
};
|
|
2093
|
-
}
|
|
2094
|
-
function useSubmitBarnsportInterest() {
|
|
2095
|
-
const { client, orgId } = useAxCloudContext();
|
|
2096
|
-
return useMutation({
|
|
2097
|
-
mutationFn: (submission) => client.post(
|
|
2098
|
-
`/barnsport/public/${orgId}/interest`,
|
|
2099
|
-
submission
|
|
2100
|
-
)
|
|
2101
|
-
});
|
|
2102
|
-
}
|
|
2103
1271
|
function LoginButton({
|
|
2104
1272
|
children = "Log in",
|
|
2105
1273
|
returnTo,
|
|
@@ -2343,6 +1511,6 @@ function LinkedAccountsList({
|
|
|
2343
1511
|
] });
|
|
2344
1512
|
}
|
|
2345
1513
|
|
|
2346
|
-
export {
|
|
1514
|
+
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 };
|
|
2347
1515
|
//# sourceMappingURL=index.mjs.map
|
|
2348
1516
|
//# sourceMappingURL=index.mjs.map
|