59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { prisma } from "@/lib/prisma";
|
|
import MenuClient from "./_components/MenuClient";
|
|
import { getTranslations } from "next-intl/server";
|
|
|
|
export default async function MenuPage() {
|
|
const t = await getTranslations('Menu');
|
|
const menus = await prisma.menu.findMany({
|
|
include: {
|
|
parent: {
|
|
select: {
|
|
name: true,
|
|
},
|
|
},
|
|
},
|
|
orderBy: {
|
|
createdAt: 'desc',
|
|
},
|
|
});
|
|
|
|
// Extract all needed translations as a plain object
|
|
const translations = {
|
|
title: t('title'),
|
|
addButton: t('addButton'),
|
|
editTitle: t('editTitle'),
|
|
addTitle: t('addTitle'),
|
|
nameIdLabel: t('nameIdLabel'),
|
|
nameEnLabel: t('nameEnLabel'),
|
|
descriptionIdLabel: t('descriptionIdLabel'),
|
|
descriptionEnLabel: t('descriptionEnLabel'),
|
|
slugLabel: t('slugLabel'),
|
|
parentLabel: t('parentLabel'),
|
|
parentNone: t('parentNone'),
|
|
activeLabel: t('activeLabel'),
|
|
cancelButton: t('cancelButton'),
|
|
saveButton: t('saveButton'),
|
|
createButton: t('createButton'),
|
|
saving: t('saving'),
|
|
tableName: t('tableName'),
|
|
tableSlug: t('tableSlug'),
|
|
tableParent: t('tableParent'),
|
|
tableStatus: t('tableStatus'),
|
|
tableActions: t('tableActions'),
|
|
statusActive: t('statusActive'),
|
|
statusInactive: t('statusInactive'),
|
|
noMenus: t('noMenus'),
|
|
confirmDelete: t('confirmDelete'),
|
|
errorOccurred: t('errorOccurred'),
|
|
nameIdRequired: t('nameIdRequired'),
|
|
descriptionIdRequired: t('descriptionIdRequired'),
|
|
slugRequired: t('slugRequired'),
|
|
};
|
|
|
|
return (
|
|
<div className="container mx-auto py-8">
|
|
<MenuClient initialMenus={menus} translations={translations} />
|
|
</div>
|
|
);
|
|
}
|