diff --git a/src/app/actions.ts b/src/app/actions.ts index 28ef27d..20bb719 100644 --- a/src/app/actions.ts +++ b/src/app/actions.ts @@ -4,10 +4,9 @@ import { db } from "@/server/db"; import type { UsersTableType } from "@/server/db/schema"; import { users } from "@/server/db/schema"; import type { PaperlessDocumentsType } from "@/types"; -import { auth } from "@clerk/nextjs/server"; +import { auth, currentUser } from "@clerk/nextjs/server"; import type { WhishperRecordingType } from "@/types"; - /* Clerk helpers ___| | ___ _ __| | __ @@ -113,4 +112,4 @@ export async function getWhishperRecordings( // Step 4: Return the sorted array without the score return sortedByScore.map(({ ...item }) => item); -} +} \ No newline at end of file diff --git a/src/app/api/deleteWhishperRecordingByName/route.ts b/src/app/api/deleteWhishperRecordingByName/route.ts new file mode 100644 index 0000000..494da53 --- /dev/null +++ b/src/app/api/deleteWhishperRecordingByName/route.ts @@ -0,0 +1,37 @@ +import { getUserData, getWhishperRecordings } from "@/app/actions"; + +export async function DELETE(req: Request) { + const url = new URL(req.url); + const name = url.searchParams.get("name"); + + if (!name) { + return new Response("Name parameter is missing", { status: 400 }); + } + + const userData = await getUserData(); + + if (!userData) { + return new Response("Unauthorized", { status: 401 }); + } + + console.log(getWhishperRecordings(name)); + + const response = await fetch( + `${userData.whishperURL}/api/transcriptions/${name}`, + { + method: "DELETE", + }, + ); + + if (!response.ok) { + throw new Error("Network error"); + } + + // Assuming the deletion is successful and you want to return a JSON response + return new Response(JSON.stringify({ success: true }), { + status: 200, + headers: { + "Content-Type": "application/json", + }, + }); +} diff --git a/src/app/whishper/page.tsx b/src/app/whishper/page.tsx index 91d2f6a..0343912 100644 --- a/src/app/whishper/page.tsx +++ b/src/app/whishper/page.tsx @@ -42,11 +42,10 @@ import { import OpenExternalLink from "@/components/external-link"; import type { UsersTableType } from "@/server/db/schema"; import { BadgeCheck, Badge, BadgeAlert } from "lucide-react"; +import type { WhishperRecordingType } from "@/types"; const queryClient = new QueryClient(); - - function SearchForm() { const formSchema = z.object({ query: z.string().min(3).max(256), @@ -160,7 +159,7 @@ function RecordingsList() { return ( <> -