astrogators-shared-ui 0.13.0 → 0.13.1
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.js +21 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -298,14 +298,14 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
298
298
|
} catch (e) {
|
|
299
299
|
console.error("Failed to save ally code to localStorage:", e);
|
|
300
300
|
}
|
|
301
|
-
},
|
|
301
|
+
}, re = (e) => {
|
|
302
302
|
try {
|
|
303
303
|
let t = V().filter((t) => t.ally_code !== e);
|
|
304
304
|
localStorage.setItem(z, JSON.stringify(t));
|
|
305
305
|
} catch (e) {
|
|
306
306
|
console.error("Failed to remove ally code from localStorage:", e);
|
|
307
307
|
}
|
|
308
|
-
},
|
|
308
|
+
}, H = (e) => {
|
|
309
309
|
try {
|
|
310
310
|
let t = V().map((t) => t.ally_code === e ? {
|
|
311
311
|
...t,
|
|
@@ -315,7 +315,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
315
315
|
} catch (e) {
|
|
316
316
|
console.error("Failed to update ally code last used:", e);
|
|
317
317
|
}
|
|
318
|
-
},
|
|
318
|
+
}, ie = () => localStorage.getItem(B), U = (e) => {
|
|
319
319
|
e ? localStorage.setItem(B, e) : localStorage.removeItem(B);
|
|
320
320
|
}, ae = () => {
|
|
321
321
|
localStorage.removeItem(z), localStorage.removeItem(B);
|
|
@@ -365,7 +365,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
365
365
|
throw console.error("Registration failed:", e), e;
|
|
366
366
|
}
|
|
367
367
|
}, T = () => {
|
|
368
|
-
O(), o(null), h([]), _(null), x({
|
|
368
|
+
O(), o(null), h([]), _(null), U(null), x({
|
|
369
369
|
show: !1,
|
|
370
370
|
localStorageCodes: []
|
|
371
371
|
});
|
|
@@ -392,27 +392,33 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
392
392
|
}, M = n(async () => {
|
|
393
393
|
y(!0);
|
|
394
394
|
try {
|
|
395
|
+
let e = [];
|
|
395
396
|
if (r) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
397
|
+
let t = await R.get("/api/v1/users/me/ally-codes");
|
|
398
|
+
h(t.ally_codes), e = t.ally_codes.map((e) => e.ally_code);
|
|
399
|
+
let n = V();
|
|
400
|
+
n.length > 0 && x({
|
|
399
401
|
show: !0,
|
|
400
|
-
localStorageCodes:
|
|
402
|
+
localStorageCodes: n.map((e) => e.ally_code)
|
|
401
403
|
});
|
|
402
|
-
} else
|
|
403
|
-
|
|
404
|
+
} else {
|
|
405
|
+
let t = V();
|
|
406
|
+
h(t), e = t.map((e) => e.ally_code);
|
|
407
|
+
}
|
|
408
|
+
let t = ie(), n = t && e.includes(t) ? t : null;
|
|
409
|
+
_(n), n !== t && U(n);
|
|
404
410
|
} catch (e) {
|
|
405
411
|
console.error("Failed to fetch ally codes:", e), h([]);
|
|
406
412
|
} finally {
|
|
407
413
|
y(!1);
|
|
408
414
|
}
|
|
409
415
|
}, [r]), N = n(async (e) => {
|
|
410
|
-
r && typeof e == "number" ? (await R.put(`/api/v1/users/me/ally-codes/${e}/use`, {}), await M()) : !r && typeof e == "string" && (
|
|
416
|
+
r && typeof e == "number" ? (await R.put(`/api/v1/users/me/ally-codes/${e}/use`, {}), await M()) : !r && typeof e == "string" && (H(e), h(V()));
|
|
411
417
|
}, [r, M]), P = n((e) => {
|
|
412
|
-
if (_(e),
|
|
418
|
+
if (_(e), U(e), e && r) {
|
|
413
419
|
let t = m.find((t) => "ally_code" in t && t.ally_code === e);
|
|
414
420
|
t && "id" in t && N(t.id);
|
|
415
|
-
} else e && !r &&
|
|
421
|
+
} else e && !r && H(e);
|
|
416
422
|
}, [
|
|
417
423
|
r,
|
|
418
424
|
m,
|
|
@@ -436,7 +442,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
436
442
|
m.length,
|
|
437
443
|
P
|
|
438
444
|
]), I = n(async (e) => {
|
|
439
|
-
r && typeof e == "number" ? (await R.delete(`/api/v1/users/me/ally-codes/${e}`), h((t) => t.filter((t) => "id" in t && t.id !== e))) : !r && typeof e == "string" && (
|
|
445
|
+
r && typeof e == "number" ? (await R.delete(`/api/v1/users/me/ally-codes/${e}`), h((t) => t.filter((t) => "id" in t && t.id !== e))) : !r && typeof e == "string" && (re(e), h(V()), g === e && P(null));
|
|
440
446
|
}, [
|
|
441
447
|
r,
|
|
442
448
|
g,
|
|
@@ -839,4 +845,4 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
839
845
|
return Object.fromEntries(n.users.map((e) => [e.id, e.username]));
|
|
840
846
|
};
|
|
841
847
|
//#endregion
|
|
842
|
-
export { ce as AllyCodeDropdown, L as ApiClient, oe as AuthProvider, fe as Badge, m as Button, de as Card, u as Container, ue as Footer, v as Input, me as Loader, pe as Modal, le as NavBar, g as Select, f as TopBar, R as apiClient, I as authedFetch, ae as clearAllyCodes, O as clearTokens, M as configureAuthRefresh, he as fetchUsernames, K as formatAllyCode, x as getAccessToken, V as getAllyCodesFromStorage, w as getRefreshToken,
|
|
848
|
+
export { ce as AllyCodeDropdown, L as ApiClient, oe as AuthProvider, fe as Badge, m as Button, de as Card, u as Container, ue as Footer, v as Input, me as Loader, pe as Modal, le as NavBar, g as Select, f as TopBar, R as apiClient, I as authedFetch, ae as clearAllyCodes, O as clearTokens, M as configureAuthRefresh, he as fetchUsernames, K as formatAllyCode, x as getAccessToken, V as getAllyCodesFromStorage, w as getRefreshToken, ie as getSelectedAllyCode, te as initializeApiClient, ee as isAuthenticated, N as refreshAccessToken, C as removeAccessToken, re as removeAllyCodeFromStorage, E as removeRefreshToken, ne as saveAllyCodeToStorage, S as setAccessToken, T as setRefreshToken, U as setSelectedAllyCode, D as setTokens, se as unformatAllyCode, H as updateAllyCodeLastUsed, G as useAuth };
|