27 lines
830 B
TypeScript
27 lines
830 B
TypeScript
/**
|
|
* @file Pollution related constants, aligned with backend enums.
|
|
*/
|
|
|
|
/**
|
|
* Represents the types of pollution, consistent with the `PollutionType` enum in the backend.
|
|
* This ensures that frontend displays and data submissions are aligned with backend expectations.
|
|
*/
|
|
export const POLLUTION_TYPES = ['PM25', 'O3', 'NO2', 'SO2', 'OTHER'] as const;
|
|
|
|
/**
|
|
* Type definition for a single pollution type.
|
|
* Ensures type safety when working with pollution constants.
|
|
*/
|
|
export type PollutionType = typeof POLLUTION_TYPES[number];
|
|
|
|
/**
|
|
* A map to provide human-readable names for pollution types.
|
|
* Useful for displaying in UI components like chart legends or labels.
|
|
*/
|
|
export const POLLUTION_TYPE_MAP: Record<PollutionType, string> = {
|
|
PM25: 'PM2.5',
|
|
O3: 'O₃',
|
|
NO2: 'NO₂',
|
|
SO2: 'SO₂',
|
|
OTHER: '其他',
|
|
};
|