fix refresh button doesnt work for users table

This commit is contained in:
miloschwartz
2025-12-17 17:44:35 -05:00
parent acf08e3ef6
commit 68191d5921
3 changed files with 161 additions and 114 deletions

View File

@@ -6,7 +6,7 @@ import { UsersDataTable } from "@app/components/AdminUsersDataTable";
import { Button } from "@app/components/ui/button";
import { ArrowRight, ArrowUpDown, MoreHorizontal } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { useState, useEffect } from "react";
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
import { toast } from "@app/hooks/useToast";
import { formatAxiosError } from "@app/lib/api";
@@ -72,6 +72,11 @@ export default function UsersTable({ users }: Props) {
useState<AdminGeneratePasswordResetCodeResponse | null>(null);
const [isGeneratingCode, setIsGeneratingCode] = useState(false);
// Update local state when props change (e.g., after refresh)
useEffect(() => {
setRows(users);
}, [users]);
const refreshData = async () => {
console.log("Data refreshed");
setIsRefreshing(true);

View File

@@ -11,7 +11,7 @@ import {
import { Button } from "@app/components/ui/button";
import { ArrowRight, ArrowUpDown, Crown, MoreHorizontal } from "lucide-react";
import { UsersDataTable } from "@app/components/UsersDataTable";
import { useState } from "react";
import { useState, useEffect } from "react";
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
import { useOrgContext } from "@app/hooks/useOrgContext";
import { toast } from "@app/hooks/useToast";
@@ -54,6 +54,11 @@ export default function UsersTable({ users: u }: UsersTableProps) {
const t = useTranslations();
const [isRefreshing, setIsRefreshing] = useState(false);
// Update local state when props change (e.g., after refresh)
useEffect(() => {
setUsers(u);
}, [u]);
const refreshData = async () => {
console.log("Data refreshed");
setIsRefreshing(true);