import { useEffect } from "preact/hooks"; import FloatingTileButtons from "./tiles/FloatingTileButtons.tsx"; import type { OnboardingStatus } from "../services/onboardingService.ts"; interface MemberHomeProps { onboardingStatus?: OnboardingStatus | null; } export default function MemberHome({ onboardingStatus }: MemberHomeProps) { useEffect(() => { const lockRoute = localStorage.getItem("lock-route"); if (lockRoute) { localStorage.removeItem("lock-route"); globalThis.location.href = lockRoute; return; } const loginPurpose = localStorage.getItem("login-purpose"); if (loginPurpose) { localStorage.removeItem("login-purpose"); const destination = loginPurpose === "landlord" ? "/landlord/dashboard" : loginPurpose === "tenant" ? "/tenant/dashboard" : ""; if (destination) { globalThis.location.href = destination; } } }, []); const tileIds = [ { id: "landlord-hub", label: "Landlord" }, { id: "tenant-hub", label: "Tenant" }, { id: "admin-center", label: "Admin" }, { id: "user-profile", label: "Profile" }, { id: "dashboard", label: "Dashboard" }, { id: "financial-calendar", label: "Calendar" }, ]; const tenantOnboarded = Boolean(onboardingStatus?.onboarded_tenant); const landlordStep = onboardingStatus?.onboarding_step ?? 0; const landlordStarted = Boolean(onboardingStatus?.onboarded_landlord) || landlordStep > 0; const landlordReady = landlordStarted && landlordStep === 0; const landlordInProgress = landlordStep > 0; const landlordPrimary = landlordReady ? { label: "Open Landlord Dashboard", href: "/landlord/dashboard" } : landlordInProgress ? { label: "Continue Landlord Setup", href: "/landlord/onboarding/profile" } : { label: "Start Landlord Setup", href: "/landlord/onboarding/profile" }; const tenantPrimary = tenantOnboarded ? { label: "Open Tenant Dashboard", href: "/tenant/dashboard" } : { label: "Continue Tenant Setup", href: "/tenant/dashboard" }; const now = new Date(); const calendarHref = `/calendar/financial-calendar/${now.getFullYear()}/${ (now.getMonth() + 1).toString().padStart(2, "0") }?`; return ( <>

Member Workspace

Go straight to what matters

Open landlord or tenant dashboards quickly, or jump into the financial calendar to plan your monthly budget.

Landlord {landlordReady ? "Ready" : landlordInProgress ? "Setup in Progress" : "Not Started"}
Tenant {tenantOnboarded ? "Ready" : "Setup Needed"}
Finance Calendar Ready

Admin Center

Administrative controls are available based on your account permissions.

Profile

Review account and security preferences.

Financial Calendar

Track income and obligations by day.

); }