Skip to content

Commit

Permalink
refactor: remove cancel button from delete team dialog and ensure dat…
Browse files Browse the repository at this point in the history
…a refetch after user deletion
  • Loading branch information
vishalkadam47 committed Dec 30, 2024
1 parent 3c9f58b commit 17d4ad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ export const DeleteTeam = ({ teamId }: Props) => {
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button variant="outline" type="button">
Cancel
</Button>
<Button
variant="destructive"
onClick={handleDelete}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export const TeamManagement = ({ teamId }: Props) => {
api.team.users.delete.useMutation({
onSuccess: () => {
utils.team.byId.invalidate({ teamId });
utils.team.all.invalidate();
refetch();
toast.success("User deleted successfully");
},
onError: (error) => {
Expand Down Expand Up @@ -238,6 +240,10 @@ export const TeamManagement = ({ teamId }: Props) => {
const handleDeleteUser = async (userId: string) => {
try {
await deleteUser({ userId });
// Force an immediate refetch after deletion
await utils.team.byId.invalidate({ teamId });
await utils.team.all.invalidate();
await refetch();
setShowDeleteUserDialog(false);
setUserToDelete(null);
} catch (error) {
Expand Down Expand Up @@ -424,7 +430,7 @@ export const TeamManagement = ({ teamId }: Props) => {
No team members
</TableCell>
</TableRow>
)}
)}
</TableBody>
</Table>
</TabsContent>
Expand Down

0 comments on commit 17d4ad2

Please sign in to comment.