{contacts.map((contact) => {
const isVisible = computed(() =>
matchesSearch(contact, searchQuery.get())
);
const contactRelations = computed(() => {
const name = contact.name;
return relationships
.get()
.filter(
(r: Relationship) =>
r.fromName === name || r.toName === name,
);
});
return ifElse(
isVisible,
{
const detail = ContactDetail({ contact });
return navigateTo(detail);
}}
>
{contact.name || "(unnamed)"}
{contact.email && (
{contact.email}
)}
{contact.company && (
{contact.company}
)}
{/* Show relationships */}
{contactRelations.map((rel: Relationship) => (
↔ {rel.fromName === contact.name
? rel.toName
: rel.fromName}
{rel.label && ({rel.label})}
))}
{
const current = contacts.get();
const idx = current.findIndex((c) =>
Cell.equals(contact, c)
);
if (idx >= 0) {
contacts.set(current.toSpliced(idx, 1));
}
}}
>
×
,
null,
);
})}
{ifElse(
computed(() => contacts.get().length === 0),
No contacts yet. Add one below!
,
null,
)}