Add shared ConfirmDialog; upgrade wordfilter with client actions and toasts.
Local Build and Deploy / deploy (push) Successful in 1m6s
Local Build and Deploy / deploy (push) Successful in 1m6s
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
1039044e48
commit
a2ca9b3c23
9 files changed
+366
-149
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
updatePrefix,
|
||||
updatePrefixSettings,
|
||||
} from "@/actions/prefixes";
|
||||
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -315,6 +316,7 @@ function PrefixDialog({
|
||||
|
||||
export function PrefixesClient({ canEdit }: { canEdit: boolean }) {
|
||||
const { run, isPending } = useServerAction();
|
||||
const { confirm, dialog: confirmDialog } = useConfirmDialog();
|
||||
const [prefixes, setPrefixes] = useState<UserPrefix[]>([]);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [page, setPage] = useState(1);
|
||||
@@ -370,7 +372,13 @@ export function PrefixesClient({ canEdit }: { canEdit: boolean }) {
|
||||
}, [fetchBlacklist, fetchSettings]);
|
||||
|
||||
const handleDeletePrefix = async (id: number) => {
|
||||
if (!confirm("Are you sure you want to delete this prefix?")) return;
|
||||
const ok = await confirm({
|
||||
title: "Delete prefix",
|
||||
description: "Are you sure you want to delete this prefix?",
|
||||
confirmLabel: "Delete",
|
||||
cancelLabel: "Cancel",
|
||||
});
|
||||
if (!ok) return;
|
||||
run(() => deletePrefixAction({ id }), {
|
||||
successMessage: "Prefix deleted!",
|
||||
onSuccess: () => {
|
||||
@@ -463,6 +471,7 @@ export function PrefixesClient({ canEdit }: { canEdit: boolean }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
{confirmDialog}
|
||||
<PrefixDialog
|
||||
editPrefix={editPrefix}
|
||||
isOpen={dialogOpen}
|
||||
|
||||
Reference in new issue
Block a user