Surgical fixes for the 7 UAT blockers that prevent productive forward
testing. Each item has a corresponding entry in alpha-uat-master.md.
- supplemental-info route relocated out of (portal) so it bypasses the
isPortalDisabledGlobally() kill-switch. URL unchanged.
- file upload service derives client_id/company_id/yacht_id from
(entityType, entityId) when not explicitly passed, so interest-tab
uploads no longer land with client_id=NULL and stay visible in the
Attachments list.
- triggerBlobDownload / triggerUrlDownload helpers in src/lib/utils
attach the anchor to the DOM before click so Chromium honours the
download attribute; 7 sites refactored, file-named downloads stop
arriving as bare UUIDs.
- search-nav-catalog dedupes by href at the result-collection layer so
the same href can no longer surface twice in the command-K dropdown
(kills the React duplicate-key warning); /admin/templates entries
merged into a single richer-keyword variant.
- NotesList gains a parentInvalidateKey prop, wired through all five
callers (interest, client, yacht, company, residential client/
interest) so the Overview "Latest note" teaser refreshes when a note
is added in the Notes tab.
- expense-form-dialog: setValue('receiptFileIds') / setValue(
'noReceiptAcknowledged') on upload/clear/checkbox so the schema-level
refine sees the field and Create stops silently no-op'ing on submit.
- bulk-add-berths-wizard: side-pontoon dropdown now reads through
useVocabulary('berth_side_pontoon_options') instead of a wrong local
enum ('Port', 'Starboard', 'Bow', 'Stern') — wizard data now matches
the rest of the platform + honours admin-editable per-port overrides.
tsc clean. 1419/1419 vitest. lint clean on touched files.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
160 lines
4.6 KiB
TypeScript
160 lines
4.6 KiB
TypeScript
'use client';
|
|
|
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
|
|
import type { DetailTab } from '@/components/shared/detail-layout';
|
|
import { InlineEditableField } from '@/components/shared/inline-editable-field';
|
|
import { NotesList } from '@/components/shared/notes-list';
|
|
import { EntityActivityFeed } from '@/components/shared/entity-activity-feed';
|
|
import { apiFetch } from '@/lib/api/client';
|
|
import { SOURCES } from '@/lib/constants';
|
|
|
|
interface ResidentialInterest {
|
|
id: string;
|
|
residentialClientId: string;
|
|
pipelineStage: string;
|
|
source: string | null;
|
|
notes: string | null;
|
|
preferences: string | null;
|
|
assignedTo: string | null;
|
|
}
|
|
|
|
interface Args {
|
|
interestId: string;
|
|
interest: ResidentialInterest;
|
|
currentUserId?: string;
|
|
stageOptions: Array<{ value: string; label: string }>;
|
|
}
|
|
|
|
const SOURCE_OPTIONS = SOURCES.map((s) => ({ value: s.value, label: s.label }));
|
|
|
|
function Row({ label, children }: { label: string; children: React.ReactNode }) {
|
|
return (
|
|
<div className="flex gap-2 py-1.5 border-b last:border-0 items-center">
|
|
<dt className="w-44 shrink-0 text-sm text-muted-foreground">{label}</dt>
|
|
<dd className="flex-1 min-w-0">{children}</dd>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function getResidentialInterestTabs({
|
|
interestId,
|
|
interest,
|
|
currentUserId,
|
|
stageOptions,
|
|
}: Args): DetailTab[] {
|
|
return [
|
|
{
|
|
id: 'overview',
|
|
label: 'Overview',
|
|
content: (
|
|
<OverviewTab interestId={interestId} interest={interest} stageOptions={stageOptions} />
|
|
),
|
|
},
|
|
{
|
|
id: 'notes',
|
|
label: 'Notes',
|
|
content: (
|
|
<NotesList
|
|
entityType="residential_interests"
|
|
entityId={interestId}
|
|
currentUserId={currentUserId}
|
|
parentInvalidateKey={['residential-interest', interestId]}
|
|
/>
|
|
),
|
|
},
|
|
{
|
|
id: 'activity',
|
|
label: 'Activity',
|
|
content: (
|
|
<EntityActivityFeed
|
|
endpoint={`/api/v1/residential/interests/${interestId}/activity`}
|
|
emptyText="No activity recorded for this residential interest yet."
|
|
/>
|
|
),
|
|
},
|
|
];
|
|
}
|
|
|
|
function useInterestPatch(interestId: string) {
|
|
const qc = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (patch: Record<string, unknown>) =>
|
|
apiFetch(`/api/v1/residential/interests/${interestId}`, { method: 'PATCH', body: patch }),
|
|
onSuccess: () => qc.invalidateQueries({ queryKey: ['residential-interest', interestId] }),
|
|
});
|
|
}
|
|
|
|
function OverviewTab({
|
|
interestId,
|
|
interest,
|
|
stageOptions,
|
|
}: {
|
|
interestId: string;
|
|
interest: ResidentialInterest;
|
|
stageOptions: Array<{ value: string; label: string }>;
|
|
}) {
|
|
const update = useInterestPatch(interestId);
|
|
const save = (field: string) => async (next: string | null) => {
|
|
await update.mutateAsync({ [field]: next });
|
|
};
|
|
|
|
// Pull users with residential access for the Assigned-to dropdown.
|
|
const { data: assignableUsers } = useQuery<{
|
|
data: Array<{ id: string; name: string; email: string }>;
|
|
}>({
|
|
queryKey: ['residential-assignable-users'],
|
|
queryFn: () => apiFetch('/api/v1/residential/assignable-users'),
|
|
});
|
|
const assigneeOptions = (assignableUsers?.data ?? []).map((u) => ({
|
|
value: u.id,
|
|
label: u.name || u.email,
|
|
}));
|
|
|
|
return (
|
|
<div className="rounded-lg border bg-card p-6 space-y-6">
|
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
<div className="space-y-1">
|
|
<h3 className="text-sm font-medium mb-2">Pipeline</h3>
|
|
<Row label="Stage">
|
|
<InlineEditableField
|
|
variant="select"
|
|
options={stageOptions}
|
|
value={interest.pipelineStage}
|
|
onSave={save('pipelineStage')}
|
|
/>
|
|
</Row>
|
|
<Row label="Source">
|
|
<InlineEditableField
|
|
variant="select"
|
|
options={SOURCE_OPTIONS}
|
|
value={interest.source}
|
|
onSave={save('source')}
|
|
/>
|
|
</Row>
|
|
<Row label="Assigned to">
|
|
<InlineEditableField
|
|
variant="select"
|
|
options={assigneeOptions}
|
|
value={interest.assignedTo}
|
|
onSave={save('assignedTo')}
|
|
placeholder="Unassigned"
|
|
/>
|
|
</Row>
|
|
</div>
|
|
|
|
<div className="space-y-1">
|
|
<h3 className="text-sm font-medium mb-2">Details</h3>
|
|
<Row label="Preferences">
|
|
<InlineEditableField
|
|
variant="textarea"
|
|
value={interest.preferences}
|
|
onSave={save('preferences')}
|
|
/>
|
|
</Row>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|