@axcode/axcloud-sdk 0.1.7-dev.cc5cc69 → 0.2.0-dev.1e6c3d5
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 +40 -31
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ npm install --save-exact @axcode/axcloud-sdk@latest
|
|
|
30
30
|
```json
|
|
31
31
|
{
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@axcode/axcloud-sdk": "0.
|
|
33
|
+
"@axcode/axcloud-sdk": "0.2.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
```
|
|
@@ -353,25 +353,25 @@ function Dashboard() {
|
|
|
353
353
|
|
|
354
354
|
### Hooks
|
|
355
355
|
|
|
356
|
-
| Hook | Description
|
|
357
|
-
| --------------------------------- |
|
|
358
|
-
| `useAuth()` | Login/logout, email-verification state, resend, and profile refresh
|
|
359
|
-
| `useUser()` | Fetch the normalized user and verified organization membership
|
|
360
|
-
| `useUpdateMyProfile()` | Update the signed-in user's name, phone, and address
|
|
361
|
-
| `useOrg()` | Fetch organization info and check modules
|
|
362
|
-
| `useNews(options?)` | Fetch the published news collection visible to the current visitor
|
|
363
|
-
| `useContent(type, options?)` | Fetch a published `news`, `pages`, or `events` collection
|
|
364
|
-
| `useContentItem(type, id, opts?)` | Fetch one published item directly by ID or slug
|
|
365
|
-
| `usePageContent(slug, options?)` | Fetch a page and read structured template slots
|
|
366
|
-
| `useMySection()` | Fetch current user's section with members
|
|
367
|
-
| `useSections()` | Fetch all organization sections
|
|
368
|
-
| `useBranding()` | Fetch organization branding (logo, colors)
|
|
369
|
-
| `useLogo()` | Fetch organization logo URL
|
|
370
|
-
| `useMedia(mediaId)` | Fetch specific media file URL
|
|
371
|
-
| `useAvatar(userId)` | Fetch user avatar URL
|
|
372
|
-
| `useMediaList(type)` | List media files
|
|
373
|
-
| `useDocuments(options?)` | List published public documents
|
|
374
|
-
| `useDocumentDownload(documentId)` | Fetch a signed document download URL
|
|
356
|
+
| Hook | Description |
|
|
357
|
+
| --------------------------------- | ------------------------------------------------------------------- |
|
|
358
|
+
| `useAuth()` | Login/logout, email-verification state, resend, and profile refresh |
|
|
359
|
+
| `useUser()` | Fetch the normalized user and verified organization membership |
|
|
360
|
+
| `useUpdateMyProfile()` | Update the signed-in user's name, phone, and address |
|
|
361
|
+
| `useOrg()` | Fetch organization info and check modules |
|
|
362
|
+
| `useNews(options?)` | Fetch the published news collection visible to the current visitor |
|
|
363
|
+
| `useContent(type, options?)` | Fetch a published `news`, `pages`, or `events` collection |
|
|
364
|
+
| `useContentItem(type, id, opts?)` | Fetch one published item directly by ID or slug |
|
|
365
|
+
| `usePageContent(slug, options?)` | Fetch a page and read structured template slots |
|
|
366
|
+
| `useMySection()` | Fetch current user's section with members |
|
|
367
|
+
| `useSections()` | Fetch all organization sections |
|
|
368
|
+
| `useBranding()` | Fetch organization branding (logo, colors) |
|
|
369
|
+
| `useLogo()` | Fetch organization logo URL |
|
|
370
|
+
| `useMedia(mediaId)` | Fetch specific media file URL |
|
|
371
|
+
| `useAvatar(userId)` | Fetch user avatar URL |
|
|
372
|
+
| `useMediaList(type)` | List media files |
|
|
373
|
+
| `useDocuments(options?)` | List published public documents |
|
|
374
|
+
| `useDocumentDownload(documentId)` | Fetch a signed document download URL |
|
|
375
375
|
|
|
376
376
|
Profile self-service is deliberately limited to personal contact fields. Organization title,
|
|
377
377
|
email, roles, status, organization, and section assignments remain administrator-managed.
|
|
@@ -384,14 +384,18 @@ const {
|
|
|
384
384
|
user,
|
|
385
385
|
roleInOrg,
|
|
386
386
|
title,
|
|
387
|
-
section,
|
|
388
|
-
sections,
|
|
387
|
+
section, // { id, name, role } | null
|
|
388
|
+
sections, // all verified section memberships
|
|
389
389
|
sectionId,
|
|
390
390
|
sectionIds,
|
|
391
|
-
memberSince,
|
|
391
|
+
memberSince, // normalized from joined_at
|
|
392
392
|
} = useUser();
|
|
393
393
|
|
|
394
|
-
return
|
|
394
|
+
return (
|
|
395
|
+
<p>
|
|
396
|
+
{section?.name ?? 'No section'} · member since {memberSince}
|
|
397
|
+
</p>
|
|
398
|
+
);
|
|
395
399
|
```
|
|
396
400
|
|
|
397
401
|
```tsx
|
|
@@ -400,14 +404,19 @@ import { useUpdateMyProfile } from '@axcode/axcloud-sdk';
|
|
|
400
404
|
function ProfileForm() {
|
|
401
405
|
const updateProfile = useUpdateMyProfile();
|
|
402
406
|
|
|
403
|
-
const save = () =>
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
407
|
+
const save = () =>
|
|
408
|
+
updateProfile.mutateAsync({
|
|
409
|
+
firstName: 'Anna',
|
|
410
|
+
lastName: 'Pilot',
|
|
411
|
+
phone: '+46701234567',
|
|
412
|
+
address: 'Flyggatan 1',
|
|
413
|
+
});
|
|
409
414
|
|
|
410
|
-
return
|
|
415
|
+
return (
|
|
416
|
+
<button onClick={save} disabled={updateProfile.isPending}>
|
|
417
|
+
Save profile
|
|
418
|
+
</button>
|
|
419
|
+
);
|
|
411
420
|
}
|
|
412
421
|
```
|
|
413
422
|
|
package/dist/index.js
CHANGED
|
@@ -2155,7 +2155,7 @@ function ProtectedRoute({
|
|
|
2155
2155
|
returnTo
|
|
2156
2156
|
}) {
|
|
2157
2157
|
const { isAuthenticated, isLoading: isAuthLoading, login } = useAuth();
|
|
2158
|
-
const {
|
|
2158
|
+
const { role, isLoading: isUserLoading } = useUser();
|
|
2159
2159
|
const isLoading = isAuthLoading || isAuthenticated && isUserLoading;
|
|
2160
2160
|
if (isLoading) {
|
|
2161
2161
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: loadingComponent ?? /* @__PURE__ */ jsxRuntime.jsx(DefaultLoadingComponent, {}) });
|
|
@@ -2167,9 +2167,9 @@ function ProtectedRoute({
|
|
|
2167
2167
|
}
|
|
2168
2168
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: unauthenticatedComponent ?? /* @__PURE__ */ jsxRuntime.jsx(DefaultUnauthenticatedComponent, {}) });
|
|
2169
2169
|
}
|
|
2170
|
-
if (roles
|
|
2170
|
+
if (roles) {
|
|
2171
2171
|
const requiredRoles = Array.isArray(roles) ? roles : [roles];
|
|
2172
|
-
const hasRequiredRole = requiredRoles.includes(role);
|
|
2172
|
+
const hasRequiredRole = role !== null && role !== void 0 && requiredRoles.includes(role);
|
|
2173
2173
|
if (!hasRequiredRole) {
|
|
2174
2174
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: unauthorizedComponent ?? /* @__PURE__ */ jsxRuntime.jsx(DefaultUnauthorizedComponent, {}) });
|
|
2175
2175
|
}
|