Files
pn-new-crm/src/components/residential/residential-interests-list.tsx

328 lines
11 KiB
TypeScript
Raw Normal View History

feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
'use client';
import { useState } from 'react';
feat(uat-batch): Group A quick-fixes — 7 items shipped, 5 verified pre-shipped Sweeps Group A of the 2026-05-21 remaining-plan. Several items the plan listed as open turned out to already be shipped (annotation gap in the master doc) — those are confirmed in the commit notes. Shipped now: A1 Documenso settings: collapsed `V2_FEATURE_FIELDS` + `CONTRACT_RESERVATION_FIELDS` (legacy SettingsFormCard) into `RegistryDrivenForm` sections (`documenso.behavior` + `documenso.templates`). Every Documenso setting now flows through the registry path that surfaces the env-fallback / port / global source badge per field. EOI generation card retitled to "Templates & signing pathway" since it now covers EOI + reservation + contract template IDs (registry already had all three under `documenso.templates`). A2 WatchersCard empty state: bumped `mb-3 → mb-4 pb-1` so the "No one is watching yet" line has breathing room above the "Add a watcher…" select. A4 /invoices/upload-receipts guide copy: terse luxury-CRM tone. Drop "Snap a photo", "fancy phone camera", "No typing. No spreadsheets." Tighten OCR explainer to one sentence; action-oriented step + best-practices headers. A5 Pageviews chart X-axis: added `interval="preserveStartEnd"` + `minTickGap={52}` so multi-week ranges thin out the middle ticks instead of overlapping. The MM-DD formatter was already in place from an earlier session. A7 Inbox doc comment: was stale ("Alerts first, Reminders second") but the JSX already had Reminders before Alerts. Fixed the docstring. A9 CommandList scroll-cap: `max-h-[300px]` now `max-h-[min(300px, var(--radix-popover-content-available-height,300px))]` so the cmdk list never extends past the host Popover's available area. Non-Popover hosts fall through to the 300px static cap. A10 DropdownMenuContent: `max-h-96` now `max-h-[min(24rem,var(--radix-dropdown-menu-content- available-height,24rem))]` for the same available-space behaviour on long menus near the viewport edge. A11 Residential InterestsTab (list page): row gets an onClick → `router.push`; first-cell Link stops propagation so middle- click / Cmd-click "open in new tab" still works. A12 StageStepper: gained a stage-name row below the bar showing every reached stage's short label inline (muted for future stages). `size="xs"` variant keeps the cramped table-cell footprint intact (no labels). Already shipped (just annotation gap in master doc): A3 EOI "Mark as signed without file" button — line 599 of interest-eoi-tab.tsx, parent passes onMarkSigned. Master doc already has `SHIPPED in 52342ee` annotation. A6 Pageviews vs Sessions explainer — Info popover at line 157-181 of website-analytics-shell.tsx. A8 BulkAddBerthsWizard CurrencySelect — line 376 (apply-to-all) + line 456 (per-row). Verified: tsc clean, vitest 1454/1454. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 21:34:20 +02:00
import { useParams, useRouter } from 'next/navigation';
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { Archive, ArrowRight, LayoutList, Plus } from 'lucide-react';
import { toast } from 'sonner';
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
import { Button } from '@/components/ui/button';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
import { ColumnPicker } from '@/components/shared/column-picker';
import { DataTable } from '@/components/shared/data-table';
import { EmptyState } from '@/components/shared/empty-state';
import { FilterBar } from '@/components/shared/filter-bar';
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
import { PageHeader } from '@/components/shared/page-header';
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
import { SaveViewDialog } from '@/components/shared/save-view-dialog';
import { SavedViewsDropdown } from '@/components/shared/saved-views-dropdown';
import { TableSkeleton } from '@/components/shared/loading-skeleton';
import { useConfirmation } from '@/hooks/use-confirmation';
import { usePaginatedQuery } from '@/hooks/use-paginated-query';
import { usePermissions } from '@/hooks/use-permissions';
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
import { useRealtimeInvalidation } from '@/hooks/use-realtime-invalidation';
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
import { useTablePreferences } from '@/hooks/use-table-preferences';
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
import { apiFetch } from '@/lib/api/client';
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
import { ResidentialInterestCard } from './residential-interest-card';
import {
getResidentialInterestColumns,
RESIDENTIAL_INTEREST_COLUMN_OPTIONS,
RESIDENTIAL_INTEREST_DEFAULT_HIDDEN,
type ResidentialInterestRow,
} from './residential-interest-columns';
import {
DEFAULT_RESIDENTIAL_PIPELINE_STAGES,
RESIDENTIAL_STAGE_LABELS,
residentialInterestFilterDefinitions,
} from './residential-interest-filters';
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
/**
* Residential interests list parity with the main InterestList. Wires
* the same DataTable + FilterBar + ColumnPicker + SavedViews + bulkActions
* stack onto the /api/v1/residential/interests endpoint. Kanban view is
* intentionally omitted (the residential pipeline stages differ and the
* board layout isn't yet wired through for them opens as a follow-up).
*/
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
export function ResidentialInterestsList() {
const params = useParams<{ portSlug: string }>();
feat(uat-batch): Group A quick-fixes — 7 items shipped, 5 verified pre-shipped Sweeps Group A of the 2026-05-21 remaining-plan. Several items the plan listed as open turned out to already be shipped (annotation gap in the master doc) — those are confirmed in the commit notes. Shipped now: A1 Documenso settings: collapsed `V2_FEATURE_FIELDS` + `CONTRACT_RESERVATION_FIELDS` (legacy SettingsFormCard) into `RegistryDrivenForm` sections (`documenso.behavior` + `documenso.templates`). Every Documenso setting now flows through the registry path that surfaces the env-fallback / port / global source badge per field. EOI generation card retitled to "Templates & signing pathway" since it now covers EOI + reservation + contract template IDs (registry already had all three under `documenso.templates`). A2 WatchersCard empty state: bumped `mb-3 → mb-4 pb-1` so the "No one is watching yet" line has breathing room above the "Add a watcher…" select. A4 /invoices/upload-receipts guide copy: terse luxury-CRM tone. Drop "Snap a photo", "fancy phone camera", "No typing. No spreadsheets." Tighten OCR explainer to one sentence; action-oriented step + best-practices headers. A5 Pageviews chart X-axis: added `interval="preserveStartEnd"` + `minTickGap={52}` so multi-week ranges thin out the middle ticks instead of overlapping. The MM-DD formatter was already in place from an earlier session. A7 Inbox doc comment: was stale ("Alerts first, Reminders second") but the JSX already had Reminders before Alerts. Fixed the docstring. A9 CommandList scroll-cap: `max-h-[300px]` now `max-h-[min(300px, var(--radix-popover-content-available-height,300px))]` so the cmdk list never extends past the host Popover's available area. Non-Popover hosts fall through to the 300px static cap. A10 DropdownMenuContent: `max-h-96` now `max-h-[min(24rem,var(--radix-dropdown-menu-content- available-height,24rem))]` for the same available-space behaviour on long menus near the viewport edge. A11 Residential InterestsTab (list page): row gets an onClick → `router.push`; first-cell Link stops propagation so middle- click / Cmd-click "open in new tab" still works. A12 StageStepper: gained a stage-name row below the bar showing every reached stage's short label inline (muted for future stages). `size="xs"` variant keeps the cramped table-cell footprint intact (no labels). Already shipped (just annotation gap in master doc): A3 EOI "Mark as signed without file" button — line 599 of interest-eoi-tab.tsx, parent passes onMarkSigned. Master doc already has `SHIPPED in 52342ee` annotation. A6 Pageviews vs Sessions explainer — Info popover at line 157-181 of website-analytics-shell.tsx. A8 BulkAddBerthsWizard CurrencySelect — line 376 (apply-to-all) + line 456 (per-row). Verified: tsc clean, vitest 1454/1454. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 21:34:20 +02:00
const router = useRouter();
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
const portSlug = params?.portSlug ?? '';
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
const queryClient = useQueryClient();
const { confirm, dialog: confirmDialog } = useConfirmation();
const { can } = usePermissions();
const [saveViewOpen, setSaveViewOpen] = useState(false);
// Bulk-action dialog state — same shape as the main InterestList so
// the inner controls feel identical.
const [stageDialog, setStageDialog] = useState<{ ids: string[] } | null>(null);
const [stageChoice, setStageChoice] = useState<string>(
DEFAULT_RESIDENTIAL_PIPELINE_STAGES[0] ?? 'new',
);
const {
data,
pagination,
isLoading,
isFetching,
sort,
setSort,
setPage,
setPageSize,
filters,
setFilter,
setAllFilters,
clearFilters,
} = usePaginatedQuery<ResidentialInterestRow>({
queryKey: ['residential-interests'],
endpoint: '/api/v1/residential/interests',
filterDefinitions: residentialInterestFilterDefinitions,
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
});
useRealtimeInvalidation({
'residential_interest:created': [['residential-interests']],
'residential_interest:updated': [['residential-interests']],
'residential_interest:archived': [['residential-interests']],
});
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
// Mirror the main list's two-mutation idiom — per-row archive when the
// rep uses the kebab on a single row, bulk endpoint when they tick the
// checkbox in the header.
const archiveMutation = useMutation({
mutationFn: (id: string) =>
apiFetch(`/api/v1/residential/interests/${id}`, { method: 'DELETE' }),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: ['residential-interests'] });
},
});
const bulkMutation = useMutation({
mutationFn: async (
payload:
| { action: 'archive'; ids: string[] }
| { action: 'change_stage'; ids: string[]; pipelineStage: string },
) =>
apiFetch<{
data: { summary: { total: number; succeeded: number; failed: number } };
}>('/api/v1/residential/interests/bulk', { method: 'POST', body: payload }),
onSuccess: (res) => {
void queryClient.invalidateQueries({ queryKey: ['residential-interests'] });
const s = res.data.summary;
if (s.failed > 0) {
toast.warning(
`${s.succeeded} of ${s.total} succeeded. ${s.failed} failed — check the activity log.`,
);
} else {
toast.success(`Updated ${s.succeeded} interest${s.succeeded === 1 ? '' : 's'}`);
}
},
});
const columns = getResidentialInterestColumns({
portSlug,
onArchive: async (interest) => {
const ok = await confirm({
title: 'Archive interest',
description: 'This can be undone from the archived list.',
confirmLabel: 'Archive',
});
if (!ok) return;
archiveMutation.mutate(interest.id);
},
});
// Persisted per-user column visibility + density.
const { hidden, setHidden, density } = useTablePreferences(
'residential_interests',
RESIDENTIAL_INTEREST_DEFAULT_HIDDEN,
);
const columnVisibility = Object.fromEntries(hidden.map((id) => [id, false]));
// Stages enum is set at module load — no runtime invariant to enforce.
// (Earlier draft had a useEffect resetting `stageChoice` if it fell
// out of the enum; React Compiler flags setState-in-effect, so we
// rely on the dropdown's controlled value to enforce validity.)
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
return (
<div className="space-y-4">
<PageHeader
title="Residential Interests"
description="Inquiries flowing through the residential pipeline"
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
variant="gradient"
actions={
<div className="flex items-center gap-2">
<div
className="hidden sm:flex items-center border rounded-md overflow-hidden"
role="group"
aria-label="View mode"
>
<Button
size="sm"
variant="default"
className="rounded-none"
aria-label="Table view"
aria-pressed
disabled
>
<LayoutList className="h-4 w-4" aria-hidden />
</Button>
</div>
</div>
}
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
/>
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
<div className="flex flex-wrap items-center gap-2">
<FilterBar
filters={residentialInterestFilterDefinitions}
values={filters}
onChange={setFilter}
onClear={clearFilters}
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
/>
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
<div className="ml-auto flex flex-wrap items-center gap-2">
<SavedViewsDropdown
entityType="residential_interests"
onApplyView={(savedFilters) => setAllFilters(savedFilters)}
/>
<ColumnPicker
columns={RESIDENTIAL_INTEREST_COLUMN_OPTIONS}
hidden={hidden}
onChange={setHidden}
onSaveView={() => setSaveViewOpen(true)}
/>
</div>
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
</div>
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
<SaveViewDialog
open={saveViewOpen}
onOpenChange={setSaveViewOpen}
entityType="residential_interests"
currentFilters={filters}
currentSort={sort}
/>
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
{isLoading ? (
<TableSkeleton />
) : (
<DataTable
columns={columns}
columnVisibility={columnVisibility}
density={density}
data={data}
pagination={pagination}
onPaginationChange={(p, ps) => {
setPage(p);
setPageSize(ps);
}}
sort={sort}
onSortChange={setSort}
isLoading={isFetching && !isLoading}
getRowId={(row) => row.id}
onRowClick={(row) => router.push(`/${portSlug}/residential/interests/${row.id}` as never)}
bulkActions={
can('residential_interests', 'edit')
? [
{
label: 'Change stage',
icon: ArrowRight,
onClick: (ids) => {
if (ids.length === 0) return;
setStageChoice(DEFAULT_RESIDENTIAL_PIPELINE_STAGES[0] ?? 'new');
setStageDialog({ ids });
},
},
...(can('residential_interests', 'delete')
? [
{
label: 'Archive',
icon: Archive,
variant: 'destructive' as const,
onClick: async (ids: string[]) => {
if (ids.length === 0) return;
const ok = await confirm({
title: `Archive ${ids.length} interest${ids.length === 1 ? '' : 's'}`,
description: 'This can be undone from the archived list.',
confirmLabel: 'Archive',
});
if (!ok) return;
bulkMutation.mutate({ action: 'archive', ids });
},
},
]
: []),
]
: undefined
}
cardRender={(row) => (
<ResidentialInterestCard interest={row.original} portSlug={portSlug} />
)}
emptyState={
<EmptyState
title="No residential interests"
description="Inquiries will appear here once the website intake fires or a rep creates one manually."
icon={Plus}
/>
}
/>
)}
{/* Bulk: change stage */}
<Dialog open={!!stageDialog} onOpenChange={(o) => !o && setStageDialog(null)}>
<DialogContent>
<DialogHeader>
<DialogTitle>Change stage</DialogTitle>
<DialogDescription>
Move {stageDialog?.ids.length ?? 0} interest
{stageDialog?.ids.length === 1 ? '' : 's'} to a new pipeline stage.
</DialogDescription>
</DialogHeader>
<div className="py-2">
<Select value={stageChoice} onValueChange={setStageChoice}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
{DEFAULT_RESIDENTIAL_PIPELINE_STAGES.map((s) => (
<SelectItem key={s} value={s}>
{RESIDENTIAL_STAGE_LABELS[s] ?? s}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
feat(uat-batch): Group I — Residential parity (4 ships) I34–I37 from the 2026-05-21 plan. Shipped: I34 Residential client header layout parity. Email / Call / WhatsApp action buttons mirror the main ClientDetailHeader. WhatsApp number resolves from phoneE164 (preferred) or strips the free-text phone to digits. Header surfaces "Linked to main client" chip when the auto-link matcher (I37) finds a counterpart in the main CRM. I35 Residential interests list rebuilt for parity with the main InterestList. New ResidentialInterestCard + getResidentialInterestColumns + residentialInterestFilter- Definitions; the list page drives DataTable + FilterBar + ColumnPicker + SavedViewsDropdown + bulkActions. List endpoint validator widened to accept pipelineStage as a string OR string[] and added a source filter. Service post- fetches client names via a single IN-list lookup so the table renders fullName in column 1 without N+1. New /api/v1/residential/interests/bulk supports change_stage + archive (100-id cap). Kanban view deferred. I36 Residential inquiries auto-forward to partner email(s). New registry entry residential_partner_recipients (comma- separated) under section residential.partner. createResidentialInterest fires forwardResidentialInquiryToPartner after the row lands. Helper uses the same branded shell other transactional emails use. Failures log + never block create. The /admin/residential-stages page picks up a registry-driven card so admins manage recipients alongside stages. I37 Auto-link residential ↔ main client. Migration 0080 adds residential_clients.linked_client_id (nullable FK, SET NULL on cascade) + partial index. New findAndLinkMatchingMainClient service matches by email first (case-insensitive client_contacts lookup) then by E.164 phone. First exact match wins. Fires fire-and-forget from createResidentialClient. Header surfaces the link via a "Linked to main client" chip. Backfill script + reverse-direction link from main ClientDetailHeader stay as follow-ups. Verified: tsc clean, vitest 1454/1454, migration applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:57:19 +02:00
<DialogFooter>
<Button variant="outline" onClick={() => setStageDialog(null)}>
Cancel
</Button>
<Button
disabled={bulkMutation.isPending}
onClick={() => {
if (!stageDialog) return;
bulkMutation.mutate(
{ action: 'change_stage', ids: stageDialog.ids, pipelineStage: stageChoice },
{ onSettled: () => setStageDialog(null) },
);
}}
>
Apply
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
{confirmDialog}
feat(platform): residential module + admin UI + reliability fixes 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>
2026-04-27 21:54:32 +02:00
</div>
);
}