MCPcopy Create free account
hub / github.com/code100x/cms / ApproveComment

Function ApproveComment

src/app/admin/comment/ApproveComment.tsx:18–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16import { ShieldCheck } from 'lucide-react';
17
18const ApproveComment = () => {
19 const formRef = React.useRef<HTMLFormElement>(null);
20 const { execute, fieldErrors } = useAction(approveComment, {
21 onSuccess: () => {
22 toast('Comment added');
23 formRef.current?.reset();
24 },
25 onError: (error) => {
26 toast.error(error);
27 },
28 });
29
30 const handleApprove = (e: React.FormEvent<HTMLFormElement>) => {
31 e.preventDefault();
32 const formData = new FormData(e.target as HTMLFormElement);
33
34 const commentId = formData.get('commentId') as string;
35 const adminPassword = formData.get('adminPassword') as string;
36 execute({
37 content_comment_ids: commentId,
38 adminPassword,
39 approved: true,
40 });
41 };
42 return (
43 <div className="h-full w-full">
44 <Accordion
45 defaultValue="approve-comment"
46 className="rounded-2xl border-2 p-4"
47 type="single"
48 collapsible
49 >
50 <AccordionItem className="border-none" value="approve-comment">
51 <AccordionTrigger className="p-6 text-lg font-bold lg:text-2xl">
52 <div className="flex flex-col gap-4">
53 <ShieldCheck size={40} /> Approve Comment
54 </div>
55 </AccordionTrigger>
56 <AccordionContent>
57 <form
58 className="h-full w-full"
59 onSubmit={handleApprove}
60 ref={formRef}
61 >
62 <div className="grid w-full grid-cols-1 gap-2 rounded-lg border-gray-200 p-2 shadow-sm dark:border-gray-800 lg:grid-cols-7">
63 <div className="col-span-1 flex flex-col gap-2 p-4 lg:col-span-3">
64 <div className="text-sm font-medium leading-none text-gray-500 dark:text-gray-400">
65 Enter the information below to approve the comment
66 </div>
67 </div>
68
69 <aside className="col-span-1 flex flex-col gap-6 p-4 lg:col-span-4">
70 <div className="flex items-center">
71 <Label className="sr-only">Comment ID</Label>
72 <Input
73 className="h-14 w-full px-2"
74 id="commentId"
75 name="commentId"

Callers

nothing calls this directly

Calls 1

useActionFunction · 0.90

Tested by

no test coverage detected