mirror of
https://github.com/Mail-0/Zero.git
synced 2026-06-30 15:56:59 +00:00
16 lines
464 B
TypeScript
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;
|
|
};
|