@veritree/services 2.82.2 → 2.82.4
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/package.json +1 -1
- package/src/helpers/api.js +0 -2
- package/src/helpers/session.js +26 -18
package/package.json
CHANGED
package/src/helpers/api.js
CHANGED
|
@@ -313,8 +313,6 @@ export default class Api {
|
|
|
313
313
|
|
|
314
314
|
const me = getMe();
|
|
315
315
|
|
|
316
|
-
// console.log("API setOrg called...", window.location.pathname);
|
|
317
|
-
|
|
318
316
|
if (Object.keys(me).length) {
|
|
319
317
|
const orgPublicId = extractOrgPublicIdFromPath(window.location.pathname);
|
|
320
318
|
const org = resolveUserOrg(me, orgPublicId);
|
package/src/helpers/session.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export const getSession = () => {
|
|
2
|
-
return JSON.parse(localStorage.getItem(
|
|
2
|
+
return JSON.parse(localStorage.getItem("session") || "{}");
|
|
3
3
|
};
|
|
4
4
|
|
|
5
5
|
export const getMe = () => {
|
|
6
|
-
return JSON.parse(localStorage.getItem(
|
|
7
|
-
}
|
|
6
|
+
return JSON.parse(localStorage.getItem("me") || "{}");
|
|
7
|
+
};
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Returns reseller org based on:
|
|
11
11
|
* - if has veritree org, return veritree org
|
|
12
12
|
* - if no veritree org, return first reseller org
|
|
13
13
|
*
|
|
14
|
-
* @param {Array<Object>} resellers
|
|
14
|
+
* @param {Array<{org: Object}>} resellers - Array of reseller objects, each containing an org property
|
|
15
15
|
* @returns {object} org
|
|
16
16
|
*/
|
|
17
17
|
export const getResellerOrg = (resellers) => {
|
|
@@ -19,7 +19,9 @@ export const getResellerOrg = (resellers) => {
|
|
|
19
19
|
return getVeritreeOrg(resellers);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
return resellers
|
|
22
|
+
return Array.isArray(resellers) && resellers.length > 0
|
|
23
|
+
? resellers[0].org
|
|
24
|
+
: {};
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -48,17 +50,17 @@ export function getOrgType(orgType) {
|
|
|
48
50
|
let orgTypeFormatted = null;
|
|
49
51
|
|
|
50
52
|
switch (orgType) {
|
|
51
|
-
case
|
|
52
|
-
orgTypeFormatted =
|
|
53
|
+
case "owner":
|
|
54
|
+
orgTypeFormatted = "ownerAccount";
|
|
53
55
|
break;
|
|
54
|
-
case
|
|
55
|
-
orgTypeFormatted =
|
|
56
|
+
case "organization":
|
|
57
|
+
orgTypeFormatted = "orgAccount";
|
|
56
58
|
break;
|
|
57
|
-
case
|
|
58
|
-
orgTypeFormatted =
|
|
59
|
+
case "sponsor":
|
|
60
|
+
orgTypeFormatted = "sponsorAccount";
|
|
59
61
|
break;
|
|
60
|
-
case
|
|
61
|
-
orgTypeFormatted =
|
|
62
|
+
case "reseller":
|
|
63
|
+
orgTypeFormatted = "resellerAccount";
|
|
62
64
|
break;
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -131,10 +133,16 @@ export const getUserOrganizations = (me) => {
|
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
return [
|
|
134
|
-
...(me.user_owners
|
|
135
|
-
|
|
136
|
+
...(me.user_owners
|
|
137
|
+
? me.user_owners.map((uo) => uo.org).filter(Boolean)
|
|
138
|
+
: []),
|
|
139
|
+
...(me.user_resellers
|
|
140
|
+
? me.user_resellers.map((ur) => ur.org).filter(Boolean)
|
|
141
|
+
: []),
|
|
136
142
|
...(me.user_orgs ? me.user_orgs.map((uo) => uo.org).filter(Boolean) : []),
|
|
137
|
-
...(me.user_sponsors
|
|
143
|
+
...(me.user_sponsors
|
|
144
|
+
? me.user_sponsors.map((us) => us.org).filter(Boolean)
|
|
145
|
+
: []),
|
|
138
146
|
];
|
|
139
147
|
};
|
|
140
148
|
|
|
@@ -151,7 +159,7 @@ export const extractOrgPublicIdFromPath = (path) => {
|
|
|
151
159
|
}
|
|
152
160
|
|
|
153
161
|
const url = new URL(path, location.origin);
|
|
154
|
-
const pathSegments = url.pathname.split(
|
|
162
|
+
const pathSegments = url.pathname.split("/").filter(Boolean);
|
|
155
163
|
|
|
156
164
|
return pathSegments.length > 0 ? pathSegments[0] : null;
|
|
157
|
-
};
|
|
165
|
+
};
|