diff --git a/src/app/whishper/page.tsx b/src/app/whishper/page.tsx index 45e5547..3ce2ec2 100644 --- a/src/app/whishper/page.tsx +++ b/src/app/whishper/page.tsx @@ -24,10 +24,8 @@ import { } from "@tanstack/react-query"; import { getUserData } from "../actions"; import LoadingSpinner from "@/components/loading-spinner"; -import type { WhishperRecordingsType } from "@/types"; +import type { WhishperRecordingType } from "@/types"; import OpenInternalLink from "@/components/internal-link"; -import OpenExternalLInk from "@/components/external-link"; -import AudioViewer from "@/components/audio-viewer"; import { type ColumnDef, flexRender, @@ -42,8 +40,8 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; -import { ExternalLink } from "lucide-react"; -import { columns } from "@/types"; +import OpenExternalLInk from "@/components/external-link"; +import { UsersTableType } from "@/server/db/schema"; const queryClient = new QueryClient(); @@ -54,7 +52,7 @@ async function getWhishperRecordings(query: string) { const response = await fetch(`${userData.whishperURL}/api/transcriptions`); - const data = (await response.json()) as WhishperRecordingsType; + const data = (await response.json()) as WhishperRecordingType[]; const lowerCaseQuery = query.toLowerCase(); const filteredAndScored = data .filter( @@ -162,6 +160,10 @@ function RecordingsList() { return

Start Searching!

; } + if (WhishperRecordings.isLoading || userData.isLoading) { + return Loading...; + } + if (!userData.data?.whishperURL) { return (

@@ -171,10 +173,6 @@ function RecordingsList() { ); } - if (WhishperRecordings.isLoading || userData.isLoading) { - return Loading...; - } - if (!WhishperRecordings.data || WhishperRecordings.error) { return (

@@ -193,22 +191,45 @@ function RecordingsList() { return ( <>

Search Results

- - data={WhishperRecordingsMap as WhishperRecordingsType[]} - /> + ); } -interface DataTableProps { - columns: ColumnDef[]; +interface DataTableProps { data: TData[]; + userData: UsersTableType; } -function DataTable({ - columns, +function DataTable({ data, -}: DataTableProps) { + userData, +}: DataTableProps) { + const columns: ColumnDef[] = [ + { + accessorFn: (recording) => { + const name = + recording.fileName.split("_WHSHPR_")[1] ?? recording.fileName; + return name.replace(".m4a", "") ?? recording.fileName; + }, + header: "Name", + }, + { + accessorKey: "status", + header: "Status", + }, + { + cell: ({ row }) => ( + + Test + + ), + header: "Link", + }, + ]; + const table = useReactTable({ data, columns, diff --git a/src/types/index.ts b/src/types/index.ts index 3eedd6c..3182e63 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -70,7 +70,7 @@ export type PaperlessDocumentsType = { }[]; }; -export type WhishperRecordingsType = { +export type WhishperRecordingType = { id: string; status: number; language: string; @@ -98,7 +98,7 @@ export type WhishperRecordingsType = { text: string; }; translations: []; -}[]; +}; export type AdviceAPIType = { slip: { @@ -106,18 +106,3 @@ export type AdviceAPIType = { advice: string; }; }; - -export const columns: ColumnDef[] = [ - { - accessorKey: "name", - header: "Name", - }, - { - accessorKey: "status", - header: "Status", - }, - { - accessorKey: "link", - header: "Link", - }, -];