feat: add attachment search view

This commit is contained in:
rustmailer
2026-04-19 01:01:46 +08:00
parent 19b5168960
commit 7dd722f9b8
96 changed files with 36331 additions and 28970 deletions
+26
View File
@@ -0,0 +1,26 @@
import { useMemo } from 'react';
import { useQuery } from '@tanstack/react-query';
import { get_attachment_senders } from '@/api/attachment/api';
export const userAttachmentSenders = (searchTerm: string = "") => {
const { data: senders = [], isLoading, isError } = useQuery({
queryKey: ['attachment-senders', 'all'],
queryFn: get_attachment_senders,
staleTime: 1000 * 60 * 10,
gcTime: 1000 * 60 * 30,
});
const filtered = useMemo(() => {
if (!searchTerm) return senders;
const lower = searchTerm.toLowerCase();
return senders.filter(email =>
email.toLowerCase().includes(lower)
);
}, [senders, searchTerm]);
return {
senders: filtered,
isLoading,
isError
};
};