2026-05-05 03:05:22 +02:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
|
|
import { Eye, EyeOff, Loader2 } from 'lucide-react';
|
|
|
|
|
|
|
|
|
|
import { Button } from '@/components/ui/button';
|
|
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogDescription,
|
|
|
|
|
DialogFooter,
|
|
|
|
|
DialogHeader,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
} from '@/components/ui/dialog';
|
|
|
|
|
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
|
|
|
|
|
import { Label } from '@/components/ui/label';
|
|
|
|
|
import { apiFetch } from '@/lib/api/client';
|
|
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
|
|
|
|
|
interface AddBerthToInterestDialogProps {
|
|
|
|
|
interestId: string;
|
|
|
|
|
berth: { berthId: string; mooringNumber: string };
|
|
|
|
|
open: boolean;
|
|
|
|
|
onOpenChange: (open: boolean) => void;
|
|
|
|
|
onAdded?: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type RoleChoice = 'specific' | 'exploring';
|
|
|
|
|
|
|
|
|
|
export function AddBerthToInterestDialog({
|
|
|
|
|
interestId,
|
|
|
|
|
berth,
|
|
|
|
|
open,
|
|
|
|
|
onOpenChange,
|
|
|
|
|
onAdded,
|
|
|
|
|
}: AddBerthToInterestDialogProps) {
|
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
|
const [choice, setChoice] = useState<RoleChoice>('specific');
|
|
|
|
|
|
|
|
|
|
const mutation = useMutation({
|
|
|
|
|
mutationFn: async (isSpecificInterest: boolean) =>
|
|
|
|
|
apiFetch(`/api/v1/interests/${interestId}/berths`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: { berthId: berth.berthId, isSpecificInterest },
|
|
|
|
|
}),
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
// Invalidate the recommender cache + linked-berths cache so both
|
|
|
|
|
// surfaces re-fetch immediately. (See plan §5.3 / §5.5.)
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ['berth-recommendations', interestId] });
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ['interest-berths', interestId] });
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ['interests', interestId] });
|
|
|
|
|
onAdded?.();
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const handleSubmit = () => {
|
|
|
|
|
mutation.mutate(choice === 'specific');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle>Add berth {berth.mooringNumber} to interest</DialogTitle>
|
|
|
|
|
<DialogDescription>
|
|
|
|
|
Choose how this berth relates to the deal. This drives whether it shows as “Under
|
|
|
|
|
Offer” on the public map.
|
|
|
|
|
</DialogDescription>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
|
|
|
|
|
<RadioGroup
|
|
|
|
|
value={choice}
|
|
|
|
|
onValueChange={(v) => setChoice(v as RoleChoice)}
|
|
|
|
|
className="gap-3"
|
|
|
|
|
>
|
|
|
|
|
<RoleCard
|
|
|
|
|
value="specific"
|
|
|
|
|
checked={choice === 'specific'}
|
|
|
|
|
title="Pitching specifically"
|
|
|
|
|
description="The client is pitched on this exact berth."
|
|
|
|
|
consequence="This berth will appear as under interest on the public map."
|
fix(audit-wave-10): aria-hidden sweep on decorative Lucide icons (#69)
Mechanical codemod added \`aria-hidden\` to 444 self-closing single-line
Lucide icon JSX elements across 267 .tsx files in:
- shared/, layout/, dashboard/
- admin/ (all sections)
- clients/, berths/, yachts/, companies/, interests/, documents/
- reminders/, reservations/, residential/, expenses/, email/
The regex targeted only the safe pattern \`<IconName className="..." />\`
(no other props, self-closing, capitalized component name). Every match
inspected is a decorative companion to visible text or sits inside a
button whose accessible name comes from \`aria-label\` / sr-only text
— the icon itself should not be announced.
Screen readers no longer double-read the icon + the adjacent label
text (e.g. "Pencil Pencil Edit" → just "Edit"). The existing
@axe-core/playwright smoke test (\`20-accessibility.spec.ts\`) continues
to pass.
Test suite stays at 1315/1315 vitest. typescript clean.
Closes task #69 (aria-hidden sweep) from the AUDIT-2026-05-12 follow-ups
backlog.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 12:37:22 +02:00
|
|
|
icon={<Eye className="size-4" aria-hidden />}
|
2026-05-05 03:05:22 +02:00
|
|
|
/>
|
|
|
|
|
<RoleCard
|
|
|
|
|
value="exploring"
|
|
|
|
|
checked={choice === 'exploring'}
|
|
|
|
|
title="Just exploring"
|
|
|
|
|
description="The berth is being considered or covered by the EOI bundle, but not pitched specifically."
|
feat(pipeline): 9→7 stage refactor + v1.1 hardening wave
Replaces the legacy 9-stage pipeline with 7 canonical stages
(enquiry → qualified → eoi → reservation → deposit_paid → contract →
nurturing) plus three doc sub-status columns (eoi_doc_status,
reservation_doc_status, contract_doc_status) that track sent/signed
within a single stage instead of branching it.
Schema (migration 0062):
- interests gains assigned_to, deposit_expected_amount/currency,
three doc-status columns, two documenso-id columns, and
date_reservation_signed.
- New tables: qualification_criteria (per-port admin-configurable),
interest_qualifications (per-interest state), payments (deposit /
balance / refund records keyed to interest + client).
- Default qualification criteria seeded for every existing port.
- Dummy-data UPDATEs collapse Sent/Signed pairs and 'completed' into
the new stage + doc-status + outcome shape.
Migration 0063 adds interest_contact_log.voice_transcript and
template_used columns for v1.1-A/B (quick-template buttons + voice
transcription via Web Speech API).
v1.1 phase work bundled here:
- A/B: Quick-template buttons (Call / Visit / Email) + mic toggle on
the contact-log compose dialog (useVoiceTranscription hook).
- C: berth-rules-engine wraps state writes in pg_advisory_xact_lock
with an idempotent re-read; emits rule_evaluated audit traces.
- D: Documenso webhook: reservation/contract sub-status stamping
moved out of the PDF-download try-block so a download failure
no longer swallows the stamp. New integration test coverage.
- E: /admin/qualification-criteria CRUD page + admin component.
- F: default_new_interest_owner exposed in System Settings.
- G: recentActivityCount + active_engagement deal-pulse signal
surfaced as a chip on interests + hot-deals card.
- H: interest_assigned notification on assignedTo change (skips
self-assign, uses a dedupe key).
Plus the supporting components: AssignedToChip, DealPulseChip,
PaymentsSection, QualificationChecklist, MultiEoiChip,
SkipAheadBanner, WonStatusPanel, InterestBerthStatusBanner,
SupplementalInfoRequestButton, UserPicker.
Tests: 1370/1370 vitest pass (added deal-health unit suite +
expanded constants/validators/pipeline-transitions coverage). tsc
clean, eslint clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 03:39:21 +02:00
|
|
|
consequence="This berth stays marked “Available” on the public map — the link is internal only."
|
fix(audit-wave-10): aria-hidden sweep on decorative Lucide icons (#69)
Mechanical codemod added \`aria-hidden\` to 444 self-closing single-line
Lucide icon JSX elements across 267 .tsx files in:
- shared/, layout/, dashboard/
- admin/ (all sections)
- clients/, berths/, yachts/, companies/, interests/, documents/
- reminders/, reservations/, residential/, expenses/, email/
The regex targeted only the safe pattern \`<IconName className="..." />\`
(no other props, self-closing, capitalized component name). Every match
inspected is a decorative companion to visible text or sits inside a
button whose accessible name comes from \`aria-label\` / sr-only text
— the icon itself should not be announced.
Screen readers no longer double-read the icon + the adjacent label
text (e.g. "Pencil Pencil Edit" → just "Edit"). The existing
@axe-core/playwright smoke test (\`20-accessibility.spec.ts\`) continues
to pass.
Test suite stays at 1315/1315 vitest. typescript clean.
Closes task #69 (aria-hidden sweep) from the AUDIT-2026-05-12 follow-ups
backlog.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 12:37:22 +02:00
|
|
|
icon={<EyeOff className="size-4" aria-hidden />}
|
2026-05-05 03:05:22 +02:00
|
|
|
/>
|
|
|
|
|
</RadioGroup>
|
|
|
|
|
|
|
|
|
|
{mutation.isError ? (
|
|
|
|
|
<p className="text-sm text-destructive">
|
|
|
|
|
{(mutation.error as Error)?.message ?? 'Failed to add berth.'}
|
|
|
|
|
</p>
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
<DialogFooter>
|
|
|
|
|
<Button
|
|
|
|
|
type="button"
|
|
|
|
|
variant="outline"
|
|
|
|
|
onClick={() => onOpenChange(false)}
|
|
|
|
|
disabled={mutation.isPending}
|
|
|
|
|
>
|
|
|
|
|
Cancel
|
|
|
|
|
</Button>
|
|
|
|
|
<Button type="button" onClick={handleSubmit} disabled={mutation.isPending}>
|
fix(audit-wave-10): aria-hidden sweep on decorative Lucide icons (#69)
Mechanical codemod added \`aria-hidden\` to 444 self-closing single-line
Lucide icon JSX elements across 267 .tsx files in:
- shared/, layout/, dashboard/
- admin/ (all sections)
- clients/, berths/, yachts/, companies/, interests/, documents/
- reminders/, reservations/, residential/, expenses/, email/
The regex targeted only the safe pattern \`<IconName className="..." />\`
(no other props, self-closing, capitalized component name). Every match
inspected is a decorative companion to visible text or sits inside a
button whose accessible name comes from \`aria-label\` / sr-only text
— the icon itself should not be announced.
Screen readers no longer double-read the icon + the adjacent label
text (e.g. "Pencil Pencil Edit" → just "Edit"). The existing
@axe-core/playwright smoke test (\`20-accessibility.spec.ts\`) continues
to pass.
Test suite stays at 1315/1315 vitest. typescript clean.
Closes task #69 (aria-hidden sweep) from the AUDIT-2026-05-12 follow-ups
backlog.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 12:37:22 +02:00
|
|
|
{mutation.isPending ? (
|
|
|
|
|
<Loader2 className="mr-1.5 size-3.5 animate-spin" aria-hidden />
|
|
|
|
|
) : null}
|
2026-05-05 03:05:22 +02:00
|
|
|
Add berth to interest
|
|
|
|
|
</Button>
|
|
|
|
|
</DialogFooter>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface RoleCardProps {
|
|
|
|
|
value: RoleChoice;
|
|
|
|
|
checked: boolean;
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
|
|
|
|
consequence: string;
|
|
|
|
|
icon: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function RoleCard({ value, checked, title, description, consequence, icon }: RoleCardProps) {
|
|
|
|
|
return (
|
|
|
|
|
<Label
|
|
|
|
|
htmlFor={`role-${value}`}
|
|
|
|
|
className={cn(
|
|
|
|
|
'flex cursor-pointer items-start gap-3 rounded-lg border p-3 transition-colors',
|
|
|
|
|
checked ? 'border-brand-300 bg-brand-50/50 ring-1 ring-brand-200' : 'border-border',
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<RadioGroupItem value={value} id={`role-${value}`} className="mt-1" />
|
|
|
|
|
<div className="flex-1 space-y-1">
|
|
|
|
|
<div className="flex items-center gap-1.5 text-sm font-semibold">
|
|
|
|
|
{icon}
|
|
|
|
|
{title}
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground">{description}</p>
|
|
|
|
|
<p className="text-xs font-medium text-foreground/80">{consequence}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</Label>
|
|
|
|
|
);
|
|
|
|
|
}
|