@sylphx/sdk 0.10.1 → 0.10.3
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.d.ts +25 -5
- package/dist/index.mjs +15 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.mjs +14 -4
- package/dist/react/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/react/index.mjs
CHANGED
|
@@ -1435,8 +1435,14 @@ async function callApi(config2, path, options = {}) {
|
|
|
1435
1435
|
}
|
|
1436
1436
|
|
|
1437
1437
|
// src/orgs.ts
|
|
1438
|
+
import {
|
|
1439
|
+
organizationsEndpoints
|
|
1440
|
+
} from "@sylphx/contract";
|
|
1438
1441
|
async function getOrganizations(config2) {
|
|
1439
|
-
|
|
1442
|
+
const endpoint = organizationsEndpoints.memberships;
|
|
1443
|
+
return callApi(config2, endpoint.path, {
|
|
1444
|
+
method: endpoint.method
|
|
1445
|
+
});
|
|
1440
1446
|
}
|
|
1441
1447
|
async function getOrganization(config2, orgIdOrSlug) {
|
|
1442
1448
|
return callApi(config2, `/orgs/${orgIdOrSlug}`);
|
|
@@ -2744,6 +2750,9 @@ function useSylphx() {
|
|
|
2744
2750
|
}
|
|
2745
2751
|
};
|
|
2746
2752
|
}
|
|
2753
|
+
function mutableOrganizations(organizations) {
|
|
2754
|
+
return [...organizations];
|
|
2755
|
+
}
|
|
2747
2756
|
var ORG_STORAGE_KEY = "sylphx_active_org";
|
|
2748
2757
|
var ORG_BROADCAST_CHANNEL = "sylphx_org_sync";
|
|
2749
2758
|
function useOrganization() {
|
|
@@ -2860,9 +2869,10 @@ function useOrganization() {
|
|
|
2860
2869
|
try {
|
|
2861
2870
|
const result = await getOrganizations(config2);
|
|
2862
2871
|
if (mounted) {
|
|
2863
|
-
|
|
2872
|
+
const organizations2 = mutableOrganizations(result.organizations);
|
|
2873
|
+
setOrganizations(organizations2);
|
|
2864
2874
|
const storedSlug = getStoredOrgSlug();
|
|
2865
|
-
const orgToSelect = storedSlug ?
|
|
2875
|
+
const orgToSelect = storedSlug ? organizations2.find((o2) => o2.slug === storedSlug) : organizations2[0];
|
|
2866
2876
|
if (orgToSelect && !organization) {
|
|
2867
2877
|
await selectOrganization(orgToSelect.slug);
|
|
2868
2878
|
}
|
|
@@ -2990,7 +3000,7 @@ function useOrganization() {
|
|
|
2990
3000
|
setIsLoading(true);
|
|
2991
3001
|
try {
|
|
2992
3002
|
const result = await getOrganizations(config2);
|
|
2993
|
-
setOrganizations(result.organizations);
|
|
3003
|
+
setOrganizations(mutableOrganizations(result.organizations));
|
|
2994
3004
|
if (organization) {
|
|
2995
3005
|
await selectOrganization(organization.slug);
|
|
2996
3006
|
}
|