feat: add delete functionality to admin forms list and correct redirection paths
This commit is contained in:
+2
-2
@@ -54,6 +54,6 @@ export async function deleteForm(id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await db.delete(forms).where(eq(forms.id, id));
|
await db.delete(forms).where(eq(forms.id, id));
|
||||||
revalidatePath("/form/admin");
|
revalidatePath("/admin/form");
|
||||||
redirect("/form/admin");
|
redirect("/admin/form");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from "@/components/ui/table";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Plus } from "lucide-react";
|
import { Plus, Trash2 } from "lucide-react";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
import { deleteForm } from "@/app/actions/form";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
@@ -83,6 +84,11 @@ export default async function AdminFormsPage() {
|
|||||||
<Button variant="outline" asChild size="sm">
|
<Button variant="outline" asChild size="sm">
|
||||||
<Link href={`/admin/form/${form.id}/result`}>Results</Link>
|
<Link href={`/admin/form/${form.id}/result`}>Results</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
<form className="inline-block" action={deleteForm.bind(null, form.id)}>
|
||||||
|
<Button variant="outline" size="sm" type="submit" className="text-destructive hover:text-destructive">
|
||||||
|
<Trash2 className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user