@propknot/shared-ui 1.0.16 → 1.0.18

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
@@ -358,7 +358,8 @@ var AuthProvider = ({ children }) => {
358
358
  };
359
359
  setUser(normalizedUser);
360
360
  const isOwnerRole = normalizedUser.role === "owner";
361
- const hasNoCompany = !normalizedUser.company;
361
+ const hasNoCompany = !normalizedUser.company || normalizedUser.company === null || normalizedUser.company === void 0;
362
+ console.log("Onboarding check:", { isOwnerRole, hasNoCompany, company: normalizedUser.company });
362
363
  setNeedsOnboarding(isOwnerRole && hasNoCompany);
363
364
  if (normalizedUser.role === "property_manager" || normalizedUser.role === "maintenance") {
364
365
  try {
@@ -388,7 +389,21 @@ var AuthProvider = ({ children }) => {
388
389
  const { token, user: user2 } = response.data;
389
390
  localStorage.setItem("token", token);
390
391
  api_default.defaults.headers.common["Authorization"] = `Bearer ${token}`;
391
- setUser(user2);
392
+ const normalizedUser = {
393
+ ...user2,
394
+ id: user2._id || user2.id,
395
+ enabledFeatures: user2.enabledFeatures || {
396
+ workersModule: true,
397
+ inventoryModule: true,
398
+ advancedAnalytics: false,
399
+ aiAssistant: true
400
+ }
401
+ };
402
+ setUser(normalizedUser);
403
+ const isOwnerRole = normalizedUser.role === "owner";
404
+ const hasNoCompany = !normalizedUser.company || normalizedUser.company === null || normalizedUser.company === void 0;
405
+ console.log("Login onboarding check:", { isOwnerRole, hasNoCompany, company: normalizedUser.company });
406
+ setNeedsOnboarding(isOwnerRole && hasNoCompany);
392
407
  return { success: true };
393
408
  } catch (error) {
394
409
  console.error("Login failed:", error);