import { useQuery } from '@tanstack/react-query'
import { sharing, type SharedHeap, type SharedFolder } from '../services/api'

export const SHARED_HEAPS_KEY = ['sharing', 'heaps'] as const
export const SHARED_FOLDERS_KEY = ['sharing', 'folders'] as const

export function useSharedHeapsQuery() {
  return useQuery<SharedHeap[]>({
    queryKey: SHARED_HEAPS_KEY,
    queryFn: sharing.sharedHeaps,
    staleTime: 30_000,
  })
}

export function useSharedFoldersQuery() {
  return useQuery<SharedFolder[]>({
    queryKey: SHARED_FOLDERS_KEY,
    queryFn: sharing.sharedFolders,
    staleTime: 30_000,
  })
}
