import { useQuery } from "@tanstack/react-query";
import { getMyUploadById, getMyUploads } from "../services/portalOutgoingService";
import { FileInfo } from "@/shared/services/complaintService";

export interface Upload {
  id: string;
  documentId: string;
  createdAt: string; // ISO date string
  fileInfo: FileInfo; // refine if you know the shape
}


// Fetch list of uploads by userId
export const useMyUploads = () => {
  return useQuery<Upload[]>({
    queryKey: ["myUploads"],
    queryFn: getMyUploads,
  });
};


// Fetch single upload by documentId
export const useMyUploadById = (docId: string) => {
  return useQuery({
    queryKey: ["myUpload", docId],
    queryFn: () => getMyUploadById(docId).then((res) => res),
    enabled: !!docId,
  });
};
