Files
co-lite/solvway-admin-portal/app/components/app/icon-map.ts
T
ngqileandClaude Opus 5.5 5ee51d1913 chore: copy kept Tastefully modules and portals into Co-Lite
Backend modules from tastefully 8bd93d15: core-libs, core-session,
api-gateway, mobile-api, services-auth, services-system,
services-counter, services-member, services-log, services-email.
solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal
from tastefully 8bd93d15. Copied as tracked files only.

Literal secrets replaced with environment placeholders:
- services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY,
  MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default)
- services-system: JUMIO_TOKEN, JUMIO_SECRET (optional)
- services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed
- core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default
  removed, ipgeolocation key read from IPGEOLOCATION_API_KEY
- services-system EkycAppConfig: commented Jumio credentials removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-26 15:55:45 +08:00

100 lines
4.1 KiB
TypeScript

import { Activity, ArrowDownToLine, ArrowLeftRight, BarChart2, Bell, Box, Calendar, Circle, ClipboardList, Coins, CreditCard, FileText, GalleryHorizontalEnd, Gift, History, LayoutDashboard, Languages, Layers, Mail, Megaphone, Menu, MessagesSquare, Network, Package, Settings, Shield, ShieldCheck, ShoppingCart, SlidersHorizontal, Star, Store, Tags, ScrollText, Undo2, UserCheck, UserCog, Users, Wallet, Warehouse, Wrench } from "lucide-react";
import type { LucideIcon } from "lucide-react";
// Maps the aclMenu tree's `iconName` (a plain string served by
// solvway-services-system — see AdminModule.iconName) to a lucide-react icon
// component. A curated map, not `import * as Icons from "lucide-react"`: the
// old src/components/app/nav-config.ts imported icon components directly, and
// pulling in the whole icon set here would ship every lucide icon to the
// browser for a handful of nav entries. Extend this map as more modules are
// seeded with new iconName values.
const ICONS: Record<string, LucideIcon> = {
LayoutDashboard,
// Activity group (add-online-users): BO_NAV_ACTIVITY, Online users and Audit log seed icons.
Activity,
UserCheck,
ScrollText,
Users,
FileText,
Network,
Languages,
// Collapsible nav group headers (add-admin-portal-nav-groups).
Shield,
Settings,
// Notifications module (add-admin-internal-notifications, seed id 41300000).
Bell,
// Catalogue Setup module (add-admin-catalog-setup): BO_CATALOG nav group and
// BO_CATALOG_SETUP page.
Package,
Tags,
Layers,
// Product Setup module (add-admin-product-setup): BO_PRODUCTS page seed icon.
Box,
// Inventory module (add-inventory-stock-in): Stock In and Stock on Hand seed icons.
ArrowDownToLine,
BarChart2,
// Inventory transfers + movement history (add-inventory-transfers-movement-history, I3):
// Transfers and Movement History seed icons.
ArrowLeftRight,
History,
// Inventory adjustments (add-inventory-adjustments, I4):
// Adjustments seed icon.
SlidersHorizontal,
// Events module (add-event-module-pickup-e1, E1):
// Events page seed icon.
Calendar,
// POS counter-sales module (add-event-pos-counter-sales):
// POS page seed icon (sql/02-seed-bo-module-pos.sql icon_name = 'ShoppingCart').
ShoppingCart,
// Payment Methods module (add-payment-method-config, 2a):
// seed icon_name = 'CreditCard'.
CreditCard,
// Branch Counter POS module (add-branch-counter-sale):
// seed icon_name = 'Store'.
Store,
// Refund Requests (add-refund-requests, seed id 44300000).
Undo2,
// Gift Cards (add-gift-card-core, seed id 45000000, icon_name 'Gift').
Gift,
// Live BO module icon_name values that rendered the fallback circle
// (fix-admin-sidebar-groups-icons).
ShieldCheck,
Wallet,
Mail,
Coins,
Megaphone,
Warehouse,
UserCog,
GalleryHorizontalEnd,
// add-member-messaging: BO_MEMBER_MESSAGES seed icon_name = 'MessagesSquare'.
MessagesSquare,
// BABYBOO-43: BO_RANK_REFERRAL seed icon_name = 'Wrench'.
Wrench,
// Product reviews (add-product-reviews, seed id 44800000).
Star,
// Forms (add-cms-forms, seed id 45200000).
ClipboardList,
// Menus (add-storefront-menus, seed id 45300000).
Menu,
};
/**
* The curated icon allowlist (add-admin-module-node-crud): the /modules create/edit dialog
* offers EXACTLY these names — an icon outside the map would render the neutral fallback
* circle, so a dead icon can never be picked. Adding a new icon is a code change here.
*/
export const ICON_NAMES: readonly string[] = Object.keys(ICONS);
/** Neutral fallback for an absent or unrecognised `iconName` (spec: "The
* Sidebar Renders Lucide Icons From icon_name" — unmapped names MUST render
* a safe fallback, not throw). A plain circle, distinct from every seeded
* icon, so a nav entry never renders with no icon at all. */
const FALLBACK_ICON: LucideIcon = Circle;
/** Looks up the icon for an aclMenu node's `iconName`. Unrecognised or absent
* names resolve to the neutral fallback icon rather than throwing. */
export function iconFor(iconName: string | undefined): LucideIcon {
if (!iconName) return FALLBACK_ICON;
return ICONS[iconName] ?? FALLBACK_ICON;
}