fix(registratura): remove parentheses from institution-only contacts, add live contact sync

- Fix display format: institutions without a person name no longer show
  as "(Company)" — now shows just "Company"
- Three-case formatting: name+company → "Name (Company)", only company
  → "Company", only name → "Name"
- Registry table now resolves sender/recipient live from address book
  via contactMap — edits in address book reflect immediately in registry
- New contacts created via quick-contact are added to contactMap on the fly

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-22 04:04:17 +02:00
parent a3ab539197
commit c8aee1b58e
3 changed files with 63 additions and 12 deletions
@@ -39,6 +39,19 @@ import { DEFAULT_DOC_TYPE_LABELS, EXTERNAL_STATUS_LABELS } from "../types";
import { getOverdueDays } from "../services/registry-service";
import { cn } from "@/shared/lib/utils";
/** Format a contact for display: "Name (Company)" / "Company" / "Name" */
function formatContactLabel(c: { name?: string; company?: string }): string {
const name = (c.name ?? "").trim();
const company = (c.company ?? "").trim();
if (name && company) return `${name} (${company})`;
return name || company || "";
}
interface ContactInfo {
name: string;
company: string;
}
interface RegistryTableProps {
entries: RegistryEntry[];
loading: boolean;
@@ -48,6 +61,8 @@ interface RegistryTableProps {
onClose: (entry: RegistryEntry) => void;
/** Create a new entry linked as reply (conex) to this entry */
onReply?: (entry: RegistryEntry) => void;
/** Live contact data map: contactId → { name, company } for live sync */
contactMap?: Map<string, ContactInfo>;
}
// ── Column definitions ──
@@ -185,6 +200,7 @@ export function RegistryTable({
onDelete,
onClose,
onReply,
contactMap,
}: RegistryTableProps) {
const [visibleCols, setVisibleCols] = useState<Set<ColumnId>>(
() => DEFAULT_VISIBLE,
@@ -416,16 +432,22 @@ export function RegistryTable({
)}
{visibleCols.has("sender") && (
<td className="px-3 py-2 max-w-[130px] truncate text-xs">
{entry.sender || (
<span className="text-muted-foreground"></span>
)}
{(() => {
const live = entry.senderContactId && contactMap?.get(entry.senderContactId);
return (live ? formatContactLabel(live) : entry.sender) || (
<span className="text-muted-foreground"></span>
);
})()}
</td>
)}
{visibleCols.has("recipient") && (
<td className="px-3 py-2 max-w-[130px] truncate text-xs">
{entry.recipient || (
<span className="text-muted-foreground"></span>
)}
{(() => {
const live = entry.recipientContactId && contactMap?.get(entry.recipientContactId);
return (live ? formatContactLabel(live) : entry.recipient) || (
<span className="text-muted-foreground"></span>
);
})()}
</td>
)}
{visibleCols.has("assignee") && (