Skip to content

Commit

Permalink
Delete status tost as well as document delete logic
Browse files Browse the repository at this point in the history
  • Loading branch information
aamirazad committed Jul 25, 2024
1 parent 3d8c63a commit 46b2f93
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/audio-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import { toast } from "sonner";

const queryClient = new QueryClient();

Expand Down Expand Up @@ -249,9 +250,19 @@ function AudioInfo({ id }: AudioInfoProps) {
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={async () => {
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
Expand Down
33 changes: 33 additions & 0 deletions src/components/document-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,39 @@ const fetchUserData = async (): Promise<UsersTableType> => {
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();

Expand Down

0 comments on commit 46b2f93

Please sign in to comment.