update
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user