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 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { Button } from "../ui/button";
|
|||||||
import { Edit, Delete, Plus } from "lucide-react";
|
import { Edit, Delete, Plus } from "lucide-react";
|
||||||
import { CredentialForm } from "./InsuranceCredForm";
|
import { CredentialForm } from "./InsuranceCredForm";
|
||||||
import { DeleteConfirmationDialog } from "../ui/deleteDialog";
|
import { DeleteConfirmationDialog } from "../ui/deleteDialog";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
|
||||||
type Credential = {
|
type Credential = {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -15,20 +16,7 @@ type Credential = {
|
|||||||
|
|
||||||
export function CredentialTable() {
|
export function CredentialTable() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { user: currentUser } = useAuth();
|
||||||
// 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 [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
const [modalOpen, setModalOpen] = useState(false);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
@@ -86,9 +74,6 @@ export function CredentialTable() {
|
|||||||
const currentCredentials = credentials.slice(indexOfFirst, indexOfLast);
|
const currentCredentials = credentials.slice(indexOfFirst, indexOfLast);
|
||||||
const totalPages = Math.ceil(credentials.length / credentialsPerPage);
|
const totalPages = Math.ceil(credentials.length / credentialsPerPage);
|
||||||
|
|
||||||
if (isUserLoading) return <p>Loading user...</p>;
|
|
||||||
if (isUserError) return <p>Error loading user</p>;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white shadow rounded-lg overflow-hidden">
|
<div className="bg-white shadow rounded-lg overflow-hidden">
|
||||||
<div className="flex justify-between items-center p-4 border-b border-gray-200">
|
<div className="flex justify-between items-center p-4 border-b border-gray-200">
|
||||||
|
|||||||
@@ -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;
|
||||||
Reference in New Issue
Block a user