From 0eb3ba8104d3137db897ee3445d9cc1090d87ac0 Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Tue, 3 Jun 2025 17:54:30 -0700 Subject: [PATCH] added OrderBy functionality to Data Table --- .../app/_components/navbar/Settings.tsx | 4 +- apps/dispatch/app/_store/audioStore.ts | 2 - apps/dispatch/package.json | 7 +- apps/hub/app/(app)/admin/report/page.tsx | 4 +- .../hub/app/_components/EmailVerification.tsx | 3 +- apps/hub/app/_components/PaginatedTable.tsx | 32 ++--- apps/hub/app/_components/Table.tsx | 50 ++++--- .../app/_components/pagiantedTableActions.ts | 3 + apps/hub/package.json | 7 +- packages/database/prisma/schema/user.prisma | 2 +- pnpm-lock.yaml | 124 +++++++++--------- 11 files changed, 117 insertions(+), 121 deletions(-) diff --git a/apps/dispatch/app/_components/navbar/Settings.tsx b/apps/dispatch/app/_components/navbar/Settings.tsx index 9ef20e8d..df26b2f1 100644 --- a/apps/dispatch/app/_components/navbar/Settings.tsx +++ b/apps/dispatch/app/_components/navbar/Settings.tsx @@ -47,7 +47,7 @@ export const SettingsBtn = () => { setSelectedDevice(user.settingsMicDevice); setMic(user.settingsMicDevice, user.settingsMicVolume || 1); setMicVol(user.settingsMicVolume || 1); - setFunkVol(user.settingsFunkVolume || 0.8); + setFunkVol(user.settingsRadioVolume || 0.8); setDmeVol(user.settingsDmeVolume || 0.8); } }, [user, setMic]); @@ -205,7 +205,7 @@ export const SettingsBtn = () => { user: { settingsMicDevice: selectedDevice, settingsMicVolume: micVol, - settingsFunkVolume: funkVolume, + settingsRadioVolume: funkVolume, settingsDmeVolume: dmeVolume, }, }); diff --git a/apps/dispatch/app/_store/audioStore.ts b/apps/dispatch/app/_store/audioStore.ts index e18c97c0..23cde55b 100644 --- a/apps/dispatch/app/_store/audioStore.ts +++ b/apps/dispatch/app/_store/audioStore.ts @@ -1,6 +1,4 @@ -import { PublicUser } from "@repo/db"; import { dispatchSocket } from "dispatch/socket"; -import { serverApi } from "_helpers/axios"; import { handleDisconnect, handleLocalTrackUnpublished, diff --git a/apps/dispatch/package.json b/apps/dispatch/package.json index 89030509..9673346f 100644 --- a/apps/dispatch/package.json +++ b/apps/dispatch/package.json @@ -49,14 +49,13 @@ "tailwindcss": "^4.1.8", "zod": "^3.25.46", "zustand": "^5.0.5", - "zustand-sync-tabs": "^0.2.2" - }, - "devDependencies": { + "zustand-sync-tabs": "^0.2.2", "@types/leaflet": "^1.9.18", "@types/node": "^22.15.29", "@types/react": "^19.1.6", "@types/react-dom": "^19.1.5", "daisyui": "^5.0.43", "typescript": "^5.8.3" - } + }, + "devDependencies": {} } diff --git a/apps/hub/app/(app)/admin/report/page.tsx b/apps/hub/app/(app)/admin/report/page.tsx index d386e497..8c5731d4 100644 --- a/apps/hub/app/(app)/admin/report/page.tsx +++ b/apps/hub/app/(app)/admin/report/page.tsx @@ -8,6 +8,7 @@ import { ColumnDef } from "@tanstack/react-table"; export default function ReportPage() { return ( - new Date(row.getValue("timestamp")).toLocaleString(), + cell: ({ row }) => new Date(row.getValue("timestamp")).toLocaleString(), }, { accessorKey: "actions", diff --git a/apps/hub/app/_components/EmailVerification.tsx b/apps/hub/app/_components/EmailVerification.tsx index 1225a954..04ea207c 100644 --- a/apps/hub/app/_components/EmailVerification.tsx +++ b/apps/hub/app/_components/EmailVerification.tsx @@ -15,7 +15,8 @@ export const EmailVerification = () => {

E-Mail Adresse nicht bestätigt!

- Wir haben dir bereits eine E-Mail gesendet. Wenn deine E-Mail Adresse nicht bestätigt ist, kannst du dich nicht mit der Leitstelle verbinden! + Wir haben dir bereits eine E-Mail gesendet. Wenn deine E-Mail Adresse nicht bestätigt ist, + kannst du dich nicht mit der Leitstelle verbinden!
@@ -52,6 +54,16 @@ export default function SortableTable({ state: { sorting }, }); + useEffect(() => { + if (prismaModel) { + const orderBy: Record = {}; + sorting.forEach((sort) => { + orderBy[sort.id] = sort.desc ? "desc" : "asc"; + }); + setOrderBy?.(orderBy); + } + }, [sorting, prismaModel, setOrderBy]); + return (
@@ -59,21 +71,11 @@ export default function SortableTable({ {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( - ))} @@ -84,9 +86,7 @@ export default function SortableTable({ {table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( - + ))} ))} @@ -108,11 +108,7 @@ export const Pagination = ({ if (totalPages === 0) return null; return (
-
+
- {flexRender( - header.column.columnDef.header, - header.getContext(), - )} - {header.column.getIsSorted() === "asc" && ( - - )} - {header.column.getIsSorted() === "desc" && ( - - )} + {flexRender(header.column.columnDef.header, header.getContext())} + {header.column.getIsSorted() === "asc" && } + {header.column.getIsSorted() === "desc" && }
- {flexRender(cell.column.columnDef.cell, cell.getContext())} - {flexRender(cell.column.columnDef.cell, cell.getContext())}