From a80172897227f83f14f118221a83fc82f57d4143 Mon Sep 17 00:00:00 2001 From: Gitead Date: Thu, 16 Apr 2026 16:50:43 -0400 Subject: [PATCH] fix: restore credentials section and add missing User migration - Use useAuth() in CredentialTable instead of a separate /api/users/ fetch that was failing silently and hiding the entire credentials section - Add migration for autoBackupEnabled/usbBackupEnabled columns on User that were in the Prisma schema but missing from the database, causing a 500 error on login Co-Authored-By: Claude Sonnet 4.6 --- .../settings/insuranceCredTable.tsx | 19 ++----------------- .../migration.sql | 3 +++ 2 files changed, 5 insertions(+), 17 deletions(-) create mode 100644 packages/db/prisma/migrations/20260416000000_add_user_backup_fields/migration.sql diff --git a/apps/Frontend/src/components/settings/insuranceCredTable.tsx b/apps/Frontend/src/components/settings/insuranceCredTable.tsx index 76bb956..fbe2502 100755 --- a/apps/Frontend/src/components/settings/insuranceCredTable.tsx +++ b/apps/Frontend/src/components/settings/insuranceCredTable.tsx @@ -5,6 +5,7 @@ import { Button } from "../ui/button"; import { Edit, Delete, Plus } from "lucide-react"; import { CredentialForm } from "./InsuranceCredForm"; import { DeleteConfirmationDialog } from "../ui/deleteDialog"; +import { useAuth } from "@/hooks/use-auth"; type Credential = { id: number; @@ -15,20 +16,7 @@ type Credential = { export function CredentialTable() { const queryClient = useQueryClient(); - - // Fetch current user - const { - data: currentUser, - isLoading: isUserLoading, - isError: isUserError, - } = useQuery({ - queryKey: ["/api/users/"], - queryFn: async () => { - const res = await apiRequest("GET", "/api/users/"); - if (!res.ok) throw new Error("Failed to fetch user"); - return res.json(); - }, - }); + const { user: currentUser } = useAuth(); const [currentPage, setCurrentPage] = useState(1); const [modalOpen, setModalOpen] = useState(false); @@ -86,9 +74,6 @@ export function CredentialTable() { const currentCredentials = credentials.slice(indexOfFirst, indexOfLast); const totalPages = Math.ceil(credentials.length / credentialsPerPage); - if (isUserLoading) return

Loading user...

; - if (isUserError) return

Error loading user

; - return (
diff --git a/packages/db/prisma/migrations/20260416000000_add_user_backup_fields/migration.sql b/packages/db/prisma/migrations/20260416000000_add_user_backup_fields/migration.sql new file mode 100644 index 0000000..30d2191 --- /dev/null +++ b/packages/db/prisma/migrations/20260416000000_add_user_backup_fields/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "User" ADD COLUMN IF NOT EXISTS "autoBackupEnabled" BOOLEAN NOT NULL DEFAULT true; +ALTER TABLE "User" ADD COLUMN IF NOT EXISTS "usbBackupEnabled" BOOLEAN NOT NULL DEFAULT false;