@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.js CHANGED
@@ -1590,10 +1590,17 @@ var CustomThemeProvider = ({ children }) => {
1590
1590
  const canModifyTheme = Boolean(user && (user.role === "super_admin" || user.role === "admin" || user.role === "owner" || user.role === "property_manager" || user.role === "maintenance"));
1591
1591
  (0, import_react3.useEffect)(() => {
1592
1592
  if (!isEmbedded) return;
1593
+ let isInitialRequest = true;
1593
1594
  const handleMessage = (event) => {
1594
1595
  if (!event.origin.startsWith("http://localhost:")) return;
1595
1596
  const { type, theme } = event.data;
1596
1597
  if (type === "THEME_CHANGE" && theme && ["light", "dark"].includes(theme)) {
1598
+ const storedTheme2 = localStorage.getItem("embedded-theme");
1599
+ if (isInitialRequest && storedTheme2 && storedTheme2 !== theme) {
1600
+ isInitialRequest = false;
1601
+ return;
1602
+ }
1603
+ isInitialRequest = false;
1597
1604
  setCurrentTheme(theme);
1598
1605
  localStorage.setItem("embedded-theme", theme);
1599
1606
  }
@@ -1612,8 +1619,10 @@ var CustomThemeProvider = ({ children }) => {
1612
1619
  if (isEmbedded) return;
1613
1620
  if (user && canModifyTheme) {
1614
1621
  const themeToUse = user.themePreference || "light";
1622
+ console.log("[ThemeContext] Loading user theme preference:", themeToUse, "User:", user);
1615
1623
  setCurrentTheme(themeToUse);
1616
1624
  } else {
1625
+ console.log("[ThemeContext] No user or cannot modify theme, using light. User:", user, "canModifyTheme:", canModifyTheme);
1617
1626
  setCurrentTheme("light");
1618
1627
  }
1619
1628
  }, [user, canModifyTheme, isEmbedded]);