@crystaltech/hsms-shared-ui 0.6.4-alpha-4 → 0.6.4-alpha-5

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.es.js CHANGED
@@ -45445,30 +45445,40 @@ const AQ = (e) => {
45445
45445
  }
45446
45446
  }, yQ = ({ children: e }) => {
45447
45447
  const [t, n] = at(null), [r, i] = at(!0), a = async () => {
45448
- var s;
45448
+ var s, l;
45449
45449
  try {
45450
45450
  i(!0);
45451
- const l = (s = JSON.parse(
45451
+ const c = (s = JSON.parse(
45452
45452
  localStorage.getItem("hospital_info") || "{}"
45453
- )) == null ? void 0 : s.id, c = Kp();
45454
- if (!l) {
45455
- const b = JSON.parse(localStorage.getItem("theme") || "null"), h = Fn(b ?? Dr);
45456
- n(h), localStorage.setItem("theme", JSON.stringify(h)), i(!1);
45453
+ )) == null ? void 0 : s.id, u = Kp();
45454
+ if (!c) {
45455
+ const v = JSON.parse(localStorage.getItem("theme") || "null"), y = Fn(v ?? Dr);
45456
+ n(y), localStorage.setItem("theme", JSON.stringify(y)), i(!1);
45457
45457
  return;
45458
45458
  }
45459
- const u = `${c}/api/public/organization/hospitals/theme-settings?hospitalId=${l}`, d = await fetch(u);
45460
- if (!d.ok)
45461
- throw new Error(`HTTP error! status: ${d.status}`);
45462
- const f = await d.json(), p = (f == null ? void 0 : f.data) || null, m = Fn(p ?? Dr);
45463
- n(m), localStorage.setItem("theme", JSON.stringify(m));
45464
- } catch (l) {
45465
- console.error("Error fetching theme settings:", l);
45459
+ const d = `${u}/api/public/hospitals/${c}/settings/theme`, f = `${u}/api/public/organization/hospitals/theme-settings?hospitalId=${c}`;
45460
+ let p;
45466
45461
  try {
45467
- const c = JSON.parse(localStorage.getItem("theme") || "null"), u = Fn(c ?? Dr);
45468
- n(u), localStorage.setItem("theme", JSON.stringify(u));
45462
+ p = await fetch(d), p.ok || (p = await fetch(f));
45463
+ } catch (v) {
45464
+ try {
45465
+ p = await fetch(f);
45466
+ } catch {
45467
+ throw v;
45468
+ }
45469
+ }
45470
+ if (!p.ok)
45471
+ throw new Error(`HTTP error! status: ${p.status}`);
45472
+ const m = await p.json(), b = (m == null ? void 0 : m.data) ?? ((l = m == null ? void 0 : m.response) == null ? void 0 : l.data) ?? m ?? null, h = Fn(b ?? Dr);
45473
+ n(h), localStorage.setItem("theme", JSON.stringify(h));
45474
+ } catch (c) {
45475
+ console.error("Error fetching theme settings:", c);
45476
+ try {
45477
+ const u = JSON.parse(localStorage.getItem("theme") || "null"), d = Fn(u ?? Dr);
45478
+ n(d), localStorage.setItem("theme", JSON.stringify(d));
45469
45479
  } catch {
45470
- const c = Fn(Dr);
45471
- n(c), localStorage.setItem("theme", JSON.stringify(c));
45480
+ const u = Fn(Dr);
45481
+ n(u), localStorage.setItem("theme", JSON.stringify(u));
45472
45482
  }
45473
45483
  } finally {
45474
45484
  i(!1);