Skip to content

Commit

Permalink
Add confirmation dialog when blocking users
Browse files Browse the repository at this point in the history
  • Loading branch information
heisbrot committed Jan 9, 2025
1 parent 14d2d68 commit 67fd256
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/(dashboard)/team/user/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ function UserInformationCard({ user }: { user: User }) {
<>
{!user.is_current && user.role != Role.Owner && (
<Card.ListItem
tooltip={false}
label={
<>
<Ban size={16} />
Expand Down
14 changes: 14 additions & 0 deletions src/modules/users/table-cells/UserBlockCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ToggleSwitch } from "@components/ToggleSwitch";
import { useApiCall } from "@utils/api";
import React, { useMemo } from "react";
import { useSWRConfig } from "swr";
import { useDialog } from "@/contexts/DialogProvider";
import { User } from "@/interfaces/User";

type Props = {
Expand All @@ -12,6 +13,7 @@ type Props = {
export default function UserBlockCell({ user, isUserPage = false }: Props) {
const userRequest = useApiCall<User>("/users");
const { mutate } = useSWRConfig();
const { confirm } = useDialog();

const isChecked = useMemo(() => {
return user.is_blocked;
Expand All @@ -22,6 +24,18 @@ export default function UserBlockCell({ user, isUserPage = false }: Props) {
const update = async (blocked: boolean) => {
const name = user.name || "User";

if (blocked) {
const choice = await confirm({
title: `Block '${name}'?`,
description:
"This action will immediately revoke the user's access and disconnect all of their active peers.",
confirmText: "Block",
cancelText: "Cancel",
type: "danger",
});
if (!choice) return;
}

notify({
title: blocked ? "User blocked" : "User unblocked",
description:
Expand Down

0 comments on commit 67fd256

Please sign in to comment.