Files
Zero/apps/mail/hooks/use-drafts.ts
2025-05-03 18:32:20 +05:30

16 lines
464 B
TypeScript

import { useTRPC } from '@/providers/query-provider';
import { useQuery } from '@tanstack/react-query';
import { useSession } from '@/lib/auth-client';
export const useDraft = (id: string | null) => {
const { data: session } = useSession();
const trpc = useTRPC();
const draftQuery = useQuery(
trpc.drafts.get.queryOptions(
{ id: id! },
{ enabled: !!session?.user.id && !!id, staleTime: 1000 * 60 * 60 },
),
);
return draftQuery;
};