@propknot/shared-ui 1.0.23 → 1.0.25

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.mjs CHANGED
@@ -1525,10 +1525,17 @@ var CustomThemeProvider = ({ children }) => {
1525
1525
  const canModifyTheme = Boolean(user && (user.role === "super_admin" || user.role === "admin" || user.role === "owner" || user.role === "property_manager" || user.role === "maintenance"));
1526
1526
  useEffect2(() => {
1527
1527
  if (!isEmbedded) return;
1528
+ let isInitialRequest = true;
1528
1529
  const handleMessage = (event) => {
1529
1530
  if (!event.origin.startsWith("http://localhost:")) return;
1530
1531
  const { type, theme } = event.data;
1531
1532
  if (type === "THEME_CHANGE" && theme && ["light", "dark"].includes(theme)) {
1533
+ const storedTheme2 = localStorage.getItem("embedded-theme");
1534
+ if (isInitialRequest && storedTheme2 && storedTheme2 !== theme) {
1535
+ isInitialRequest = false;
1536
+ return;
1537
+ }
1538
+ isInitialRequest = false;
1532
1539
  setCurrentTheme(theme);
1533
1540
  localStorage.setItem("embedded-theme", theme);
1534
1541
  }
@@ -1547,8 +1554,10 @@ var CustomThemeProvider = ({ children }) => {
1547
1554
  if (isEmbedded) return;
1548
1555
  if (user && canModifyTheme) {
1549
1556
  const themeToUse = user.themePreference || "light";
1557
+ console.log("[ThemeContext] Loading user theme preference:", themeToUse, "User:", user);
1550
1558
  setCurrentTheme(themeToUse);
1551
1559
  } else {
1560
+ console.log("[ThemeContext] No user or cannot modify theme, using light. User:", user, "canModifyTheme:", canModifyTheme);
1552
1561
  setCurrentTheme("light");
1553
1562
  }
1554
1563
  }, [user, canModifyTheme, isEmbedded]);