96 lines
5.3 KiB
TypeScript
96 lines
5.3 KiB
TypeScript
import type { ElementType } from 'react';
|
|
import LocalShippingOutlined from '@mui/icons-material/LocalShippingOutlined';
|
|
import Inventory2Outlined from '@mui/icons-material/Inventory2Outlined';
|
|
import ConstructionOutlined from '@mui/icons-material/ConstructionOutlined';
|
|
import DirectionsBusOutlined from '@mui/icons-material/DirectionsBusOutlined';
|
|
import DirectionsCarOutlined from '@mui/icons-material/DirectionsCarOutlined';
|
|
import BusinessOutlined from '@mui/icons-material/BusinessOutlined';
|
|
import BadgeOutlined from '@mui/icons-material/BadgeOutlined';
|
|
import TrendingUpOutlined from '@mui/icons-material/TrendingUpOutlined';
|
|
import GroupsOutlined from '@mui/icons-material/GroupsOutlined';
|
|
import PeopleAltOutlined from '@mui/icons-material/PeopleAltOutlined';
|
|
import WarehouseOutlined from '@mui/icons-material/WarehouseOutlined';
|
|
import StoreOutlined from '@mui/icons-material/StoreOutlined';
|
|
import CheckCircleOutline from '@mui/icons-material/CheckCircleOutlineOutlined';
|
|
import ScheduleOutlined from '@mui/icons-material/ScheduleOutlined';
|
|
import ErrorOutlineOutlined from '@mui/icons-material/ErrorOutlineOutlined';
|
|
import UndoOutlined from '@mui/icons-material/UndoOutlined';
|
|
import BlockOutlined from '@mui/icons-material/BlockOutlined';
|
|
import AutorenewOutlined from '@mui/icons-material/AutorenewOutlined';
|
|
import PublicOutlined from '@mui/icons-material/PublicOutlined';
|
|
import MapOutlined from '@mui/icons-material/MapOutlined';
|
|
import SchoolOutlined from '@mui/icons-material/SchoolOutlined';
|
|
import WorkOutline from '@mui/icons-material/WorkOutlineOutlined';
|
|
import DashboardOutlined from '@mui/icons-material/DashboardOutlined';
|
|
import CategoryOutlined from '@mui/icons-material/CategoryOutlined';
|
|
|
|
/** A vivid, fixed tint per code — picked to read well in both light and dark mode, like the old dashboard's icons. */
|
|
export interface Tint {
|
|
icon: ElementType;
|
|
color: string;
|
|
}
|
|
|
|
// entities shown as the colourful overview stat cards
|
|
const ENTITY: Record<string, Tint> = {
|
|
TRUCKS: { icon: LocalShippingOutlined, color: '#2c98d4' },
|
|
TRAILERS: { icon: Inventory2Outlined, color: '#cbb67d' },
|
|
EQUIPMENTS: { icon: ConstructionOutlined, color: '#5fb87a' },
|
|
BUSES: { icon: DirectionsBusOutlined, color: '#d16475' },
|
|
CARS: { icon: DirectionsCarOutlined, color: '#7c6fd1' },
|
|
USERS: { icon: PeopleAltOutlined, color: '#2c98d4' },
|
|
PERSONNEL: { icon: PeopleAltOutlined, color: '#2c98d4' },
|
|
DRIVERS: { icon: BadgeOutlined, color: '#a5894f' },
|
|
COMPANIES: { icon: BusinessOutlined, color: '#2c98d4' },
|
|
OWNERS: { icon: BadgeOutlined, color: '#cbb67d' },
|
|
INVESTORS: { icon: TrendingUpOutlined, color: '#5fb87a' },
|
|
OTHER_STAKEHOLDERS: { icon: GroupsOutlined, color: '#7c6fd1' },
|
|
FREEZONE_CLEARING_COMPANIES: { icon: WarehouseOutlined, color: '#d1a233' },
|
|
FREEZONE_DEPOSITORS: { icon: StoreOutlined, color: '#d16475' },
|
|
};
|
|
|
|
// statuses used across every status breakdown (fleet, personnel, stakeholders…)
|
|
const STATUS: Record<string, Tint> = {
|
|
REGISTERED: { icon: CheckCircleOutline, color: '#5fb87a' },
|
|
ACTIVE: { icon: CheckCircleOutline, color: '#5fb87a' },
|
|
SUBSCRIPED: { icon: CheckCircleOutline, color: '#5fb87a' },
|
|
PENDING: { icon: ScheduleOutlined, color: '#e2a93b' },
|
|
PENDING_UPDATE: { icon: AutorenewOutlined, color: '#2c98d4' },
|
|
INCOMPLETE: { icon: ErrorOutlineOutlined, color: '#d1a233' },
|
|
RETURNED: { icon: UndoOutlined, color: '#7c6fd1' },
|
|
INACTIVE: { icon: BlockOutlined, color: '#8d98a4' },
|
|
NOT_SUBSCRIPED: { icon: BlockOutlined, color: '#8d98a4' },
|
|
};
|
|
|
|
/** Card-header icon for a dashboard block, keyed by its DASHBOARD_SECTION / infographic key. */
|
|
export const BLOCK_ICON: Record<string, Tint> = {
|
|
REGISTERED_STAKEHOLDER: { icon: GroupsOutlined, color: '#2c98d4' },
|
|
STAKEHOLDER_STATUS_CODES: { icon: CheckCircleOutline, color: '#5fb87a' },
|
|
STAKEHOLDER_LOCATION: { icon: MapOutlined, color: '#7c6fd1' },
|
|
STAKEHOLDER_FLEET: { icon: LocalShippingOutlined, color: '#2c98d4' },
|
|
PERSONNEL_HEADER: { icon: PeopleAltOutlined, color: '#2c98d4' },
|
|
PERSONNEL_EDUCATIONAL_LEVEL: { icon: SchoolOutlined, color: '#7c6fd1' },
|
|
PERSONNEL_EMPLOYMENT_CATEGORY: { icon: WorkOutline, color: '#d1a233' },
|
|
PERSONNEL_STATUS_CODES: { icon: CheckCircleOutline, color: '#5fb87a' },
|
|
PERSONNEL_RELATIVES: { icon: GroupsOutlined, color: '#d16475' },
|
|
TOP_NATIONALITY: { icon: PublicOutlined, color: '#2c98d4' },
|
|
USAGE_TYPE_CARGO: { icon: Inventory2Outlined, color: '#cbb67d' },
|
|
USAGE_TYPE_TANK: { icon: Inventory2Outlined, color: '#d16475' },
|
|
TRAILERS_TYPE: { icon: Inventory2Outlined, color: '#2c98d4' },
|
|
OTHER_TRAILERS_TYPE: { icon: Inventory2Outlined, color: '#7c6fd1' },
|
|
FLEET_LOCATION: { icon: MapOutlined, color: '#5fb87a' },
|
|
TOTALS: { icon: DashboardOutlined, color: '#2c98d4' },
|
|
};
|
|
|
|
const FALLBACK_ICON = CategoryOutlined;
|
|
// cycled for codes we have no specific tint for, so every slice/tile still gets a distinct colour
|
|
const PALETTE = ['#2c98d4', '#d16475', '#5fb87a', '#e2a93b', '#7c6fd1', '#cbb67d', '#1cabe3', '#a5894f', '#8d98a4', '#13964c'];
|
|
|
|
/** The tint for one item's code (entity name, status, category…), falling back to a cycled colour. */
|
|
export function itemTint(code: string | undefined, index: number): Tint {
|
|
if (code && ENTITY[code]) return ENTITY[code];
|
|
if (code && STATUS[code]) return STATUS[code];
|
|
return { icon: FALLBACK_ICON, color: PALETTE[index % PALETTE.length] };
|
|
}
|
|
|
|
export const blockIcon = (key: string): Tint | undefined => BLOCK_ICON[key];
|