fix: guard against undefined fields when loading old localStorage data
Old entries in localStorage lack new fields (department, role, contactPersons, linkedEntryIds, attachments, versions, placeholders, ipAddress, vendor, model). Add null-coalescing guards to prevent client-side crashes on property access. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -174,7 +174,7 @@ function ContactCard({ contact, onEdit, onDelete }: {
|
||||
<Globe className="h-3 w-3 shrink-0" /><span className="truncate">{contact.website}</span>
|
||||
</div>
|
||||
)}
|
||||
{contact.contactPersons.length > 0 && (
|
||||
{(contact.contactPersons ?? []).length > 0 && (
|
||||
<div className="mt-1 border-t pt-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1">
|
||||
Persoane de contact ({contact.contactPersons.length})
|
||||
|
||||
@@ -76,8 +76,8 @@ export function useContacts() {
|
||||
c.company.toLowerCase().includes(q) ||
|
||||
c.email.toLowerCase().includes(q) ||
|
||||
c.phone.includes(q) ||
|
||||
c.department.toLowerCase().includes(q) ||
|
||||
c.role.toLowerCase().includes(q)
|
||||
(c.department ?? '').toLowerCase().includes(q) ||
|
||||
(c.role ?? '').toLowerCase().includes(q)
|
||||
);
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user