- Updated translation utility to improve consistency and reduce redundancy. - Removed deprecated useTrans hook and related code. - Introduced a new Zustand store for managing translations and locale settings. - Cleaned up unused hooks and files related to localization.
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import { Link } from "@inertiajs/react";
|
|
import { StickyNoteIcon } from "lucide-react";
|
|
|
|
import {
|
|
filterActions,
|
|
type NavListLinksProps,
|
|
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
|
import { type SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
|
import Views from "@/back/lib/actions";
|
|
import type { AuthProp, ConfigBackend } from "@/back/types/global";
|
|
import { Button } from "@/components/ui/button";
|
|
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
|
import str from "@/hooks/use-string";
|
|
import trans from "@/hooks/use-translations";
|
|
|
|
export default function DynamicPages(
|
|
auth: AuthProp,
|
|
configBackend: ConfigBackend,
|
|
): Readonly<SidebarGroupLink> {
|
|
const modelName = "dynamic-pages";
|
|
|
|
// Translations.
|
|
const transDynamicPages = trans(
|
|
`uwil-dynamic-pages::models.classes.${modelName}`,
|
|
{
|
|
choice: 2,
|
|
},
|
|
);
|
|
const transCreate = str(
|
|
trans(`uwil-backend::crud.actions.${Views.CREATION.label}`),
|
|
)
|
|
.ucFirst()
|
|
.value();
|
|
const transArchives = str(trans("uwil-backend::back.archives"))
|
|
.ucFirst()
|
|
.value();
|
|
|
|
const link: NavListLinksProps = {
|
|
title: str(transDynamicPages).ucFirst().value(),
|
|
model: modelName,
|
|
icon: StickyNoteIcon,
|
|
show: auth.policies.dynamicPages.viewAny,
|
|
actions: (model: string) =>
|
|
filterActions({
|
|
auth,
|
|
configBackend,
|
|
model,
|
|
items: [
|
|
auth.policies.dynamicPages.create && (
|
|
<DropdownMenuItem key="create" className="p-0">
|
|
<Button variant="ghost" asChild>
|
|
<Link
|
|
href={route(`${configBackend.routes.name}${model}.create`)}
|
|
className="w-full"
|
|
>
|
|
{}
|
|
<Views.CREATION.icon />
|
|
{transCreate}
|
|
</Link>
|
|
</Button>
|
|
</DropdownMenuItem>
|
|
),
|
|
auth.policies.dynamicPages.viewTrash && (
|
|
<DropdownMenuItem key="trash" className="p-0">
|
|
<Button variant="ghost" asChild>
|
|
<Link
|
|
href={route(`${configBackend.routes.name}${model}.trash`)}
|
|
className="w-full"
|
|
>
|
|
{}
|
|
<Views.ARCHIVATION.icon />
|
|
{transArchives}
|
|
</Link>
|
|
</Button>
|
|
</DropdownMenuItem>
|
|
),
|
|
],
|
|
}),
|
|
};
|
|
|
|
return { link, group: "pages" };
|
|
}
|