* feat: implement standard pagination for org member list * fix type error * i18n for pagination * add paginationMode * apply the change to PlatformManagedUsersTable * replace useInfiniteQuery with useQuery * fix type error * fix type error * fix type error * fix type error * update comment * remove optimistic update * minor changes * update usage on nuqs --------- Co-authored-by: Benny Joo <sldisek783@gmail.com>
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { DataTableSelectionBar } from "@calcom/features/data-table";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import { ConfirmationDialogContent, Dialog, DialogTrigger, showToast } from "@calcom/ui";
|
|
|
|
import type { UserTableUser } from "../types";
|
|
|
|
interface Props {
|
|
users: Array<{ id: UserTableUser["id"] }>;
|
|
onRemove: () => void;
|
|
}
|
|
|
|
export function DeleteBulkUsers({ users, onRemove }: Props) {
|
|
const { t } = useLocale();
|
|
const selectedRows = users; // Get selected rows from table
|
|
const utils = trpc.useUtils();
|
|
const deleteMutation = trpc.viewer.organizations.bulkDeleteUsers.useMutation({
|
|
onSuccess: () => {
|
|
showToast("Deleted Users", "success");
|
|
utils.viewer.organizations.listMembers.invalidate();
|
|
},
|
|
onError: (error) => {
|
|
showToast(error.message, "error");
|
|
},
|
|
});
|
|
return (
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
<DataTableSelectionBar.Button icon="ban" color="destructive">
|
|
{t("Delete")}
|
|
</DataTableSelectionBar.Button>
|
|
</DialogTrigger>
|
|
<ConfirmationDialogContent
|
|
variety="danger"
|
|
title={t("remove_users_from_org")}
|
|
confirmBtnText={t("remove")}
|
|
isPending={deleteMutation.isPending}
|
|
onConfirm={() => {
|
|
deleteMutation.mutateAsync({
|
|
userIds: selectedRows.map((user) => user.id),
|
|
});
|
|
onRemove();
|
|
}}>
|
|
<p className="mt-5">
|
|
{t("remove_users_from_org_confirm", {
|
|
userCount: selectedRows.length,
|
|
})}
|
|
</p>
|
|
</ConfirmationDialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|