campaign sending prototype
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Activity, FileText, Folder, Form, LayoutDashboard, MailCheck, Users, type LucideIcon } from "lucide-react";
|
||||
import { Activity, FileText, Folder, Form, LayoutDashboard, Mail, Mails, Users, type LucideIcon } from "lucide-react";
|
||||
import campaignModule from "@govoplan/campaign-webui";
|
||||
import filesModule from "@govoplan/files-webui";
|
||||
import mailModule from "@govoplan/mail-webui";
|
||||
@@ -6,28 +6,41 @@ import type { AuthInfo, PlatformModuleInfo, PlatformNavItem, PlatformRouteContri
|
||||
import { adminReadScopes, hasAnyScope, hasScope } from "../utils/permissions";
|
||||
|
||||
export const shellNavItems: PlatformNavItem[] = [
|
||||
{ to: "/dashboard", label: "Dashboard", icon: LayoutDashboard, order: 10 }
|
||||
{ to: "/dashboard", label: "Dashboard", iconName: "dashboard", order: 10 }
|
||||
];
|
||||
|
||||
const legacyModules: PlatformWebModule[] = [campaignModule, filesModule, mailModule];
|
||||
|
||||
const iconByName: Record<string, LucideIcon> = {
|
||||
activity: Activity,
|
||||
campaign: MailCheck,
|
||||
campaign: Mails,
|
||||
dashboard: LayoutDashboard,
|
||||
file: Folder,
|
||||
files: Folder,
|
||||
folder: Folder,
|
||||
form: Form,
|
||||
mail: MailCheck,
|
||||
mail: Mail,
|
||||
reports: FileText,
|
||||
users: Users
|
||||
};
|
||||
|
||||
export function iconComponentForName(iconName: string | null | undefined): LucideIcon | undefined {
|
||||
if (!iconName) return undefined;
|
||||
return iconByName[iconName];
|
||||
}
|
||||
|
||||
function resolveNavItemIcon(item: PlatformNavItem): PlatformNavItem {
|
||||
return {
|
||||
...item,
|
||||
icon: item.icon ?? iconComponentForName(item.iconName)
|
||||
};
|
||||
}
|
||||
|
||||
function navFromMetadata(item: PlatformModuleInfo["nav"][number]): PlatformNavItem {
|
||||
return {
|
||||
to: item.path,
|
||||
label: item.label,
|
||||
icon: item.icon ? iconByName[item.icon] : undefined,
|
||||
iconName: item.icon ?? null,
|
||||
allOf: item.required_all,
|
||||
anyOf: item.required_any,
|
||||
order: item.order
|
||||
@@ -70,7 +83,9 @@ export function moduleIntegrationEnabled(moduleId: string, dependencyId: string,
|
||||
}
|
||||
|
||||
export function navItemsForModules(modules: PlatformWebModule[]): PlatformNavItem[] {
|
||||
return [...shellNavItems, ...modules.flatMap((module) => module.navItems ?? [])].sort((left, right) => (left.order ?? 100) - (right.order ?? 100));
|
||||
return [...shellNavItems, ...modules.flatMap((module) => module.navItems ?? [])]
|
||||
.map(resolveNavItemIcon)
|
||||
.sort((left, right) => (left.order ?? 100) - (right.order ?? 100));
|
||||
}
|
||||
|
||||
export function routeContributionsForModules(modules: PlatformWebModule[]): PlatformRouteContribution[] {
|
||||
|
||||
Reference in New Issue
Block a user