FEAT: Enhance berth color handling in dashboard components and improve authentication middleware with caching
This commit is contained in:
32
utils/berthColors.ts
Normal file
32
utils/berthColors.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Berth area color mapping based on the Port Nimara layout
|
||||
*/
|
||||
export const berthAreaColors: Record<string, string> = {
|
||||
'A': '#E67E22', // Orange/Brown
|
||||
'B': '#F1C40F', // Yellow
|
||||
'C': '#27AE60', // Green
|
||||
'D': '#3498DB', // Blue
|
||||
'E': '#E91E63', // Pink
|
||||
'F': '#9B59B6', // Purple (if exists)
|
||||
'G': '#1ABC9C', // Teal (if exists)
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the color for a berth area
|
||||
* @param area - The area letter
|
||||
* @returns The hex color code for the area
|
||||
*/
|
||||
export function getBerthAreaColor(area: string): string {
|
||||
return berthAreaColors[area?.toUpperCase()] || '#757575'; // Grey fallback
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color from a mooring number (e.g., "A1" -> orange)
|
||||
* @param mooringNumber - The full mooring number
|
||||
* @returns The hex color code for the area
|
||||
*/
|
||||
export function getBerthColorFromMooringNumber(mooringNumber: string): string {
|
||||
if (!mooringNumber) return '#757575'; // Grey fallback
|
||||
const area = mooringNumber.charAt(0).toUpperCase();
|
||||
return getBerthAreaColor(area);
|
||||
}
|
||||
Reference in New Issue
Block a user