Gas Station Feature
This commit is contained in:
71
frontend/src/core/config/config.types.ts
Normal file
71
frontend/src/core/config/config.types.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Runtime Configuration Types
|
||||
*
|
||||
* Configuration loaded at container startup from secrets.
|
||||
* Mirrors Kubernetes deployment patterns where secrets are mounted as files
|
||||
* and read at runtime before application initialization.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Application runtime configuration
|
||||
* Loaded from window.CONFIG set by /config.js
|
||||
*/
|
||||
export interface AppConfig {
|
||||
/** Google Maps JavaScript API key for map visualization */
|
||||
googleMapsApiKey: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Window augmentation for runtime config
|
||||
* config.js is loaded before the React app initializes
|
||||
*/
|
||||
declare global {
|
||||
interface Window {
|
||||
CONFIG?: AppConfig;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get application configuration with validation
|
||||
* Throws if required configuration is missing
|
||||
*
|
||||
* @returns Application configuration object
|
||||
* @throws Error if configuration is not loaded or invalid
|
||||
*/
|
||||
export function getConfig(): AppConfig {
|
||||
if (!window.CONFIG) {
|
||||
throw new Error(
|
||||
'Application configuration not loaded. Ensure config.js is loaded before the app initializes.'
|
||||
);
|
||||
}
|
||||
|
||||
return window.CONFIG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Google Maps API key
|
||||
* Returns empty string if key is not available (graceful fallback)
|
||||
*
|
||||
* @returns Google Maps API key or empty string
|
||||
*/
|
||||
export function getGoogleMapsApiKey(): string {
|
||||
try {
|
||||
const config = getConfig();
|
||||
return config.googleMapsApiKey || '';
|
||||
} catch {
|
||||
console.warn(
|
||||
'Google Maps API key not available. Maps functionality will be limited.'
|
||||
);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if configuration is available
|
||||
* Useful for conditional feature enablement
|
||||
*
|
||||
* @returns true if config is loaded, false otherwise
|
||||
*/
|
||||
export function isConfigLoaded(): boolean {
|
||||
return !!window.CONFIG;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { create } from 'zustand';
|
||||
import { persist, createJSONStorage } from 'zustand/middleware';
|
||||
import { safeStorage } from '../utils/safe-storage';
|
||||
|
||||
export type MobileScreen = 'Dashboard' | 'Vehicles' | 'Log Fuel' | 'Documents' | 'Settings';
|
||||
export type MobileScreen = 'Dashboard' | 'Vehicles' | 'Log Fuel' | 'Stations' | 'Documents' | 'Settings';
|
||||
export type VehicleSubScreen = 'list' | 'detail' | 'add' | 'edit';
|
||||
|
||||
interface NavigationHistory {
|
||||
|
||||
Reference in New Issue
Block a user