Residential platform - New schema: residentialClients, residentialInterests (separate from marina/yacht clients) with migration 0010 - Service layer with CRUD + audit + sockets + per-port portal toggle - v1 + public API routes (/api/v1/residential/*, /api/public/residential-inquiries) - List + detail pages with inline editing for clients and interests - Per-user residentialAccess toggle on userPortRoles (migration 0011) - Permission keys: residential_clients, residential_interests - Sidebar nav + role form integration - Smoke spec covering page loads, UI create flow, public endpoint Admin & shared UI - Admin → Forms (form templates CRUD) with validators + service - Notification preferences page (in-app + email per type) - Email composition + accounts list + threads view - Branded auth shell shared across CRM + portal auth surfaces - Inline editing extended to yacht/company/interest detail pages - InlineTagEditor + per-entity tags endpoints (yachts, companies) - Notes service polymorphic across clients/interests/yachts/companies - Client list columns: yachtCount + companyCount badges - Reservation file-download via presigned URL (replaces stale <a href>) Route handler refactor - Extracted yachts/companies/berths reservation handlers to sibling handlers.ts files (Next.js 15 route.ts only allows specific exports) Reliability fixes - apiFetch double-stringify bug fixed across 13 components (apiFetch already JSON.stringifies its body; passing a stringified body produced double-encoded JSON which failed zod validation) - SocketProvider gated behind useSyncExternalStore-based mount check to avoid useSession() SSR crashes under React 19 + Next 15 - apiFetch falls back to URL-pathname → port-id resolution when the Zustand store hasn't hydrated yet (fresh contexts, e2e tests) - CRM invite flow (schema, service, route, email, dev script) - Dashboard route → [portSlug]/dashboard/page.tsx + redirect - Document the dev-server restart-after-migration gotcha in CLAUDE.md Tests - 5-case residential smoke spec - Integration test updates for new service signatures Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
151 lines
5.7 KiB
TypeScript
151 lines
5.7 KiB
TypeScript
'use client';
|
|
|
|
import { Plus, Moon, Sun, LogOut, User, Settings, Bell } from 'lucide-react';
|
|
import { useRouter } from 'next/navigation';
|
|
|
|
import { useUIStore } from '@/stores/ui-store';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
|
import { Separator } from '@/components/ui/separator';
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from '@/components/ui/dropdown-menu';
|
|
import { PortSwitcher } from '@/components/layout/port-switcher';
|
|
import { Breadcrumbs } from '@/components/layout/breadcrumbs';
|
|
import { CommandSearch } from '@/components/search/command-search';
|
|
import { NotificationBell } from '@/components/notifications/notification-bell';
|
|
import type { Port } from '@/lib/db/schema/ports';
|
|
|
|
interface TopbarProps {
|
|
ports: Port[];
|
|
}
|
|
|
|
export function Topbar({ ports }: TopbarProps) {
|
|
const router = useRouter();
|
|
const currentPortSlug = useUIStore((s) => s.currentPortSlug);
|
|
const darkMode = useUIStore((s) => s.darkMode);
|
|
const toggleDarkMode = useUIStore((s) => s.toggleDarkMode);
|
|
|
|
const base = currentPortSlug ? `/${currentPortSlug}` : '';
|
|
|
|
function handleToggleDarkMode() {
|
|
toggleDarkMode();
|
|
document.documentElement.classList.toggle('dark');
|
|
}
|
|
|
|
return (
|
|
<header className="h-14 border-b border-border bg-background flex items-center gap-3 px-4 shrink-0">
|
|
{/* Breadcrumbs / page title */}
|
|
<div className="flex-1 min-w-0">
|
|
<Breadcrumbs />
|
|
</div>
|
|
|
|
{/* Actions row */}
|
|
<div className="flex items-center gap-2 shrink-0">
|
|
{/* Global search — inline with dropdown results */}
|
|
<CommandSearch />
|
|
|
|
{/* Port switcher — hidden for single port */}
|
|
<PortSwitcher ports={ports} />
|
|
|
|
{/* + New dropdown */}
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button size="sm" className="bg-brand hover:bg-brand-500 text-white gap-1.5">
|
|
<Plus className="w-4 h-4" />
|
|
<span className="hidden sm:inline">New</span>
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-44">
|
|
<DropdownMenuLabel className="text-xs text-muted-foreground">Create</DropdownMenuLabel>
|
|
<DropdownMenuSeparator />
|
|
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
|
|
<DropdownMenuItem onClick={() => router.push(`${base}/clients/new` as any)}>
|
|
New Client
|
|
</DropdownMenuItem>
|
|
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
|
|
<DropdownMenuItem onClick={() => router.push(`${base}/interests/new` as any)}>
|
|
New Interest
|
|
</DropdownMenuItem>
|
|
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
|
|
<DropdownMenuItem onClick={() => router.push(`${base}/expenses/new` as any)}>
|
|
New Expense
|
|
</DropdownMenuItem>
|
|
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
|
|
<DropdownMenuItem onClick={() => router.push(`${base}/reminders/new` as any)}>
|
|
New Reminder
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
|
|
{/* Notification bell — real-time via socket */}
|
|
<NotificationBell />
|
|
|
|
<Separator orientation="vertical" className="h-6" />
|
|
|
|
{/* User menu */}
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="ghost" size="icon" className="rounded-full">
|
|
<Avatar className="w-7 h-7">
|
|
<AvatarImage src={undefined} />
|
|
<AvatarFallback className="bg-brand text-white text-xs font-semibold">
|
|
U
|
|
</AvatarFallback>
|
|
</Avatar>
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-52">
|
|
<DropdownMenuLabel>My Account</DropdownMenuLabel>
|
|
<DropdownMenuSeparator />
|
|
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
|
|
<DropdownMenuItem onClick={() => router.push(`${base}/settings/profile` as any)}>
|
|
<User className="w-4 h-4 mr-2" />
|
|
Profile
|
|
</DropdownMenuItem>
|
|
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
|
|
<DropdownMenuItem onClick={() => router.push(`${base}/settings` as any)}>
|
|
<Settings className="w-4 h-4 mr-2" />
|
|
Settings
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
onClick={() => router.push(`${base}/notifications/preferences` as any)}
|
|
>
|
|
<Bell className="w-4 h-4 mr-2" />
|
|
Notification preferences
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem onClick={handleToggleDarkMode}>
|
|
{darkMode ? (
|
|
<>
|
|
<Sun className="w-4 h-4 mr-2" />
|
|
Light Mode
|
|
</>
|
|
) : (
|
|
<>
|
|
<Moon className="w-4 h-4 mr-2" />
|
|
Dark Mode
|
|
</>
|
|
)}
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem
|
|
className="text-destructive focus:text-destructive"
|
|
onClick={() => router.push('/api/auth/sign-out')}
|
|
>
|
|
<LogOut className="w-4 h-4 mr-2" />
|
|
Sign Out
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|