| 1 | "use client"; |
| 2 | |
| 3 | import { useQuery } from "@tanstack/react-query"; |
| 4 | |
| 5 | import { |
| 6 | getPresentationOwner, |
| 7 | type PresentationOwnerProfile, |
| 8 | } from "@/app/_actions/notebook/presentation/presentationActions"; |
| 9 | |
| 10 | export function usePresentationOwner(presentationId: string | null) { |
| 11 | return useQuery<PresentationOwnerProfile | null>({ |
| 12 | queryKey: ["presentation-owner", presentationId], |
| 13 | queryFn: async () => { |
| 14 | if (!presentationId) { |
| 15 | return null; |
| 16 | } |
| 17 | |
| 18 | const result = await getPresentationOwner(presentationId); |
| 19 | |
| 20 | return result.success ? result.owner : null; |
| 21 | }, |
| 22 | enabled: Boolean(presentationId), |
| 23 | staleTime: Infinity, |
| 24 | }); |
| 25 | } |
| 26 |