astrogators-shared-ui 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.js CHANGED
@@ -285,14 +285,14 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
285
285
  } catch (e) {
286
286
  console.error("Failed to save ally code to localStorage:", e);
287
287
  }
288
- }, re = (e) => {
288
+ }, B = (e) => {
289
289
  try {
290
290
  let t = z().filter((t) => t.ally_code !== e);
291
291
  localStorage.setItem(L, JSON.stringify(t));
292
292
  } catch (e) {
293
293
  console.error("Failed to remove ally code from localStorage:", e);
294
294
  }
295
- }, B = (e) => {
295
+ }, V = (e) => {
296
296
  try {
297
297
  let t = z().map((t) => t.ally_code === e ? {
298
298
  ...t,
@@ -302,11 +302,11 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
302
302
  } catch (e) {
303
303
  console.error("Failed to update ally code last used:", e);
304
304
  }
305
- }, ie = () => localStorage.getItem(R), V = (e) => {
305
+ }, H = () => localStorage.getItem(R), U = (e) => {
306
306
  e ? localStorage.setItem(R, e) : localStorage.removeItem(R);
307
- }, H = () => {
307
+ }, W = () => {
308
308
  localStorage.removeItem(L), localStorage.removeItem(R);
309
- }, U = t(void 0), W = ({ children: e, apiBaseUrl: t }) => {
309
+ }, re = t(void 0), ie = ({ children: e, apiBaseUrl: t }) => {
310
310
  let [r, o] = a(null), [c, l] = a(!0), [u, d] = a(!0), [f, p] = a(!0), [m, h] = a([]), [g, _] = a(null), [v, y] = a(!1), [b, x] = a({
311
311
  show: !1,
312
312
  localStorageCodes: []
@@ -389,19 +389,19 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
389
389
  localStorageCodes: e.map((e) => e.ally_code)
390
390
  });
391
391
  } else h(z());
392
- _(ie());
392
+ _(H());
393
393
  } catch (e) {
394
394
  console.error("Failed to fetch ally codes:", e), h([]);
395
395
  } finally {
396
396
  y(!1);
397
397
  }
398
398
  }, [r]), N = n(async (e) => {
399
- r && typeof e == "number" ? (await I.put(`/api/v1/users/me/ally-codes/${e}/use`, {}), await M()) : !r && typeof e == "string" && (B(e), h(z()));
399
+ r && typeof e == "number" ? (await I.put(`/api/v1/users/me/ally-codes/${e}/use`, {}), await M()) : !r && typeof e == "string" && (V(e), h(z()));
400
400
  }, [r, M]), P = n((e) => {
401
- if (_(e), V(e), e && r) {
401
+ if (_(e), U(e), e && r) {
402
402
  let t = m.find((t) => "ally_code" in t && t.ally_code === e);
403
403
  t && "id" in t && N(t.id);
404
- } else e && !r && B(e);
404
+ } else e && !r && V(e);
405
405
  }, [
406
406
  r,
407
407
  m,
@@ -425,7 +425,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
425
425
  m.length,
426
426
  P
427
427
  ]), L = n(async (e) => {
428
- r && typeof e == "number" ? (await I.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(z()), g === e && P(null));
428
+ r && typeof e == "number" ? (await I.delete(`/api/v1/users/me/ally-codes/${e}`), h((t) => t.filter((t) => "id" in t && t.id !== e))) : !r && typeof e == "string" && (B(e), h(z()), g === e && P(null));
429
429
  }, [
430
430
  r,
431
431
  g,
@@ -435,7 +435,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
435
435
  show: !1,
436
436
  localStorageCodes: []
437
437
  });
438
- }, []), W = n(async () => {
438
+ }, []), ie = n(async () => {
439
439
  if (!r) return;
440
440
  let e = z();
441
441
  for (let t of e) try {
@@ -443,7 +443,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
443
443
  } catch (e) {
444
444
  console.error(`Failed to migrate ally code ${t.ally_code}:`, e);
445
445
  }
446
- H(), R();
446
+ W(), R();
447
447
  }, [
448
448
  r,
449
449
  F,
@@ -475,14 +475,14 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
475
475
  updateAllyCodeLastUsed: N,
476
476
  migrationPrompt: b,
477
477
  dismissMigrationPrompt: R,
478
- migrateLocalStorageCodes: W
478
+ migrateLocalStorageCodes: ie
479
479
  };
480
- return /* @__PURE__ */ s(U.Provider, {
480
+ return /* @__PURE__ */ s(re.Provider, {
481
481
  value: G,
482
482
  children: e
483
483
  });
484
484
  }, G = () => {
485
- let e = r(U);
485
+ let e = r(re);
486
486
  if (e === void 0) throw Error("useAuth must be used within an AuthProvider");
487
487
  return e;
488
488
  }, K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e.slice(6, 9)}`, ae = (e) => e.replace(/-/g, ""), q = {
@@ -507,11 +507,24 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
507
507
  }, E = async (e) => {
508
508
  let t = n.find((t) => t.ally_code === e);
509
509
  t && await o("id" in t ? t.id : t.ally_code);
510
- };
511
- return n.length === 0 ? null : /* @__PURE__ */ c("div", {
510
+ }, D = async () => {
511
+ if (y(""), x(""), !/^\d{9}$/.test(p)) {
512
+ y("Ally code must be exactly 9 digits");
513
+ return;
514
+ }
515
+ C(!0);
516
+ try {
517
+ await l(p), x("Added successfully!"), h(""), setTimeout(() => x(""), 2e3);
518
+ } catch (e) {
519
+ y(e.message || "Failed to add ally code");
520
+ } finally {
521
+ C(!1);
522
+ }
523
+ }, O = n.length > 0;
524
+ return /* @__PURE__ */ c("div", {
512
525
  className: `${q.allyCodeDropdown} ${t}`,
513
526
  children: [
514
- /* @__PURE__ */ s(g, {
527
+ O && /* @__PURE__ */ s(g, {
515
528
  options: w,
516
529
  value: r || "",
517
530
  onChange: T,
@@ -537,20 +550,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
537
550
  }), /* @__PURE__ */ s(m, {
538
551
  variant: "primary",
539
552
  size: "sm",
540
- onClick: async () => {
541
- if (y(""), x(""), !/^\d{9}$/.test(p)) {
542
- y("Ally code must be exactly 9 digits");
543
- return;
544
- }
545
- C(!0);
546
- try {
547
- await l(p), x("Added successfully!"), h(""), setTimeout(() => x(""), 2e3);
548
- } catch (e) {
549
- y(e.message || "Failed to add ally code");
550
- } finally {
551
- C(!1);
552
- }
553
- },
553
+ onClick: D,
554
554
  loading: S,
555
555
  disabled: p.length !== 9,
556
556
  children: "Add"
@@ -592,7 +592,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
592
592
  size: "sm",
593
593
  onClick: () => f(!d),
594
594
  className: q.manageButton,
595
- children: "Manage"
595
+ children: O ? "Manage" : "+ Add ally code"
596
596
  })
597
597
  ]
598
598
  });
@@ -824,4 +824,4 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
824
824
  })
825
825
  });
826
826
  //#endregion
827
- export { oe as AllyCodeDropdown, F as ApiClient, W as AuthProvider, ue as Badge, m as Button, le as Card, u as Container, ce as Footer, v as Input, fe as Loader, de as Modal, se as NavBar, g as Select, f as TopBar, I as apiClient, P as authedFetch, H as clearAllyCodes, O as clearTokens, M as configureAuthRefresh, K as formatAllyCode, x as getAccessToken, z 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, V as setSelectedAllyCode, D as setTokens, ae as unformatAllyCode, B as updateAllyCodeLastUsed, G as useAuth };
827
+ export { oe as AllyCodeDropdown, F as ApiClient, ie as AuthProvider, ue as Badge, m as Button, le as Card, u as Container, ce as Footer, v as Input, fe as Loader, de as Modal, se as NavBar, g as Select, f as TopBar, I as apiClient, P as authedFetch, W as clearAllyCodes, O as clearTokens, M as configureAuthRefresh, K as formatAllyCode, x as getAccessToken, z as getAllyCodesFromStorage, w as getRefreshToken, H as getSelectedAllyCode, te as initializeApiClient, ee as isAuthenticated, N as refreshAccessToken, C as removeAccessToken, B as removeAllyCodeFromStorage, E as removeRefreshToken, ne as saveAllyCodeToStorage, S as setAccessToken, T as setRefreshToken, U as setSelectedAllyCode, D as setTokens, ae as unformatAllyCode, V as updateAllyCodeLastUsed, G as useAuth };
@@ -6,6 +6,7 @@ export interface User {
6
6
  id: string;
7
7
  email: string;
8
8
  username: string;
9
+ role: string;
9
10
  is_verified: boolean;
10
11
  is_active: boolean;
11
12
  created_at: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astrogators-shared-ui",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "description": "Shared UI components and utilities for Astrogator's Table applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",