76 lines
2.4 KiB
TypeScript
76 lines
2.4 KiB
TypeScript
// * Packages
|
|
import { StickyNoteIcon } from "lucide-react";
|
|
import { route } from "ziggy-js";
|
|
import { Link } from "@inertiajs/react";
|
|
// * Components shadcn
|
|
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
|
import { Button } from "@/components/ui/button";
|
|
// * Other
|
|
import {
|
|
filterActions,
|
|
NavListLinksProps,
|
|
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
|
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
|
import { AuthProp } from "@/back/types/global";
|
|
import str from "@/hooks/use-string";
|
|
import { GetTranslation } from "@/lib/utils";
|
|
import Views from "@/back/lib/actions";
|
|
import useTrans from "@/hooks/use-translations";
|
|
|
|
export default function DynamicPages(auth: AuthProp): SidebarGroupLink {
|
|
const modelName = "dynamic-pages";
|
|
|
|
// Translations.
|
|
const transDynamicPages = GetTranslation(
|
|
`uwil-dynamic-pages::models.classes.${modelName}`,
|
|
{
|
|
choice: 2,
|
|
},
|
|
);
|
|
const transCreate = str(
|
|
useTrans(`uwil-backend::crud.actions.${Views.CREATION.label}`),
|
|
)
|
|
.ucFirst()
|
|
.value();
|
|
const transArchives = str(useTrans("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,
|
|
model,
|
|
items: [
|
|
auth.policies.dynamicPages.create && (
|
|
<DropdownMenuItem key="create" className="p-0">
|
|
<Button variant="ghost" asChild>
|
|
<Link href={route(`back.${model}.create`)} className="w-full">
|
|
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
|
<Views.CREATION.icon />
|
|
{transCreate}
|
|
</Link>
|
|
</Button>
|
|
</DropdownMenuItem>
|
|
),
|
|
auth.policies.dynamicPages.viewTrash && (
|
|
<DropdownMenuItem className="p-0">
|
|
<Button variant="ghost" asChild>
|
|
<Link href={route(`back.${model}.trash`)} className="w-full">
|
|
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
|
<Views.ARCHIVATION.icon />
|
|
{transArchives}
|
|
</Link>
|
|
</Button>
|
|
</DropdownMenuItem>
|
|
),
|
|
],
|
|
}),
|
|
};
|
|
|
|
return { link, group: "pages" };
|
|
}
|