Skip to content

Commit

Permalink
feat(forum): Add delete dialog for forum in AdminCP
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Feb 26, 2024
1 parent a2f4f59 commit 0820a7b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EditActionForumAdmin } from "./edit";
import { DeleteActionForumAdmin } from "./delete/delete";

import type { ShowForumForumsAdminWithChildren } from "../../hooks/use-forum-forums-admin-api";

Expand All @@ -8,6 +9,7 @@ export const ActionsForumAdmin = (
return (
<div className="flex gap-2 flex-shrink-0">
<EditActionForumAdmin {...props} />
<DeleteActionForumAdmin />
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useTranslations } from "next-intl";

import {
AlertDialogHeader,
AlertDialogTitle
} from "@/components/ui/alert-dialog";

export const ContentDeleteActionForumAdmin = () => {
// const t = useTranslations("admin_forum.forums.delete");
const tCore = useTranslations("core");

return (
<>
<AlertDialogHeader>
<AlertDialogTitle>{tCore("are_your_sure")}</AlertDialogTitle>
</AlertDialogHeader>
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Trash2 } from "lucide-react";
import { useTranslations } from "next-intl";
import { Suspense, lazy } from "react";

import { Loader } from "@/components/loader";
import {
AlertDialog,
AlertDialogContent,
AlertDialogTrigger
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";

const Content = lazy(() =>
import("./content").then(module => ({
default: module.ContentDeleteActionForumAdmin
}))
);

export const DeleteActionForumAdmin = () => {
const t = useTranslations("core");

return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructiveGhost" size="icon" tooltip={t("delete")}>
<Trash2 />
</Button>
</AlertDialogTrigger>

<AlertDialogContent>
<Suspense fallback={<Loader />}>
<Content />
</Suspense>
</AlertDialogContent>
</AlertDialog>
);
};
4 changes: 1 addition & 3 deletions frontend/admin/forum/views/forums/table/item/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ export const ItemTableForumsForumAdmin = ({
)}

<div className="flex-grow flex flex-col">
<span>
{convertText(name)} - {id}
</span>
<span>{convertText(name)}</span>
</div>

<ActionsForumAdmin id={id} name={name} {...props} />
Expand Down

0 comments on commit 0820a7b

Please sign in to comment.