24 lines
848 B
JavaScript
24 lines
848 B
JavaScript
import { useMutation } from "@tanstack/react-query";
|
|
import { useToast } from "@/hooks/use-toast";
|
|
import { apiRequest } from "@/lib/queryClient";
|
|
export default function useExtractPdfData() {
|
|
const { toast } = useToast();
|
|
return useMutation({
|
|
mutationFn: async (pdfFile) => {
|
|
const formData = new FormData();
|
|
formData.append("pdf", pdfFile);
|
|
const res = await apiRequest("POST", "/api/patientDataExtraction/patientdataextract", formData);
|
|
if (!res.ok)
|
|
throw new Error("Failed to extract PDF");
|
|
return res.json();
|
|
},
|
|
onError: (error) => {
|
|
toast({
|
|
title: "Error",
|
|
description: `Failed to extract PDF: ${error.message}`,
|
|
variant: "destructive",
|
|
});
|
|
},
|
|
});
|
|
}
|