Skip to content

Commit 18819d6

Browse files
authored
Add confirmation dialog when blocking users (#437)
1 parent 158804c commit 18819d6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/app/(dashboard)/team/user/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ function UserInformationCard({ user }: { user: User }) {
316316
<>
317317
{!user.is_current && user.role != Role.Owner && (
318318
<Card.ListItem
319+
tooltip={false}
319320
label={
320321
<>
321322
<Ban size={16} />

src/modules/users/table-cells/UserBlockCell.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ToggleSwitch } from "@components/ToggleSwitch";
33
import { useApiCall } from "@utils/api";
44
import React, { useMemo } from "react";
55
import { useSWRConfig } from "swr";
6+
import { useDialog } from "@/contexts/DialogProvider";
67
import { User } from "@/interfaces/User";
78

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

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

27+
if (blocked) {
28+
const choice = await confirm({
29+
title: `Block '${name}'?`,
30+
description:
31+
"This action will immediately revoke the user's access and disconnect all of their active peers.",
32+
confirmText: "Block",
33+
cancelText: "Cancel",
34+
type: "danger",
35+
});
36+
if (!choice) return;
37+
}
38+
2539
notify({
2640
title: blocked ? "User blocked" : "User unblocked",
2741
description:

0 commit comments

Comments
 (0)