feat: live client-side recipient filtering with match count, no reload needed

This commit is contained in:
lorentz 2026-04-01 08:08:59 -04:00
parent 672d8c52a6
commit 3cb312e6ec

View file

@ -788,9 +788,12 @@ function HeldMailTab() {
}
};
const filtered = policyFilter
? messages.filter(m => m.policyInfo?.toLowerCase().includes(policyFilter.toLowerCase()))
: messages;
const recipientLower = recipient.trim().toLowerCase();
const filtered = messages.filter(m => {
if (recipientLower && !m.to?.toLowerCase().includes(recipientLower) && !m.toDisplay?.toLowerCase().includes(recipientLower)) return false;
if (policyFilter && !m.policyInfo?.toLowerCase().includes(policyFilter.toLowerCase())) return false;
return true;
});
const policies = [...new Set(messages.map((m: any) => m.policyInfo).filter(Boolean))].sort();
const tenantInfo: any[] = data?.tenants ?? [];
@ -813,13 +816,17 @@ function HeldMailTab() {
</select>
</div>
<div className="flex-1 min-w-56">
<label className="text-xs text-muted-foreground mb-1 block">Recipient email</label>
<label className="text-xs text-muted-foreground mb-1 block">
Recipient email
{loaded && recipient.trim() && (
<span className="ml-1 text-muted-foreground/60">({filtered.length} match{filtered.length !== 1 ? 'es' : ''})</span>
)}
</label>
<input
type="text"
placeholder="filter by recipient…"
value={recipient}
onChange={e => setRecipient(e.target.value)}
onKeyDown={e => e.key === 'Enter' && load()}
className="w-full border rounded-md px-3 py-1.5 text-sm bg-background"
/>
</div>