This commit is contained in:
UltraLionFr
2025-12-07 00:44:44 +01:00
parent 765e9a6c1a
commit fca0f438d8
2 changed files with 15 additions and 4 deletions
+11 -3
View File
@@ -110,9 +110,16 @@ export default async function CategoriesPage() {
// Compter les tutoriels par catégorie // Compter les tutoriels par catégorie
const counts = await prisma.tutorial.groupBy({ const counts = await prisma.tutorial.groupBy({
by: ["categoryId"], by: ["categoryId"],
_count: true, _count: {
_all: true,
},
}); });
const countMap = new Map(counts.map((c) => [c.categoryId, c._count])); const countMap = new Map(
counts.map((c: (typeof counts)[number]) => [
c.categoryId,
c._count._all,
])
);
return ( return (
<div className="space-y-8"> <div className="space-y-8">
@@ -208,7 +215,8 @@ export default async function CategoriesPage() {
<div className="bg-slate-900/80 border border-slate-700/50 rounded-lg overflow-hidden"> <div className="bg-slate-900/80 border border-slate-700/50 rounded-lg overflow-hidden">
<div className="divide-y divide-slate-800/50"> <div className="divide-y divide-slate-800/50">
{categories.map((cat) => { {categories.map((cat) => {
const tutorialCount = countMap.get(cat.id) || 0; const tutorialCount =
(countMap.get(cat.id) as number) || 0;
return ( return (
<div <div
+4 -1
View File
@@ -29,6 +29,9 @@ export default async function EditTutorialPage({ params }: Props) {
notFound(); notFound();
} }
// Capture le slug ici pour l'utiliser dans la Server Action
const tutorialSlug = tutorial.slug;
async function handleUpdate(formData: FormData) { async function handleUpdate(formData: FormData) {
"use server"; "use server";
@@ -68,7 +71,7 @@ export default async function EditTutorialPage({ params }: Props) {
revalidatePath("/dashboard"); revalidatePath("/dashboard");
revalidatePath("/"); revalidatePath("/");
revalidatePath(`/tutos/${tutorial.slug}`); revalidatePath(`/tutos/${tutorialSlug}`);
redirect("/dashboard"); redirect("/dashboard");
} }