diff --git a/src/components/audio-preview.tsx b/src/components/audio-preview.tsx index 971bbba..d031476 100644 --- a/src/components/audio-preview.tsx +++ b/src/components/audio-preview.tsx @@ -29,6 +29,7 @@ import { TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; +import { toast } from "sonner"; const queryClient = new QueryClient(); @@ -249,9 +250,19 @@ function AudioInfo({ id }: AudioInfoProps) { Cancel { - await deleteWhishperRecording( + const response = await deleteWhishperRecording( `${userData.whishperURL}/api/transcriptions/${id}`, ); + if (response.ok) { + toast("Recording deleted", { + description: "The recording has been deleted.", + }); + } else { + toast("Error deleting recording", { + description: + "An error occurred while deleting the recording.", + }); + } }} > Continue diff --git a/src/components/document-viewer.tsx b/src/components/document-viewer.tsx index 8b31740..8d45381 100644 --- a/src/components/document-viewer.tsx +++ b/src/components/document-viewer.tsx @@ -97,6 +97,39 @@ const fetchUserData = async (): Promise => { return data; }; +async function deleteDocument(documentId: number) { + const userData = await getUserData(); + if (!userData) { + console.error("Error getting user data"); + return; + } + const body = { + documents: [documentId], + method: "delete", + }; + try { + const response = await fetch( + `${userData.paperlessURL}/api/documents/bulk_edit/ `, + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Token ${userData.paperlessToken}`, + }, + body: JSON.stringify(body), + }, + ); + if (!response.ok) { + console.error("Failed to delete document"); + return; + } + console.log("Document deleted successfully"); + } catch (error) { + console.error("Error deleting document:", error); + return null; + } +} + function DocumentViewer(props: { id: number }) { const router = useRouter();