Feature 1 - How-To Intro Tour (react-joyride): - 8-step guided walkthrough highlighting Dashboard, Accounts, Assessments, Transactions, Budgets, Reports, and AI Investment Planning - Runs automatically on first login, tracked via has_seen_intro flag on user - Centralized step config in config/tourSteps.ts for easy text editing - data-tour attributes on Sidebar nav items and Dashboard for targeting Feature 2 - Tenant Onboarding Wizard: - 3-step modal wizard: create operating account, assessment group + units, import budget CSV - Runs after tour completes, tracked via onboardingComplete in org settings JSONB - Reuses existing API endpoints (POST /accounts, /assessment-groups, /units, /budgets/:year/import) Backend changes: - Add has_seen_intro column to shared.users + migration - Add PATCH /auth/intro-seen endpoint to mark tour complete - Add PATCH /organizations/settings endpoint for org settings updates - Include hasSeenIntro in login response, settings in switch-org response Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
195 lines
6.0 KiB
TypeScript
195 lines
6.0 KiB
TypeScript
import { NavLink, ScrollArea, Divider, Text } from '@mantine/core';
|
|
import { useNavigate, useLocation } from 'react-router-dom';
|
|
import {
|
|
IconDashboard,
|
|
IconListDetails,
|
|
IconReceipt,
|
|
IconHome,
|
|
IconFileInvoice,
|
|
IconCash,
|
|
IconReportAnalytics,
|
|
IconChartSankey,
|
|
IconShieldCheck,
|
|
IconBuildingBank,
|
|
IconUsers,
|
|
IconCrown,
|
|
IconCategory,
|
|
IconChartAreaLine,
|
|
IconClipboardCheck,
|
|
IconSparkles,
|
|
IconHeartRateMonitor,
|
|
} from '@tabler/icons-react';
|
|
import { useAuthStore } from '../../stores/authStore';
|
|
|
|
const navSections = [
|
|
{
|
|
items: [
|
|
{ label: 'Dashboard', icon: IconDashboard, path: '/dashboard' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Financials',
|
|
items: [
|
|
{ label: 'Accounts', icon: IconListDetails, path: '/accounts', tourId: 'nav-accounts' },
|
|
{ label: 'Cash Flow', icon: IconChartAreaLine, path: '/cash-flow' },
|
|
{ label: 'Monthly Actuals', icon: IconClipboardCheck, path: '/monthly-actuals' },
|
|
{ label: 'Budgets', icon: IconReportAnalytics, path: '/budgets/2026', tourId: 'nav-budgets' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Assessments',
|
|
items: [
|
|
{ label: 'Units / Homeowners', icon: IconHome, path: '/units' },
|
|
{ label: 'Assessment Groups', icon: IconCategory, path: '/assessment-groups', tourId: 'nav-assessment-groups' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Transactions',
|
|
items: [
|
|
{ label: 'Transactions', icon: IconReceipt, path: '/transactions', tourId: 'nav-transactions' },
|
|
{ label: 'Invoices', icon: IconFileInvoice, path: '/invoices' },
|
|
{ label: 'Payments', icon: IconCash, path: '/payments' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Planning',
|
|
items: [
|
|
{ label: 'Projects', icon: IconShieldCheck, path: '/projects' },
|
|
{ label: 'Capital Planning', icon: IconBuildingBank, path: '/capital-projects' },
|
|
{ label: 'Investment Planning', icon: IconSparkles, path: '/investment-planning', tourId: 'nav-investment-planning' },
|
|
{ label: 'Vendors', icon: IconUsers, path: '/vendors' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Reports',
|
|
items: [
|
|
{
|
|
label: 'Reports',
|
|
icon: IconChartSankey,
|
|
tourId: 'nav-reports',
|
|
children: [
|
|
{ label: 'Balance Sheet', path: '/reports/balance-sheet' },
|
|
{ label: 'Income Statement', path: '/reports/income-statement' },
|
|
{ label: 'Cash Flow', path: '/reports/cash-flow' },
|
|
{ label: 'Budget vs Actual', path: '/reports/budget-vs-actual' },
|
|
{ label: 'Aging Report', path: '/reports/aging' },
|
|
{ label: 'Sankey Diagram', path: '/reports/sankey' },
|
|
{ label: 'Year-End', path: '/reports/year-end' },
|
|
{ label: 'Quarterly Financial', path: '/reports/quarterly' },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
interface SidebarProps {
|
|
onNavigate?: () => void;
|
|
}
|
|
|
|
export function Sidebar({ onNavigate }: SidebarProps) {
|
|
const navigate = useNavigate();
|
|
const location = useLocation();
|
|
const user = useAuthStore((s) => s.user);
|
|
const currentOrg = useAuthStore((s) => s.currentOrg);
|
|
const organizations = useAuthStore((s) => s.organizations);
|
|
const isAdminOnly = location.pathname.startsWith('/admin') && !currentOrg;
|
|
|
|
const go = (path: string) => {
|
|
navigate(path);
|
|
onNavigate?.();
|
|
};
|
|
|
|
// When on admin route with no org selected, show admin-only sidebar
|
|
if (isAdminOnly && user?.isSuperadmin) {
|
|
return (
|
|
<ScrollArea p="sm">
|
|
<Text size="xs" c="dimmed" fw={700} tt="uppercase" px="sm" pb={4}>
|
|
Platform Administration
|
|
</Text>
|
|
<NavLink
|
|
label="Admin Panel"
|
|
leftSection={<IconCrown size={18} />}
|
|
active={location.pathname === '/admin'}
|
|
onClick={() => go('/admin')}
|
|
color="red"
|
|
/>
|
|
{organizations && organizations.length > 0 && (
|
|
<>
|
|
<Divider my="sm" />
|
|
<NavLink
|
|
label="Switch to Tenant"
|
|
leftSection={<IconBuildingBank size={18} />}
|
|
onClick={() => go('/select-org')}
|
|
variant="subtle"
|
|
/>
|
|
</>
|
|
)}
|
|
</ScrollArea>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<ScrollArea p="sm" data-tour="sidebar-nav">
|
|
{navSections.map((section, sIdx) => (
|
|
<div key={sIdx}>
|
|
{section.label && (
|
|
<>
|
|
{sIdx > 0 && <Divider my={6} />}
|
|
<Text size="xs" c="dimmed" fw={700} tt="uppercase" px="sm" pb={2} pt={sIdx > 0 ? 4 : 0}>
|
|
{section.label}
|
|
</Text>
|
|
</>
|
|
)}
|
|
{section.items.map((item: any) =>
|
|
item.children ? (
|
|
<NavLink
|
|
key={item.label}
|
|
label={item.label}
|
|
leftSection={<item.icon size={18} />}
|
|
defaultOpened={item.children.some((c: any) =>
|
|
location.pathname.startsWith(c.path),
|
|
)}
|
|
data-tour={item.tourId || undefined}
|
|
>
|
|
{item.children.map((child: any) => (
|
|
<NavLink
|
|
key={child.path}
|
|
label={child.label}
|
|
active={location.pathname === child.path}
|
|
onClick={() => go(child.path)}
|
|
/>
|
|
))}
|
|
</NavLink>
|
|
) : (
|
|
<NavLink
|
|
key={item.path}
|
|
label={item.label}
|
|
leftSection={<item.icon size={18} />}
|
|
active={location.pathname === item.path}
|
|
onClick={() => go(item.path!)}
|
|
data-tour={item.tourId || undefined}
|
|
/>
|
|
),
|
|
)}
|
|
</div>
|
|
))}
|
|
|
|
{user?.isSuperadmin && (
|
|
<>
|
|
<Divider my="sm" />
|
|
<Text size="xs" c="dimmed" fw={700} tt="uppercase" px="sm" pb={4}>
|
|
Platform Admin
|
|
</Text>
|
|
<NavLink
|
|
label="Admin Panel"
|
|
leftSection={<IconCrown size={18} />}
|
|
active={location.pathname === '/admin'}
|
|
onClick={() => go('/admin')}
|
|
color="red"
|
|
/>
|
|
</>
|
|
)}
|
|
</ScrollArea>
|
|
);
|
|
}
|