import type { PageMeta } from "./types"; import { getFleetRouteMeta } from "@/pages/fleet/config/resources"; import { RULE_ENGINE_CATEGORY_BASE_PATH, RULE_ENGINE_RESOURCES, } from "@/pages/ruleEngine/config/resources"; const APP_TITLE = "EDR Freight Backoffice"; const APP_SUBTITLE = "Manage freight operations and platform settings"; const configurationRouteMeta = RULE_ENGINE_RESOURCES.filter( (r) => r.category === "configuration", ).map((resource) => ({ prefix: `${RULE_ENGINE_CATEGORY_BASE_PATH.configuration}/${resource.slug}`, meta: { title: resource.label, subtitle: resource.subtitle, }, })); const rulesRouteMeta = RULE_ENGINE_RESOURCES.filter((r) => r.category === "rules").map( (resource) => ({ prefix: `${RULE_ENGINE_CATEGORY_BASE_PATH.rules}/${resource.slug}`, meta: { title: resource.label, subtitle: resource.subtitle, }, }), ); const ROUTE_META: Array<{ prefix: string; meta: PageMeta }> = [ { prefix: "/dashboard/overview", meta: { title: "Overview", subtitle: "Dashboard summary and key metrics", }, }, { prefix: "/dashboard/overview/bookings", meta: { title: "Bookings", subtitle: "Booking volume, pipeline, and recent activity" }, }, { prefix: "/dashboard/overview/contracts", meta: { title: "Contracts", subtitle: "Contract volume, pipeline, and recent activity" }, }, { prefix: "/dashboard/overview/billing", meta: { title: "Billing", subtitle: "Revenue, payments, and collection status" }, }, { prefix: "/dashboard/overview/operations", meta: { title: "Operations", subtitle: "Trains, schedules, containers, and cargo" }, }, { prefix: "/dashboard/overview/fleet", meta: { title: "Fleet", subtitle: "Wagon and train fleet status" }, }, { prefix: "/dashboard/overview/customers", meta: { title: "Customers", subtitle: "Customer growth and top accounts" }, }, { prefix: "/dashboard/overview/staff", meta: { title: "Staff", subtitle: "Employee and user account status" }, }, { prefix: "/dashboard/profile", meta: { title: "My Profile", subtitle: "Manage your account and signature", }, }, { // Invoices, Payments, and USD Payments are tabs on one page now // (FinanceHubPage); the header title itself is set per-tab there. prefix: "/dashboard/invoices", meta: { title: "Invoices", subtitle: "Invoices, payments, and USD bank transfers", }, }, { prefix: "/dashboard/operations/first-mile", meta: { title: "First Mile", subtitle: "Assign vehicles to initial-leg pickups", }, }, { prefix: "/dashboard/operations/last-mile", meta: { title: "Last Mile", subtitle: "Assign vehicles to final-leg deliveries" } }, { prefix: "/dashboard/warehouse-dashboard", meta: { title: "Warehouse Dashboard", subtitle: "Live overview of warehouse capacity and inventory lifecycle", }, }, { prefix: "/dashboard/warehouses/", meta: { title: "Warehouse detail", subtitle: "Yards, zones, and inventory for this warehouse", }, }, { prefix: "/dashboard/warehouses", meta: { title: "Warehouses", subtitle: "Manage warehouses, yards and zones", }, }, { prefix: "/dashboard/operations/train-scheduling-v2/", meta: { title: "Train schedule", subtitle: "Assign bookings, auto-pin wagons, finalize and dispatch", }, }, { prefix: "/dashboard/operations/train-scheduling-v2", meta: { title: "Train Schedules", subtitle: "Operational train scheduling with full allocation workflow", }, }, { prefix: "/dashboard/routes", meta: { title: "Routes", subtitle: "Manage route definitions built from freight yards", }, }, { prefix: "/dashboard/warehouses/list", meta: { title: "Warehouses", subtitle: "Manage warehouses, yards, and zones", }, }, { prefix: "/dashboard/warehouse-inventory", meta: { title: "Warehouse inventory", subtitle: "Track received items through inspection and loading", }, }, { prefix: "/dashboard/inventory-inquiry", meta: { title: "Inventory inquiry", subtitle: "Locate cargo, containers, and goods inside the warehouse network", }, }, { prefix: "/dashboard/warehouses", meta: { title: "Warehouse dashboard", subtitle: "Live overview of warehouse capacity and inventory lifecycle", }, }, ...getFleetRouteMeta(), { prefix: "/dashboard/trains/", meta: { title: "Train detail", subtitle: "Manage fleet consist and wagon assignments", }, }, { prefix: "/dashboard/user-management/employees", meta: { title: "Employees", subtitle: "Manage employee accounts and assignments", }, }, { prefix: "/dashboard/user-management/permissions", meta: { title: "Permissions", subtitle: "Configure access permissions for roles and users", }, }, { prefix: "/dashboard/user-management/roles", meta: { title: "Roles", subtitle: "Manage roles and their permission sets", }, }, { prefix: "/dashboard/user-management", meta: { title: "User management", subtitle: "Organization structure, employees, roles, and permissions", }, }, { prefix: "/dashboard/file-settings", meta: { title: "File Settings", subtitle: "Configure file upload rules and document fields", }, }, { prefix: "/dashboard/dropdown-settings", meta: { title: "Dropdown Settings", subtitle: "Manage dropdown options used across the platform", }, }, { prefix: "/dashboard/configuration/contract-validity-periods", meta: { title: "Contract validity periods", subtitle: "Validity options staff choose when accepting a submitted contract", }, }, { prefix: "/dashboard/configuration/train-scheduling-rules", meta: { title: "Train scheduling rules", subtitle: "Global limits for train length, weight, wagons, and 20ft container balance", }, }, { prefix: RULE_ENGINE_CATEGORY_BASE_PATH.configuration, meta: { title: "Configuration", subtitle: "Master data: cargo, containers, wagon types, services, yards, and shipping lines", }, }, ...configurationRouteMeta, { prefix: RULE_ENGINE_CATEGORY_BASE_PATH.rules, meta: { title: "Rules", subtitle: "Priority, weight limits, rates, and approval workflows", }, }, ...rulesRouteMeta, { prefix: "/dashboard/wagon-types", meta: { title: "Wagon Types", subtitle: "Manage wagon type capacity and supported load configuration", }, }, { prefix: "/dashboard/user1", meta: { title: "Demo User 1", subtitle: "Demo workspace", }, }, { prefix: "/dashboard/user2", meta: { title: "Demo User 2", subtitle: "Demo workspace", }, }, ]; export const getPageMeta = (pathname: string): PageMeta => { const normalized = pathname.toLowerCase(); const sorted = [...ROUTE_META].sort((a, b) => b.prefix.length - a.prefix.length); const match = sorted.find(({ prefix }) => normalized.startsWith(prefix.toLowerCase())); if (match) { return match.meta; } return { title: APP_TITLE, subtitle: APP_SUBTITLE, }; };